Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Read script on ganache development network #20

Open
nickbeaird opened this issue Jul 25, 2021 · 6 comments
Open

Cannot Read script on ganache development network #20

nickbeaird opened this issue Jul 25, 2021 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest

Comments

@nickbeaird
Copy link

nickbeaird commented Jul 25, 2021

I am seeing that my local testing with ganche-cli is causing some issues connecting to the same network.

Repro steps:

  1. Set the default network in the yanl file to ganache.
  2. Install ganache-cli via npm. Start ganache-cli in one terminal tab.
  3. Open a new terminal tab and add a ganache network. brownie networks add Ethereum ganache host=http://localhost:8545 chainid=1337.
  4. 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

  1. I was able to get this to work by running brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py --network development.
  2. 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

  1. 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

@PatrickAlphaC
Copy link
Contributor

Thanks for making this! Yes... I'll have to make some updates to this mix to better handle self-run ganache chains...

@PatrickAlphaC PatrickAlphaC added good first issue Good for newcomers enhancement New feature or request labels Jul 27, 2021
@AdiF1
Copy link

AdiF1 commented Aug 9, 2021

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

@itsencrypted
Copy link

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.

@pappas999
Copy link
Collaborator

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

@ANG3L0
Copy link

ANG3L0 commented Jan 22, 2022

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.

@PatrickAlphaC
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest
Projects
None yet
Development

No branches or pull requests

6 participants