Estimates the gas required for a transaction. Use pending on a Flashblocks endpoint to estimate against pre-confirmed state.
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
object
required
The transaction object to estimate gas for.
Show Transaction fields
string
Address the transaction is sent from. Optional.
string
Address the transaction is sent to. Optional for contract deployments.
string
Gas limit. Optional; a high default is used if omitted.
string
Gas price in wei for legacy transactions. Optional.
string
EIP-1559 maximum total fee per gas. Optional.
string
EIP-1559 maximum priority fee per gas. Optional.
string
Value to transfer in wei. Optional.
string
ABI-encoded call data. Optional.
string
Block to estimate against. Optional; defaults to "latest". Use "pending" on a Flashblocks endpoint to estimate against pre-confirmed state.
Returns
string
The estimated gas amount as a hexadecimal integer.
Error Codes
Code
Message
Description
-32000
execution reverted
The transaction would revert. The error data field may contain a revert reason.