eth_estimateGas

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.

Parameters

  • Object - The transaction call object
    • from: DATA, 20 Bytes - (optional) The address the transaction is sent from.
    • to: DATA, 20 Bytes - The address the transaction is directed to.
    • gas: QUANTITY - (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.
    • gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas
    • value: QUANTITY - (optional) Integer of the value sent with this transaction
    • data: DATA - (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI in the Solidity documentation.
  • QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
curl --request POST \
     --url https://ethereum-mainnet-rpc.allthatnode.com/8U3JLUhzIDg3GShvy9hkCCSYkLGc11kj \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [
    {
    "from": "0x17c0f36f80A6ed37F09650C52f24C76a396eDf18",
    "to": "0x7C4CBc1C8CB34e3AE021E66EfDa4C69D759fF499",
    "data": "0x608060806080608155"
    },
    "latest"
  ]
}
'

Returns

  • QUANTITY - the amount of gas used.
{"jsonrpc":"2.0","id":1,"result":"0x5298"}

Try yourself

Language
Click Try It! to start a request and see the response here!