chainlink-mix
chainlink-mix copied to clipboard
Cannot Read script on ganache development network
I am seeing that my local testing with ganche-cli is causing some issues connecting to the same network.
Repro steps:
- Set the default network in the yanl file to
ganache. - Install ganache-cli via npm. Start ganache-cli in one terminal tab.
- Open a new terminal tab and add a ganache network.
brownie networks add Ethereum ganache host=http://localhost:8545 chainid=1337. - Run the deploy script locally with
brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py. Here I was having an issue
$ brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py
Brownie v1.15.1 - Python development framework for Ethereum
ChainlinkMixProject is the active project. File "brownie/_cli/main.py", line 64, in main importlib.import_module(f"brownie._cli.{cmd}").main() File "brownie/_cli/run.py", line 43, in main network.connect(CONFIG.argv["network"]) File "brownie/network/main.py", line 55, in connect p._load_deployments() File "brownie/project/main.py", line 357, in _load_deployments contract = ProjectContract(self, build, build_json.stem) File "brownie/network/contract.py", line 1291, in init _DeployedContractBase.init(self, address, owner, tx) File "brownie/network/contract.py", line 757, in init raise ContractNotFound(f"No contract deployed at {address}") ContractNotFound: No contract deployed at 0xB47a7bDF2C0B546AE73C4352c70BC68B0d479048
- I was able to get this to work by running
brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py --network development. - I then tried to run the read script and I was not able to
brownie run scripts/price_feed_scripts/02_read_price_feed.py
$ brownie run scripts/price_feed_scripts/02_read_price_feed.py
Brownie v1.15.1 - Python development framework for Ethereum
ChainlinkMixProject is the active project. File "brownie/_cli/main.py", line 64, in main importlib.import_module(f"brownie._cli.{cmd}").main() File "brownie/_cli/run.py", line 43, in main network.connect(CONFIG.argv["network"]) File "brownie/network/main.py", line 55, in connect p._load_deployments() File "brownie/project/main.py", line 357, in _load_deployments contract = ProjectContract(self, build, build_json.stem) File "brownie/network/contract.py", line 1291, in init _DeployedContractBase.init(self, address, owner, tx) File "brownie/network/contract.py", line 757, in init raise ContractNotFound(f"No contract deployed at {address}") ContractNotFound: No contract deployed at 0xB47a7bDF2C0B546AE73C4352c70BC68B0d479048
- I retried with the network setting and it did not work due to list index out of range in Python and a BrownieEnvironmentWarning of block height.
$ brownie run scripts/price_feed_scripts/02_read_price_feed.py --network development
Brownie v1.15.1 - Python development framework for Ethereum
ChainlinkMixProject is the active project. /Users/nicklasb/.local/pipx/venvs/eth-brownie/lib/python3.9/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 30 warnings.warn( Attached to local RPC client listening at '127.0.0.1:8545'...
Running 'scripts/price_feed_scripts/02_read_price_feed.py::main'... File "brownie/_cli/run.py", line 49, in main return_value, frame = run( File "brownie/project/scripts.py", line 103, in run return_value = f_locals[method_name](*args, **kwargs) File "./scripts/price_feed_scripts/02_read_price_feed.py", line 6, in main price_feed_contract = PriceFeedConsumer[-1] File "brownie/network/contract.py", line 160, in getitem return self._contracts[i] IndexError: list index out of range
Thanks for making this! Yes... I'll have to make some updates to this mix to better handle self-run ganache chains...
Hi Patrick. I was having the same problems as Nick. I randomly trashed the build folder and all was good again. It seems to be a repeatable 'fix' too. I have no idea why, or if that helps. Just thought I'd speak up!
Cheers
Hi Patrick I'm having an issue with the .env file as well. It's not being able to read my: WEB3_INFURA_PROJECT_ID as well.
thanks for raising @itsencrypted . Can you create a StackOverflow post, posting all the relevant details and steps you took after cloning the repo? https://stackoverflow.com/questions/ask?tags=chainlink
I think this might not be strictly a ganache situation. I ran into this with rinkeby as well and trashing build/ and redoing brownie compile lets me run a test successfully (per @AdiF1 solution). I guess just like work, sometimes you just have to trash your build dir and things magically work again when you recompile.
Hmm... Usually when stuff "magically" starts working in software that's when I start to sweat ahah.
If anyone would like to investigate that would be greatly appreciated!