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.
Since Denim, Base produces a canonical block every 200ms and Flashblocks are retired. The "pending" tag is still accepted, but it no longer returns Flashblocks preconfirmation state. Use "latest" for the newest canonical state. See Migrate From Flashblocks.
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".
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.