Eth_call returns execution reverted

When I try to call balanceOf on eth_call, returns execution reverted.

I don’t understand because balanceOf is a view function.

In documentation, there are a method limitation to prevent abusive of the API, but I don’t know how to calculate the correct gas.

My JSON request (Rinkeby):

{ "jsonrpc":"2.0", "method":"eth_call", "id":1, "params: [ {"from":"0xD8F7E3adb3C93739b2600E7180D2DFaeCFa3b4E9", "to":"0x6e724351f7d94E47B2c05d69f3bCF97094482d6f", "gas":"0x5f5e100", "gasprice":"0x3b9aca00", "value":"0x0", "data":"0x70a082310000000000000000D8F7E3adb3C93739b2600E7180D2DFaeCFa3b4E9"}, "latest" ] }

Hey @carlos, and welcome to the Infura community!

When you get the execution reverted error, do you get a message after that? Typically there will be some reason just after the execution reverted, as in the screenshot attached.

1 Like

@Leiya_Kenney, thank you for your answer.

No, I do not get any message after execution reverted error.

My new script, same error:

export const tokenByIndex = (address: any, index: any) => {
    return new Promise((resolve, reject) => {

        let data = Prexis.methods.tokenByIndex(index).encodeABI();
    
        web3.call({
                from: OWNER_ADDRESS,
                to: address,
                data: data,
            })
            .then((receipt: any) => {
                let res = web3.abi.decodeParameters(["uint256"], receipt);
                resolve(res);
            })
            .catch((err: any) => {
                reject(err);
        });
      }); 
} 

Is it necessary to send a transaction? It’s an ERC-721 contract.

@carlos you could try to activate the handleRevert in web3js (web3.eth.handleRevert = true) https://web3js.readthedocs.io/en/v1.2.8/web3-eth.html#handlerevert

Hopefully it would return the revert reason.

Thank you for you reply, Traian. But I still get the error without reason message.

Is it necessary gas to calling baseURI() method on a standard ERC-721 contract?

const web3 = new Web3(new Web3.providers.HttpProvider(NETWORK_URL))

const OWNER_ADDRESS = '0xD8F7E3adb3C93739b2600E7180D2DFaeCFa3b4E9'

const Prexis = new web3.Contract(prexis_contract.abi, prexis_contract.address, {
  from: OWNER_ADDRESS,
})

web3.handleRevert = true;

export const baseURI = (address: any) => {
    return new Promise((resolve, reject) => {

        let data = Prexis.methods.baseURI().encodeABI();
    
        web3.call({
                from: OWNER_ADDRESS,
                to: address,
                data: data,
            })
            .then((receipt: any) => {
                let res = web3.abi.decodeParameters(["string"], receipt);
                resolve(res);
            })
            .catch((err: any) => {
                reject(err);
        });
    }); 
}
1 Like

+1, getting this too

Welcome to the Infura community.
Can you help to share the snippet of the code you’re using?

I’m also getting the same error without a reason

The error returns without a reason

{jsonrpc: "2.0", id: 44, error: {code: -32000, message: "execution reverted"}}

error: {code: -32000, message: “execution reverted”}
code: -32000
message: “execution reverted”
id: 44
jsonrpc: “2.0”