9

I am trying to figure out how to return the address of a contract when I deploy it with truffle's deployer.deploy. So the goal is that when I deploy a contract that is a custom token, I want to return that address once it's deployed and pass that address to my CrowdSale contract constructor. I am getting undefined for the instance of the deployed contract when doing this like so:

1_initial_migration.js

module.exports = function(deployer) {
  deployer.deploy(Migrations);
  deployer.deploy(CrowdTestToken).then((instance) => {
    console.log(instance);
    deployer.deploy(CrowdSale, instance.address);
  });
};

In the above example, instance is undefined. Does anybody know how I can get the address of the CrowdTestToken contract in the deployment script?

1 Answer 1

12

The address of the contract is just the variable name of the deployed contract. Try this:

deployer.deploy(CrowdTestToken).then(function(){
    return deployer.deploy(CrowdSale, CrowdTestToken.address)});
0

Your Answer

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

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