4

I'm getting a:

Error: call revert exception (method="balanceOf(address)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL\_EXCEPTION, version=abi/5.4.0)

Whenever I call a read-only function using Ethers.js. I've been looking everywhere for hours & I can't figure out why it's not working. It lets me send write transactions, but I can't make a simple read-only call.

async function enableEth() {
    if (window.ethereum) {
    const provider = new ethers.providers.Web3Provider(window.ethereum);
    const [account] = await ethereum.request({
        method: 'eth_requestAccounts'
    });
    const signer = provider.getSigner(account);
    const contract = new ethers.Contract(
        contractAddress,
        contractABI,
        signer
    );

    const result = await contract.balanceOf(
        '0x5FbDB2315678afecb367f032d93F642f64180aa3'
    );
    console.log(result);
    }
}
1
  • 3
    Check your contract is deployed and/or to the right location i.e. --network localhost Commented Jul 16, 2021 at 11:09

2 Answers 2

13

The error call revert exception means that:

  • Method reverts during its execution.
  • Method is not present in your contract.
  • Contract not deployed on the network you're connected to (or address put is incorrect).
  • Your network has some temporary outages.

The third one is a frequent dev error, and it's likely also the reason for you.

2
  • 2
    Thank you. It turns out I was deploying to hardhat instead of localhost
    – Adrian D.
    Commented Jul 30, 2021 at 17:24
  • This thing. I restarted my local node, yet forgot to deploy the contract again.
    – mdmb
    Commented Jun 8, 2022 at 9:54
0

I know this is not specific to this issue, but I had exactly the same error, for me it was that my JSON-RPC endpoint was not working. And multiple different ones were not working, so you should try a few.

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.