I am writing code in Java and trying to calculated potential gas units, for a function call on my methods. I am trying to do so by using infura as a provider for my web3 Instance, and then created a transaction and using the ethEstimateGas() function, but when I do so The response returned is {"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"execution reverted"}} Which is not really descriptive, I would like to know what am I doing wrong or is there any other way to do so: Code For Reference:

        Type address = new Address({My address here});

        Type value = new Uint(new BigInteger("1000"));

        Function function = new Function(

        String functionEncoderString = FunctionEncoder.encode(function);
        Web3j web3j = Web3j.build(new HttpService("https://ropsten.infura.io/v3/{my_API_KWY}"));

        BigInteger gasPrice = web3j.ethGasPrice().send().getGasPrice();
        Transaction t = new Transaction({fromAddress}, null, gasPrice, null, "0x3DDbe06F45B98a8613C95319Af8CA37BCC5d5c92", null, functionEncoderString);
        EthEstimateGas amount = web3j.ethEstimateGas(t).send();```

1 Answer 1


I have tried your exact same code but on Rinkeby and it worked just fine.

For Ropsten, it is a little bit different since Block gas limit is not fixed and varies a lot.

Similar issues stating this issue:

Gas estimation errored with the following message error upon contract deployment

Gas estimation failed” on Ropsten using MetaMask!

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.