0

I have created a fork of the ethereum mainnet using Alchemy. When I try to fetch the WETH contract in the fork, it says no contract deployed at the given address (0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2). However, when I do the same in Goerli testnet, I don't face any issues. Below is the code I use to test:

enter image description here

Below is the definition of the mainnet fork:

enter image description here

Any help would be highly appreciated as I'm not sure what is causing this issue.

1 Answer 1

1

Hi dev advocate at Chainstack here!

How you forked it, you'll need to manually re-deploy the smart contracts that you want to interact with, which is not very practical.

Follow this simple tutorial to fork the network using the Ganache CLI; this allows you to fork at a specific block.

Now you can point your framework to the new Ganache instance, allowing you to interact with contracts and data on the mainnet deterministically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.