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

rollup_gasPrices

Get zkEVM gas price oracle data on the Linea network. This method provides comprehensive gas pricing information for the zkEVM rollup, including both L2 execution costs and L1 data availability fees.

Overview

Linea zkEVM uses a sophisticated gas pricing mechanism that accounts for:

  • L2 Execution Costs: Gas costs for transaction execution on the zkEVM
  • L1 Data Availability: Costs for posting transaction data to Ethereum L1
  • Proof Generation: Costs associated with generating zero-knowledge proofs

Parameters

This method typically takes no parameters, but implementation may vary. Please refer to the official Linea documentation for the most current parameter specifications.

Returns

Gas price oracle data object containing current pricing information for the zkEVM rollup.

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": "rollup_gasPrices",
"params": [],
"id": 1
}'

Response Example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"l1GasPrice": "0x12a05f200",
"l2GasPrice": "0x3b9aca00",
"overhead": "0xbc0",
"scalar": "0x684000",
"decimals": "0x6"
}
}

Understanding Gas Prices on Linea

Price Components

  1. L2 Gas Price: Cost per gas unit for execution on Linea zkEVM
  2. L1 Gas Price: Current Ethereum L1 gas price for data posting
  3. Overhead: Fixed overhead cost for L1 data posting
  4. Scalar: Scaling factor for L1 cost calculation
  5. Decimals: Decimal precision for calculations

Cost Calculation

Total transaction cost = (L2 Gas × L2 Gas Price) + L1 Data Fee

Where L1 Data Fee considers:

  • Transaction data size
  • Current L1 gas price
  • Overhead and scalar factors

Common Use Cases

1. Gas Price Monitoring

// Monitor gas prices for optimal transaction timing
async function monitorForOptimalGas(targetGwei, callback) {
const monitor = new LineaGasPriceMonitor(rpcUrl);

const checkPrice = async () => {
const pricing = await monitor.getCurrentPricing();
const currentGwei = pricing.formattedPrices.standardGasPrice.gwei;

if (currentGwei <= targetGwei) {
callback({
optimal: true,
currentPrice: currentGwei,
targetPrice: targetGwei,
message: 'Target price reached!'
});
return true;
}

return false;
};

// Check every 30 seconds
const interval = setInterval(async () => {
const optimal = await checkPrice();
if (optimal) {
clearInterval(interval);
}
}, 30000);

// Initial check
await checkPrice();
}

2. Cost Optimization

def optimize_transaction_timing(analyzer, transactions, budget_gwei):
"""Find optimal timing for multiple transactions within budget"""

optimization_plan = []

for i, tx in enumerate(transactions):
# Estimate transaction cost at different gas prices
cost_estimates = []

for gas_price_gwei in [10, 15, 20, 25, 30]:
gas_price_wei = int(gas_price_gwei * 1e9)
estimated_cost = tx['gas_estimate'] * gas_price_wei

cost_estimates.append({
'gas_price_gwei': gas_price_gwei,
'estimated_cost_wei': estimated_cost,
'within_budget': gas_price_gwei <= budget_gwei
})

# Find optimal price point
optimal = next(
(est for est in cost_estimates if est['within_budget']),
cost_estimates[0]
)

optimization_plan.append({
'transaction_id': i,
'optimal_gas_price': optimal['gas_price_gwei'],
'estimated_cost': optimal['estimated_cost_wei'],
'cost_estimates': cost_estimates
})

return optimization_plan

3. Historical Analysis

// Analyze historical gas price patterns
async function analyzeGasPricePatterns(monitor, days = 7) {
const patterns = {
hourlyAverages: {},
dailyTrends: [],
optimalTimes: []
};

// This would require storing historical data
// For demonstration, showing structure

// Simulate hourly analysis
for (let hour = 0; hour < 24; hour++) {
patterns.hourlyAverages[hour] = {
averageGwei: 0, // Would be calculated from historical data
transactionVolume: 0,
volatility: 0
};
}

// Identify optimal transaction times
const sortedHours = Object.entries(patterns.hourlyAverages)
.sort((a, b) => a[1].averageGwei - b[1].averageGwei);

patterns.optimalTimes = sortedHours.slice(0, 6).map(([hour, data]) => ({
hour: parseInt(hour),
averageGwei: data.averageGwei,
timeRange: `${hour}:00-${hour}:59 UTC`
}));

return patterns;
}

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