Skip to main content

linea_estimateGas

info

linea_estimateGas is currently not available on the Linea Sepolia testnet, but will be activated soon. Mainnet activation is scheduled for July 30, 2024.

It will only be fully compatible with endpoints using the Besu client — if it is unavailable, try updating Besu. If you prefer to use Geth, linea_estimateGas is only available if you redirect your request through an Infura endpoint.

We recommend using linea_estimateGas rather than alternatives, such as eth_gasPrice. linea_estimateGas returns estimates with greater accuracy, minimizing the risk of transactions being priced incorrectly and failing as a result.

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete and be published on Ethereum. The transaction will not be added to the blockchain.

For more information about estimating gas, and how this API formulates the transaction costs, see the Estimate transaction costs topic.

The priorityFeePerGas returned by this method includes the cost of submitting the transaction to Ethereum, which can vary based on the size of the calldata.

note

linea_estimateGas uses the same inputs as the standard eth_estimateGas, but returns the recommended gas limit, the base fee per gas, and the priority fee per gas. We recommend using linea_estimateGas for more accurate results.

Parameters​

  • TRANSACTION CALL OBJECT [required]
    • from: [optional] 20 bytes - The address the transaction is sent from.
    • to: [optional] 20 bytes - The address the transaction is directed to.
    • gas: [optional] Hexadecimal value of the gas provided for the transaction execution. linea_estimateGas consumes zero gas, but this parameter may be needed by some executions.
    • gasPrice: [optional] Hexadecimal value of the gas price used for each paid gas.
    • maxPriorityFeePerGas: [optional] Maximum fee, in wei, the sender is willing to pay per gas above the base fee.
    • maxFeePerGas: [optional] Maximum total fee (base fee + priority fee), in wei, the sender is willing to pay per gas.
    • 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 number: [optional] A string representing a block number, or one of the string tags latest, earliest, or pending. See the default block parameter.

Returns​

Hexidecimal values representing the recommended gas limit, the base fee per gas, and the priority fee per gas.

Example​

tip

You can also call the API using Infura's supported Linea endpoints.

curl https://rpc.sepolia.linea.build \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"linea_estimateGas","params":[{"from":"0x42c27251C710864Cf76f1b9918Ace3E585e6E21b","gasPrice":"0x100000000","gas":"0x21000"}],"id":53}'