Ethereum 由于缺少功能,块菌迁移失败,但它存在于节点_模块中

Ethereum 由于缺少功能,块菌迁移失败,但它存在于节点_模块中,ethereum,solidity,smartcontracts,truffle,ether,Ethereum,Solidity,Smartcontracts,Truffle,Ether,尝试运行块菌迁移时,出现以下错误: Using network 'development'. Running migration: 1_initial_migration.js Replacing Migrations... ... 0x1e30a241296f07f9e4e702f5066031ba128e163fd7858cfd09311ddff14bebf8 Migrations: 0xe1b914764eeed3cceee23a6b8b43365318b219a9 Savi

尝试运行块菌迁移时,出现以下错误:

Using network 'development'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... 0x1e30a241296f07f9e4e702f5066031ba128e163fd7858cfd09311ddff14bebf8
  Migrations: 0xe1b914764eeed3cceee23a6b8b43365318b219a9
Saving successful migration to network...
  ... 0x74086dea1bf5aab373d9091512fea7f84188c05f6c2c071eae45a7eb3f5abc5d
Saving artifacts...
Running migration: 1524796297_will_contract.js
Error encountered, bailing. Network state unknown. Review successful transactions manually.
TypeError: contract.detectNetwork is not a function
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-deployer/src/actions/deploy.js:6:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-deployer/src/deferredchain.js:20:1
它可以很好地编译,但在运行迁移时,它会声明找不到contract.detectNetwork。这很奇怪,因为我可以找到方法。它位于node_modules/truffle contract/contract.js中

detectNetwork: function() {
      var self = this;

      return new Promise(function(accept, reject) {
        // Try to detect the network we have artifacts for.
        if (self.network_id) {
          // We have a network id and a configuration, let's go with it.
          if (self.networks[self.network_id] != null) {
            return accept(self.network_id);
          }
        }

        self.web3.version.getNetwork(function(err, result) {
          if (err) return reject(err);

          var network_id = result.toString();

          // If we found the network via a number, let's use that.
          if (self.hasNetwork(network_id)) {
            self.setNetwork(network_id);
            return accept();
          }

          // Otherwise, go through all the networks that are listed as
          // blockchain uris and see if they match.
          var uris = Object.keys(self._json.networks).filter(function(network) {
            return network.indexOf("blockchain://") == 0;
          });

          var matches = uris.map(function(uri) {
            return BlockchainUtils.matches.bind(BlockchainUtils, uri, self.web3.currentProvider);
          });

          Utils.parallel(matches, function(err, results) {
            if (err) return reject(err);

            for (var i = 0; i < results.length; i++) {
              if (results[i]) {
                self.setNetwork(uris[i]);
                return accept();
              }
            }

            // We found nothing. Set the network id to whatever the provider states.
            self.setNetwork(network_id);

            accept();
          });

        });
      });
    }
Will.sol文件的构造函数:

//Constructor function that initializes passwords, deadline, and defines destination account
    function Will(bytes32 password1, bytes32 password2, uint _deadline) payable {
        deadline = _deadline;
        pass1 = password1;
        pass2 = password2;
        owner = msg.sender;
    }
truffle.js:

 module.exports = {
      networks: {
        development: {
          host: "127.0.0.1",
          port: 8545,
          network_id: "*" // Match any network id
        }
      }
    };

Adam提供的解决方案是100%正确的

deployer.deploy(password1, password2, deadline, {value: 100, from: accounts[0]}); 
应该是

deployer.deploy(will, password1, password2, deadline, {value: 100, from: accounts[0]}); 

你能添加你的
truffle.js
config吗?如果运行
truffle migrate--reset
,会有什么不同吗?更新后,我一直在运行
truffle migrate--reset
,哦…我第一次错过了它。你的部署人员错了。它应该是
deployer.deploy(Will,password1,password2,deadline,{value:100,from:accounts[0]})
deployer.deploy(will, password1, password2, deadline, {value: 100, from: accounts[0]});