Reputation: 33
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/01_deploy_price_consumer_v3.py
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:\Users\N\new\chainlink-mix>brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py
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 "C:\Users\N\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\_cli\__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "C:\Users\N\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\_cli\run.py", line 43, in main
network.connect(CONFIG.argv["network"])
File "C:\Users\N\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\main.py", line 55, in connect
p._load_deployments()
File "C:\Users\N\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 357, in _load_deployments
contract = ProjectContract(self, build, build_json.stem)
File "C:\Users\N\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\contract.py", line 1292, in __init__
_DeployedContractBase.__init__(self, address, owner, tx)
File "C:\Users\N\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\contract.py", line 758, in __init__
raise ContractNotFound(f"No contract deployed at {address}")
ContractNotFound: No contract deployed at 0xa1d97e44c6Ac5327DEa2deCAb5f9E1085b8Bcf38
Upvotes: 1
Views: 973
Reputation: 6131
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:
Ethereum
├─Mainnet (Infura): mainnet
└─ganache: ganache (brownie will remember these)
Development
├─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/02_whatever_this_one_is.py
since brownie won't remember any contracts being there.
Upvotes: 3