[Ethereum] Truffle migrate fails

testrpctruffletruffle-migration

I am using testrpc. While running truffle migrate I get the following error:

/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).

My truffle.js as the following content

// 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
    }
  }
}

What am I missing? Would appreciate any help I get. Thanks

Best Answer

This seems to occur if you're trying to deploy contract A that depends on contract B before contract B has actually finished deploying.

You probably have something like this:

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

It's essentially a race condition because B.address is probably not ready in time for the second deployer.deploy call. So use the promise that deploy returns like this:

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