eth_estimateGas | Optimism

eth_estimateGas RPC Method

The eth_estimateGas method estimates the amount of gas required to execute a transaction. This is useful for understanding how much gas might be consumed by a transaction before actually sending it. The estimation is not always accurate but provides a good approximation.

👍

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Request

To use eth_estimateGas, send a POST request with a JSON RPC call in the body.

Parameters

A single object containing:

  • from (string): (optional) The address the transaction is sent from.
  • to (string): The address the transaction is directed to.
  • gas (string): (optional) The gas limit provided by the sender.
  • gasPrice (string): (optional) The gas price for the transaction.
  • value (string): (optional) The value transferred for the transaction in Wei.
  • data (string): (optional) The data sent along with the transaction.

Response

The method returns the estimated gas required as a hexadecimal number.

  • result (string): The estimated gas required for the transaction.

Use case

The eth_estimateGas method is essential for:

  • Developers to estimate transaction costs before sending them.
  • Wallets and interfaces that calculate transaction fees.
  • Optimizing smart contract interactions by understanding gas requirements.

Try the eth_call RPC method yourself

Language
Click Try It! to start a request and see the response here!