Estoy usando testrpc. Mientras ejecuto la migración de trufas, aparece el siguiente 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).
Mi truffle.js como el siguiente contenido
// 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
}
}
}
¿Qué me estoy perdiendo? Agradecería cualquier ayuda que reciba. Gracias
Esto parece ocurrir si intenta implementar un contrato A
que depende del contrato B
antes de que el contrato B
haya terminado de implementarse.
Probablemente tengas algo como esto:
module.exports = function(deployer, network, accounts) {
deployer.deploy(B);
deployer.deploy(A, B.address);
};
Es esencialmente una condición de carrera porque B.address
probablemente no esté listo a tiempo para la segunda deployer.deploy
llamada. Así que usa la promesa que deploy
regresa así:
module.exports = function(deployer, network, accounts) {
deployer.deploy(B).then(function() {
return deployer.deploy(A, B.address);
});
};
return
declaración. Después de agregar eso, funcionó.Prefiero esta sintaxis:
module.exports = function(deployer, network, accounts) {
deployer.then(async () => {
await deployer.deploy(A);
await deployer.deploy(B, A.address);
//...
});
};
ya que es mucho más legible cuando tienes muchos contratos.
Consulte también: https://github.com/trufflesuite/truffle/issues/501#issuecomment-373886205
Sanchit
Parthasarathy Ramanujam