Skip to content

eth_estimateGas

Returns an estimate of how much gas a transaction would require. The reported value may exceed what the transaction actually consumes when executed.

The transaction object to estimate gas for.

FieldTypeDescription
fromstringAddress the transaction is sent from. Optional.
tostringAddress the transaction is sent to. Optional for contract deployments.
gasstringGas limit. Optional; a high default is used if omitted.
gasPricestringGas price in wei for legacy transactions. Optional.
maxFeePerGasstringEIP-1559 maximum total fee per gas. Optional.
maxPriorityFeePerGasstringEIP-1559 maximum priority fee per gas. Optional.
valuestringValue to transfer in wei. Optional.
datastringABI-encoded call data. Optional.

Block to estimate against. Defaults to "latest". Pass "pending" on a Flashblocks endpoint to estimate against pre-confirmed state.

FieldTypeDescription
resultstringThe estimated gas amount as a hexadecimal integer.
CodeMessageDescription
-32000execution revertedThe transaction would revert. The error data field may contain a revert reason.
Terminal window
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
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x5208"
}