1

How do I pass my account address to the contract constructor while deploying with truffle migration? I want to pass address into MyAdress like below.

deployer.deploy(MyContract, MyAddress)

My contract looks like this

address payable public admin;
constructor(address payable _admin) {
        admin = _admin;
}

3 Answers 3

2

You need to define the address as a constant in the deployment file:

const MyAddress = '0x123...'

deployer.deploy(MyContract, MyAddress)
2

Refer address to truffle config file is more appropriable.

module.exports = async function(deployer, network, accounts) {
  const deployerAddress = accounts[0];
  await deployer.deploy(Contract, deployerAddress);
};
2
1

You can also decide to just put in the address deployer.deploy(contractName, "addresshere")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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