美文网首页
truffle网络设置

truffle网络设置

作者: Simth | 来源:发表于2017-12-19 22:09 被阅读276次

    在使用truffle migrate进行智能合约test环境发布时如果未配置正确会出现以下异常:

    $ 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
    

    导致上面异常的原因为是因为truffle.js里面未配置链接合约发布的环境地址,找到对应的truffle.js文件,修改代码为类似如下配置即可解决问题:

    module.exports = {
        networks: {
            development: {
                host: "localhost",
                port: 8545,
                network_id: "*" // 匹配任何network id
             }
        }
    };
    

    相关文章

      网友评论

          本文标题:truffle网络设置

          本文链接:https://www.haomeiwen.com/subject/fhxwwxtx.html