区块链 truffle 3.0开发入门

区块链 truffle 3.0

网上的教程大多是在2.0基础上的,按照网上文章学习过程中会有一些困惑,整个 demo 的过程基本上网上别人遇到的报错我也都踩了个遍,在这里面记录一下整个学习过程

配置环境

安装truffle 环境

npm install -g truffle

安装 ethereum 客户端

npm install -g ethereumjs-testrpc

开始项目

1.初始化项目

truffle init webpack 

会提示

Using `truffle init` with a specific template is deprecated. Please use `truffle unbox` instead.
Downloading project...
Installing dependencies...
Project initialized.

  Documentation: https://github.com/trufflesuite/truffle-init-webpack

Commands:

  Compile:        truffle compile
  Migrate:        truffle migrate
  Test:           truffle test
  Build Frontend: npm run build
  Run Linter:     npm run lint
  Run Dev Server: npm run dev

Hint: Run the dev server via `npm run dev` to have your changes rebuilt automatically.

Make sure you have an Ethereum client like the ethereumjs-testrpc running on http://localhost:8545.

2.编译项目

truffle compile

将会把 contracts 中的.sol编译成.json能够在build/contracts/*.json看到
3.部署项目
新开一个终端,启动Ethereum客户端

testrpc

4.部署

truffle migrate

在 testrpc 中将会看到

net_version
eth_accounts
eth_accounts
net_version
net_version
eth_sendTransaction

  Transaction: 0x74c7b56ab9f04b6cd30d729df956980f23fd9042ea6102e09c0d63954d694594
  Contract created: 0xda53fa14d825f41f449cdb80c11791e8ad043670
  Gas usage: 199673
  Block Number: 1
  Block Time: Wed Jan 10 2018 18:49:26 GMT+0800 (CST)

5.运行

truffle serve

根据上面的提示打开http://localhost:8080/ 就能看到教程上面说的网页了额
这个是官方文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值