Skip to main content

linea_estimateGas

Compatibility mode

linea_estimateGas is currently only available on Linea Sepolia fully activated and on Mainnet in compatibility mode, which means it returns the same results as eth_gasPrice on mainnet.

linea_estimateGas will be fully activated on Mainnet on September 30. Infrastructure providers must adjust their node configurations to ensure compatibility mode is deactivated and linea_estimateGas functions fully. See our guide.

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, pending, or finalized.

      note

      A finalized block is a block on an L2 blockchain (Linea) that has been confirmed and validated by the L1 blockchain (Ethereum).

Returns​

Hexadecimal 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.

Request​

curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0","method": "linea_estimateGas","params": [{"from": "0x971e727e956690b9957be6d51Ec16E73AcAC83A7","gas":"0x21000"}],"id": 53}'

Response​

{
"jsonrpc": "2.0",
"id": 53,
"result": {
"baseFeePerGas": "0x7",
"gasLimit": "0xcf08",
"priorityFeePerGas": "0x43a82a4"
}
}

Where:

  • baseFeePerGas - Uses the Linea base fee which is set at 7 wei.
  • gasLimit - Uses the standard eth_estimateGas API calculation.
  • priorityFeePerGas - Calculates the fee required to prioritize a transaction by considering factors such as the compressed transaction size, layer 1 verification costs and capacity, gas price ratio between layer 1 and layer 2, the transaction's gas usage, the minimum gas price on layer 2, and a minimum margin (for error) for gas price estimation.
note

The result of the request returns hexadecimal equivalent integers of gas prices in wei. Convert the hexadecimal value into decimals to get the wei value. You can use any hexadecimal to decimal converter such as RapidTables.

Compatibility mode​

When linea_estimateGas is activated on Mainnet on September 30, infrastructure providers and those using their own nodes to submit transactions must adjust their configuration files to disable compatibility mode.

No action is required for Linea Sepolia nodes using the advanced-testnet profile from the linea-besu-package repository, since linea_estimateGas is already activated on Linea Sepolia.

Effects​

linea_estimateGas in compatibility mode returns the same gas price as eth_gasPrice. This means gas price is applied consistently regardless of the relative complexity of the transaction (measured through its calldata size). As a result, transactions can be underpriced and risk getting stuck, or be overpriced and result in the user overpaying in fees.

Benefits of disabling​

With compatibility mode disabled, linea_estimateGas is able to function as designed and return a more accurate gas price, better suited to the transaction. The gas price scales with the amount of calldata a transaction contains. As a result, Linea can more effectively ensure the gas price reflects L1 costs and prover costs, which rise with transaction complexity/calldata size.

How to disable​

For most people running an advanced Linea Besu node —a prerequisite for using linea_estimateGas— compatibility mode will already be disabled in the files you downloaded from the linea-besu-package repository.

note

See our run a node guides for information on running a Linea Besu node with Docker and using the binary distribution.

Binary distribution​

To ensure compatibility is not running, check your .toml configuration file for the following setting, and ensure it is false:

plugin-linea-estimate-gas-compatibility-mode-enabled=false

This configuration may be true if you downloaded the files before September 30.

Docker​

The Docker image accessed via the compose files in the linea-besu-package repository will be updated via image update to ensure compatibility mode is disabled after September 30.