1

Im doing the tutorial at https://github.com/ConsenSys-Academy/proof-of-existence-exercise and running into the following error:

$ truffle console
truffle(development)> var poe = await ProofOfExistence2.at(ProofOfExistence2.address)
Thrown:
Error: ProofOfExistence2 has no network configuration for its current network id (1575203139857).
    at evalmachine.<anonymous>:1:48
    at Function.getter (C:\Users\mrleo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\constructorMethods.js:243:1)
    at Function.get (C:\Users\mrleo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\properties.js:129:1)
    at Function.getter (C:\Users\mrleo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\constructorMethods.js:246:1)
    at Function.network (C:\Users\mrleo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\properties.js:108:1)
truffle(development)> truffle(development)>

1

3 Answers 3

1

In the migrations directory you have to reference the deployments for any new contracts.

In this case that is the file 2_deploy_contracts.js:

var ProofOfExistence1 = artifacts.require('./ProofOfExistence1.sol');
var ProofOfExistence2 = artifacts.require('./ProofOfExistence2.sol');

module.exports = function(deployer) {
    deployer.deploy(ProofOfExistence1);
    deployer.deploy(ProofOfExistence2);
};

Then run:

truffle migrate --reset

This resolves the issue.

Therefore contract deployments have to be listed in a migrations file.

References:

[1] https://www.trufflesuite.com/docs/truffle/getting-started/running-migrations

[2] https://www.trufflesuite.com/docs/truffle/reference/truffle-commands

[3] https://medium.com/@blockchain101/demystifying-truffle-migrate-21afbcdf3264

1

This error means that Truffle cannot find a network entry for the current network ID in the build artifact file. Whenever a truffle migration is done, the build artifact JSON (typically under build) is updated to include a mapping of network ID to contract address.

Thus whenever you reset your test blockchain, e.g. restart ganache-cli, you need to re-deploy your contracts so that Truffle can find your contracts under the new network ID.

One way to avoid this issue is to specify a custom network ID, say 10312008, when starting the test blockchain:

ganache-cli -i 10312008 --db .ganache/data --deterministic

The above also:

  • specifies a data location for the blockchain state, as using the same network ID each time will probably not be very useful without your previously deployed contracts available on the blockchain
  • specifies a fixed wallet mnemonic, in case your contract logic relies somehow upon deployer addresses, e.g. msg.sender; if that's not the case, you can remove this. Note you can specify your own mnemonic using --mnemonic instead.
0

I had the same error when trying to access MyContract.address wthout trapping the block in a .then() so MyContract was not still deployed when truffle tryed to retrieve the address so it throwed an error.

deployer.deploy(MyContract)
     console.log(MyContract.address)

I forgot the ".then" block...

deployer.deploy(MyContract).then(()=>{
     console.log(MyContract.address)
})

And with that it worked perfectly.

I think your error may be somehow related to mine...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.