web3j-evm icon indicating copy to clipboard operation
web3j-evm copied to clipboard

ethEstimateGas causes IllegalArgumentException due to negative gas returned

Open magmahindenburg opened this issue 9 months ago • 0 comments

Bug_title

When trying to estimate gas using the EmbeddedWeb3jService, the gas value calculated is negative, which causes longToHex() to throw an IllegalArgumentException.

EthEstimateGas gasEstimated = web3j.ethEstimateGas(transaction).send();

Steps To Reproduce

Created a transaction using Transaction.createFunctionCallTransaction or Transaction.createContractTransaction.

Try to estimate gas using web3j.ethEstimateGas(transaction).send();

Expected behavior

A more helpful error message

Actual behavior

IllegalArgumentException is not helpful at all, and it doesn't even tell me the negative value.

Environment

  • Web3j version: 4.12.2
  • Java or Android version: 21 and 17
  • Operating System: Ubuntu Linux 64-bit

magmahindenburg avatar Feb 28 '25 12:02 magmahindenburg