{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [{
    "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
    "gas": "0x76c0",
    "gasPrice": "0x9184e72a000",
    "value": "0x9184e72a",
    "data": "0xd46e8dd67c5d32be8d24c6b0afe7c5c3f4e9c3b2"
  }]
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x5208"
}

Defined in the Ethereum JSON-RPC Specification

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.

Parameters

transaction
object
required

The transaction call object.

Returns

result
string

The amount of gas used as a hexadecimal string.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [{
    "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
    "gas": "0x76c0",
    "gasPrice": "0x9184e72a000",
    "value": "0x9184e72a",
    "data": "0xd46e8dd67c5d32be8d24c6b0afe7c5c3f4e9c3b2"
  }]
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x5208"
}

Error Handling

CodeMessageDescription
-32602Invalid paramsInvalid transaction parameters
-32000Execution revertedTransaction would revert during execution
4100Requested method not supportedThe method is not supported by the wallet

The estimate may not be accurate if the blockchain state changes between the estimation and actual execution.