1

I want to chain contract deployment, where the second contract gets as a parameter the address of the first using Brownie:

from brownie import ContractA, ContractB , accounts

def main():
    acct = accounts[0]
    ContractA.deploy({'from': acct})
    ContractB.deploy(ContractA.address, {'from': acct})

With web3 and Truffle, the deployed contract instance can be imported and we get its address with .address. However, brownie CountractContainer are function objects and I can't understand how to get the deployed address.

1
  • Were you trying to achieve this on the ganache blockchain?
    – alper
    Commented Jun 21, 2023 at 10:42

1 Answer 1

3

Here is your code with some changes that should work.

from brownie import ContractA, ContractB , accounts

def main():
    acct = accounts[0]
    container = ContractA.deploy({'from': acct})
    ContractB.deploy(container.address, {'from': acct})

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.