I need your help! I run a hardhat testnet on localhost in a fork goerli mode and would like to test a simple Ether to WETH wrap and unwrap.

I use WETH contract address 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 and copied the ABI.

First, I initialize a contract object:

const wethContract = new ethers.Contract(

Now I can use the deposit and withdraw functions successfully:

 const testSwap = await wethContract.deposit({
      value: ethers.utils.parseEther("1"),

Checking the ETH balance before and after this swap, I can assume that it works and also the terminal shows the transaction:

  Transaction:         0x9431f941bdd23074850ecd7cc9d0c2c8e93001d115e11205f5a38c934376ffbe   
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
  Value:               1 ETH
  Gas used:            21064 of 21065
  Block #8521084:      0x295a494348ab2921220fc8dd693108e617e1444c8015448fd135014da6e3164c

Now I simply want to check the WETH balance of my account:

const wethBalanceBeforeWrap = await wethContract.balanceOf(owner.address);

This does not work but gives me a "Calling an account which is not a contract" error

  WARNING: Calling an account which is not a contract
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

I figured out that all Read functions of the WETH Contract give me this error while I can simply use the Write functions. This is very weird to me - any idea what I'm doing wrong?

2 Answers 2


The address you are using is a contract on Ethreum mainnet. But not on Goerli. So when you call for balanceOf, there is no code at this address.

Instead of forking Goerli you should fork the mainnet.

Or deploy your own WETH contract on Goerli to test with.

  • Thanks a lot! I thought the contract addresses of Mainnet and Goerli are the same. Deploying my own WETH Contract did the trick! Commented Feb 23, 2023 at 19:55
  • Then you could accept my answer! Commented Feb 23, 2023 at 21:26
  • 1
    I hope I just did Commented Feb 26, 2023 at 20:51

Maybe you deploy it with a wrong way ? can you check your deploy command: "npx hardhat run scripts/deploy.js --network localhost" Have you ignore the network option, add "--network localhost" and then check it.

  • This question was marked as answered. They were using mainnet token address while calling on georli. Best to upvote correct answers once you can. Much love.
    – Maka
    Commented Sep 29, 2023 at 7:33

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.