when I run my deploy script in console, ContractContainer has the newly deployed contract-address. But when I try to reference that in tests, ContractContainer seems to be empty. What would be the correct way to reference these already-deployed contracts in my tests easily?

For example: Truffle has an DeployedAddresses contract that is available for import in its Solidity testing suite... So I can reference already-deployed contract(-addresses) like this: address contractAddress = DeployedAdresses.ContractName()

For Brownie the somewhat equivalent seems to be the ContractContainer, being filled with ProjectContract objects (upon deployment). When I run my deploy script in console, the ContractContainer is filled and ProjectContract available to the console. Yet, when I try to reference this in my tests, it seems to be empty. Am I missing something?

Is there a way to run tests in the console? Maybe that would be part of the solution for me.

1 Answer 1


When you run a development chain (those under the Development section after running brownie networks list), all contracts deployed only live in the instance that the chain is alive, so every time you run a new script, the entire blockchain is scrapped.

You can access deployed contracts on a chain, by referencing their index. Let's say you have a contract named SimpleStorage, you could reference the most recently deploy contract with:

simple_storage = SimpleStorage[-1]

But again, those contracts will have to have been deployed.

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.