⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_estimateL1Fee

Estimate L1 data posting fee on the Linea zkEVM network. This method helps calculate the additional cost of posting transaction data to Ethereum L1 as part of Linea's zkEVM rollup architecture.

Overview

Linea zkEVM is a Layer 2 rollup that periodically submits batched transaction data and proofs to Ethereum L1. While most transaction execution happens on L2 with low gas costs, there's an additional fee component for the L1 data availability costs.

Parameters

ParameterTypeRequiredDescription
transactionObjectYesTransaction object to estimate L1 fee for

Transaction Object

FieldTypeRequiredDescription
fromAddressNoSender address
toAddressNoRecipient address
gasQuantityNoGas limit
gasPriceQuantityNoGas price in wei
valueQuantityNoValue to transfer in wei
dataDataNoTransaction data

Returns

TypeDescription
QUANTITYEstimated L1 fee in wei

Implementation Example

curl -X POST https://api-linea-mainnet-archive.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_estimateL1Fee",
"params": [
{
"from": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5",
"to": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"gas": "0x5208",
"gasPrice": "0x3b9aca00",
"value": "0x1bc16d674ec80000",
"data": "0x"
}
],
"id": 1
}'

Response Example

{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1c6bf526340"
}

Understanding L1 Fees on Linea

Fee Components

  1. L2 Execution Fee: Standard gas cost for transaction execution on Linea
  2. L1 Data Fee: Cost of posting transaction data to Ethereum L1 for data availability

Data Size Impact

L1 fees scale with transaction data size:

  • Simple transfers: Minimal L1 fee
  • Contract interactions: Moderate L1 fee based on calldata
  • Large data payloads: Significant L1 fee component

Cost Optimization Strategies

  1. Minimize Data: Reduce unnecessary data in transactions
  2. Batch Operations: Combine multiple operations into single transaction
  3. Use Events: Emit events instead of storing large data on-chain
  4. Optimize Encoding: Use efficient data encoding methods

Common Use Cases

1. Transaction Cost Planning

// Plan transaction costs before execution
async function planTransactionCosts(transactions) {
const feeEstimator = new LineaFeeEstimator(rpcUrl);
const plans = [];

for (const tx of transactions) {
const breakdown = await feeEstimator.getFullFeeBreakdown(tx);
plans.push({
transaction: tx,
estimatedCost: breakdown.totalEstimatedCost,
l1FeeRatio: breakdown.breakdown.l1FeePercentage,
recommendation: breakdown.breakdown.l1FeePercentage > 70 ?
'Consider batching or data optimization' : 'Cost efficient'
});
}

return plans.sort((a, b) => a.estimatedCost - b.estimatedCost);
}

2. Data Optimization Analysis

def optimize_contract_call_data(base_transaction, data_variations):
"""Find most cost-effective data encoding"""

fee_estimator = LineaFeeEstimator(rpc_url)
results = []

for name, data in data_variations.items():
tx = {**base_transaction, 'data': data}
breakdown = fee_estimator.get_full_fee_breakdown(tx)

results.append({
'encoding': name,
'data_size': len(data) // 2 - 1, # Hex bytes
'total_cost': breakdown['total_estimated_cost'],
'l1_fee': breakdown['l1_fee'],
'efficiency': breakdown['l1_fee'] / (len(data) // 2 - 1)
})

# Sort by total cost
return sorted(results, key=lambda x: x['total_cost'])

Need help? Contact our support team or check the Linea documentation.