errors when running 01_deploy_price_consumer twice – killing ganache in brownie

Currently following the chainlink bootcamp on exercise 3: deploying to a local blockchain.

When using ganache, if I have a fresh folder of chainlink-mix after running

brownie run scripts/price_feed_scripts/

everything compiles fine. but when I close ganache(ctrl+C) and open another ganache and run the same command I get a ton of errors.

I can fix the problem if i delete chainlink mix and get a fresh clone. I’d like to know how to solve this without getting a fresh folder every time.

edit: i’m running the 01_deploy_price_consumer command again to see if i can change the default getLatestPrice for eth to 3000 instead of 2000

C:UsersNnewchainlink-mix>brownie run scripts/price_feed_scripts/
INFO: Could not find files for the given pattern(s).
Brownie v1.16.3 - Python development framework for Ethereum

ChainlinkMixProject is the active project.
  File "", line 64, in main
  File "", line 43, in main
  File "", line 55, in connect
  File "", line 357, in _load_deployments
    contract = ProjectContract(self, build, build_json.stem)
  File "", line 1292, in __init__
    _DeployedContractBase.__init__(self, address, owner, tx)
  File "", line 758, in __init__
    raise ContractNotFound(f"No contract deployed at {address}")
ContractNotFound: No contract deployed at 0xa1d97e44c6Ac5327DEa2deCAb5f9E1085b8Bcf38


There are 3 kinds of networks brownie connects to:

  • Ethereum
  • Ethereum Classic (We can ignore this)
  • Development

You can see them by running brownie networks list in your terminal.

When creating a network in the Ethereum category, brownie will save the addresses of the contracts that were deployed, in this case, your local ganache chain is in the Ethereum category. It remembers, but storing addresses in the build folder.

So when you deploy a contract to your local ganache chain the first time, brownie stores addresses in its build folder. Those contracts live on your ganache chain. However, when you delete the ganache chain and create a new one, those contracts are deleted as well, but brownie still thinks they exist.

brownie networks list truncated output:

  ├─Mainnet (Infura): mainnet
  └─ganache: ganache (brownie will remember these)

  ├─Ganache-CLI: development
  └─ganache-temp: ganache-temp (brownie won't remember these)

If you’d like the desired experience to be such that brownie always redeploys, you can create your ganache network in the Development network instead, so brownie won’t remember it’s deployments, and will always deploy fresh.

This will mean though, that you won’t be able to run any of the 2nd scripts, like brownie run scripts/price_feed_scripts/ since brownie won’t remember any contracts being there.