API Reference

eth_estimateGas

Executes a call to a read-only function of a smart contract immediately without creating a transaction on the blockchain.

Limits

🚧

Limits:

To prevent API abuse, the gas parameter in eth_estimateGas and eth_call is capped at 10x (1000%) the current block gas limit. You can recreate this behavior in your local test environment (Ganache, Besu, Geth or other client) via the rpc.gascap command-line option.

Request Parameters

  • TRANSACTION CALL OBJECT [required]
    • from: [optional] 20 Bytes - The address the transaction is sent from.
    • to: 20 Bytes - The address the transaction is directed to.
    • gas: [optional] hexadecimal value of the gas provided for the transaction execution. eth_estimateGas consumes zero gas, but this parameter may be needed by some executions.
    • gasPrice: [optional] hexadecimal value of the gasPrice used for each paid gas.
    • maxPriorityFeePerGas: [optional] Maximum fee, in Wei, the sender is willing to pay per gas above the base fee. See EIP-1559 transactions.
    • maxFeePerGas: [optional] Maximum total fee (base fee + priority fee), in Wei, the sender is willing to pay per gas. See EIP-1559 transactions.
    • value: [optional] hexadecimal value of the value sent with this transaction.
    • data: [optional] Hash of the method signature and encoded parameters. See the Ethereum contract ABI specification.
  • BLOCK PARAMETER [required] - a hexadecimal block number, or the string "latest", "earliest" or "pending". See the default block parameter.

📘

Note:

If no gas limit is specified, geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.

Response

Returns the estimated amount of gas to complete the execution of a transaction.

Result Fields

  • GAS USED - the estimated amount of gas used.

Examples

Example Responses
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x1e081"
}
Language
Click Try It! to start a request and see the response here!