不能部署migrate通过Tunffle编译的以太坊智能合约。我是这么做的:
truffle init
truffle compile
open other terminal and run testrpc
truffle migrate
前三步都正常过了,当我运行truffle migrate时,出现了这个问题:
Error: No network specified. Cannot determine current network.
at Object.detect (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43157:23)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:200497:19
at finished (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43085:9)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:198408:14
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:68162:7
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:163793:9
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:160353:16
at replenish (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:160873:25)
at iterateeCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:160863:17)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:160838:16
开发环境:
- node 9.1.0
- truffle 4.0.1
- testrpc 6.0.3
解决办法:
应该在配置文件truffel.js中设置下networks网络,它位于项目文件夹的根目录中。
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*"
}
}
};
原文:http://cw.hubwiz.com/card/c/ethereum-FAQ/1/2/2/
另外推荐一些之前的教程:
- python以太坊,主要是针对python围绕web3.py进行区块链以太坊应用开发的讲解。
- web3j,主要是针对java和android程序员围绕web3j库进行区块链以太坊开发的讲解。
- php以太坊,主要是介绍使用php进行智能合约开发交互,进行账号创建、交易、转账、代币开发以及过滤器和事件等内容。
- 以太坊开发,主要是介绍使用node.js、mongodb、区块链、ipfs实现去中心化电商DApp实战,适合进阶。
- 以太坊教程,主要介绍智能合约与dapp应用开发,适合入门。