Truffle

松露遷移失敗

  • December 5, 2019

我正在使用 testrpc。執行 truffle migrate 時出現以下錯誤:

/usr/local/lib/node_modules/truffle/node_modules/truffle-contract/contract.js:671
       throw new Error(this.contract_name + " has no network configuration for its current network id (" + network_id + ").");
       ^

Error: XXXTokenFactory has no network configuration for its current network id (1497979617513).

我的 truffle.js 為以下內容

// Allows us to use ES6 in our migrations and tests.
require('babel-register')

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

我錯過了什麼?將不勝感激我得到的任何幫助。謝謝

如果您在合約實際完成部署之前嘗試部署A依賴於合約的合約,這似乎會發生。B``B

你可能有這樣的事情:

module.exports = function(deployer, network, accounts) {
 deployer.deploy(B);
 deployer.deploy(A, B.address);
};

這本質上是一種競爭條件,因為B.address可能沒有及時準備好進行第二次deployer.deploy通話。deploy所以使用這樣返回的承諾:

module.exports = function(deployer, network, accounts) {
 deployer.deploy(B).then(function() {
   return deployer.deploy(A, B.address);
 });
};

引用自:https://ethereum.stackexchange.com/questions/18432