Skip to main content
Estimates the amount of gas required to execute a transaction. The estimate may be higher than the gas actually used at execution time.

Parameters

transactionObject
object
required
The transaction object to estimate gas for.
blockParameter
string
Optional block to estimate against. Defaults to latest.

Returns

result
string
The estimated gas amount as a hexadecimal integer.

Flashblocks Behavior

On a Flashblocks-aware endpoint, use "pending" as the block parameter to query preconfirmed state — data available up to 200ms before the next full block is sealed. Estimates gas against the latest preconfirmed Flashblock state. Use "pending" to get an estimate based on the most current state, reducing the chance of reverts due to stale state.
curl https://mainnet-preconf.base.org \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0xd3CdA913deB6f4967b2Ef66ae97DE114a83bcc01","to":"0x4200000000000000000000000000000000000006","value":"0x2c68af0bb14000"},"pending"],"id":1}'

Example

{
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [
    {
      "from": "0xd3CdA913deB6f4967b2Ef66ae97DE114a83bcc01",
      "to": "0x4200000000000000000000000000000000000006",
      "value": "0x2c68af0bb14000"
    }
  ],
  "id": 1
}

Errors

CodeMessageDescription
-32000execution revertedThe transaction would revert. The error data may contain a revert reason.