Estimate transaction costs
How gas works on Linea​
Linea supports the Ethereum EIP-1559 gas price model:
total fee = units of gas used * (base fee + priority fee)
Linea fundamentally works exactly the same as Ethereum. The one difference is that the base fee is constant at 7 wei. Blocks created by Linea use up to 24 million gas (less than 50% of the maximum Linea block size of 61 million gas), and the fee decreases by 12.5% per block, effectively keeping it at a stable 7 wei.
The gas cost to submit your transaction and include it on Ethereum involves the following fee components:
- Layer 2 cost: The execution fee; the cost of including your transaction on the Linea sequencer, and calculated using a similar formula to Ethereum (as described above).
- Layer 1 cost: The cost of publishing your L2 transaction on Ethereum, which varies based on the blob fee market.
These two resource costs are abstracted by the rollup and covered by the recommended L2 gas price and gas used.
Learn more about gas on Linea.
linea_estimateGas
is the recommended method for estimating gas on Linea. See our
reference page for more information.
Linea also supports eth_estimateGas
,
eth_gasPrice
, and
eth_feeHistory
.
You can use eth_gasPrice
or eth_feeHistory
to get the gas price, in wei, and you can use
eth_estimateGas
to find out how many units of gas a specific transaction will need.
linea_estimateGas
​
linea_estimateGas
is the recommended method for estimating gas on Linea. It returns gasLimit
,
baseFeePerGas
, and priorityFeePerGas
, and therefore provides a more precise gas estimate than
the alternatives.
It can also help prevent transactions from being rejected due to exceeding module limits.
Example​
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"
}
}
See the reference page for full usage.