2

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
  • 1
    Check your contract is deployed and/or to the right location i.e. --network localhost Jul 16 at 11:09
2

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.

1
  • Thank you. It turns out I was deploying to hardhat instead of localhost
    – Adrian D.
    Jul 30 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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