0

In my truffle project I have two smart contracts A and B. I need to call a public function in smart contract A from smart contract B. Therefore at deployment of smart contract B, I will have to provide the address of smart contract A in the constructor of smart contract B.

But with truffle when I enter truffle migrate --reset all the two smart contracts get migrated one after the other. In the migration file of B how can I get the address of smart contract A that was deployed seconds ago and provide it to B?

1 Answer 1

0

You can use another option of truffle migrate called --to.

--to <number>: Run contracts to a specific migration. The number refers to the prefix of the migration file.

That way you can deploy the first contract, then save its address and deploy the second one. That's the easiest way that I thought of so far.

1

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.