Skip to main content
Returns an estimate of how much gas is required to execute a transaction. The estimate may be larger than the gas actually used at execution time.
Flashblocks: Query https://mainnet-preconf.base.org with "pending" to estimate gas against the current pre-confirmed state, useful when a transaction depends on a prior pre-confirmed one.

Parameters

transaction
object
required
The transaction object to estimate gas for.
block
string
Block to estimate against. Optional; defaults to "latest". Use "pending" on a Flashblocks endpoint to estimate against pre-confirmed state.

Returns

result
string
The estimated gas amount as a hexadecimal integer.

Error Codes

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

Example

curl https://mainnet.base.org \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_estimateGas",
    "params": [{
      "from": "0xd3CdA913deB6f4967b2Ef66ae97DE114a83bcc01",
      "to": "0x4200000000000000000000000000000000000006",
      "value": "0x2c68af0bb14000"
    }],
    "id": 1
  }'