Closed vlasebian closed 2 years ago
Hello there @vlasebian
This line:
if network.show_active() in ["mainnet-fork"]:
should be:
`if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
Also you must import LOCAL_BLOCKCHAIN_ENVIRONMENTS from helpful scripts.
I made the suggested changes, this is my updated aave_borrow.py
:
from brownie import network, config
from scripts.util import LOCAL_BLOCKCHAIN_ENVIRONMENTS, get_account
from scripts.get_weth import get_weth
def main():
account = get_account()
erc20_address = config["networks"][network.show_active()]["weth_token"]
if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
get_weth()
However, I still get the same error as before:
ContractNotFound: No contract deployed at 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
It seems a problem with you alchemy then, make sure your app looks like this:
Also delete the mainnet-fork network and try adding again.
I had the environment set to Staging, I changed it to Development. Then, I removed the network and added it again like this:
brownie networks delete mainnet-fork
brownie networks add development mainnet-fork cmd=ganache-cli host=http://127.0.0.1 fork=https://eth-mainnet.alchemyapi.io/v2/<key> accounts=10 mnemonic=brownie port=8545
It still gives me the same error :(
This is weird, the error is saying that there is not a contract on that address, but that address actually exists: https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 just for curiosity, are you adding the --network identifier
when you run it?
This is how I run it:
brownie run scripts/get_weth.py --network mainnet-fork
Jum this is weird, @PatrickAlphaC Have you any clue on this?
Odd... What happens when you do
brownie console --network mainnet-fork
And then in the shell
from scripts.helpful_scripts import
weth = interface.IWeth(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)
print(weth)
Or also try:
print(Contract(f"{pair}.data.eth").latestAnswer() / 1e8)
If both of those don't work, it means you're not actually connecting to a mainnet fork.
brownie networks add development mainnet-fork cmd=ganache-cli host=http://127.0.0.1 fork=<FORK> accounts=10 mnemonic=brownie port=8545
Yep I was thinking the same, is not connecting to mainnet fork, @vlasebian did something Patrick said helped you.
Hello, I'm having the same problem on my code. Try to add again the mainnet-fork with @cromewar specs. Also tried what @PatrickAlphaC ask for and it seems that is not connecting to a mainnet-fork. @vlasebian you were able to solve this? Anything else that I can check on this?
Okay, I think I solved it, but please let me know if this is something that it's okay to do. So I went to settings in my ganache app and under server tab I turned this on and add the alchemy fork address. the I ran:
PS C:\Users\ezequ\demos\aave_brownie> brownie run scripts/aave_borrow.py --network mainnet-fork
INFORMACIÓN: no se pudo encontrar ningún archivo para los patrones dados.
Brownie v1.17.2 - Python development framework for Ethereum
AaveBrownieProject is the active project.
C:\Users\ezequ\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\main.py:44: BrownieEnvironmentWarning: Development network has a block
height of 14495918
warnings.warn(
Attached to local RPC client listening at '127.0.0.1:7545'...
Running 'scripts\aave_borrow.py::main'...
Transaction sent: 0xb23bd37f9b1d3f361e93dffa6e06392d29c27012367f7a73c7e3d9e05116a842
Gas price: 0.0 gwei Gas limit: 6721975 Nonce: 0
Transaction confirmed Block: 14495919 Gas used: 28738 (0.43%)
Transaction confirmed Block: 14495919 Gas used: 28738 (0.43%)
Recieved 0.1 weth
something that kept my attention was this:
BrownieEnvironmentWarning: Development network has a block height of 14495918
Is there something else to set up in Brownie?
Also, when I click under blocks or transactions tabs on my ganache app this bug appears
It's working now but let me know if there is something else to set up on my ganache up.
Hi , thank you for such a great course . I am facing the same issue. If not solve how can I possibly circumvent this problem?
hello @EzeCerino and @MayankB02 sorry for the delay, please go to %APPDATA% and delete the ganache folder, and then try opening it again.
Thanks @cromewar . Its working now .
Hello!
First of all, thank you for providing such a great course on smart contracts!
I am stuck at lesson 10 while trying to get some WETH. I believe it may be something related to how I forked the mainnet, but I couldn't solve the issue.
This is the error that I get when i run
brownie run scripts/aave_borrow.py
:This is how I added the mainnet-fork to brownie networks:
This is my code:
What am I doing wrong here?
Thanks, Vlad