不能部署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: "*" // 所有id都匹配
}
}
};