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:


module.exports = function(deployer) {
  deployer.deploy(CrowdTestToken).then((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?


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

    return deployer.deploy(CrowdSale, CrowdTestToken.address)});

Your Answer

