rollup_gasPrices - Get modular L2 gas price o...
Get modular L2 gas price oracle data on Mantle Network. Essential for understanding gas pricing on the optimistic rollup.
Get modular L2 gas price oracle data on the Mantle network. This method provides comprehensive gas pricing information for the optimistic rollup, including both L2 execution costs and L1 data availability fees.
Overview
Mantle's modular L2 architecture uses a sophisticated gas pricing mechanism that accounts for:
- L2 Execution Costs: Gas costs for transaction execution on the optimistic rollup
- L1 Data Availability: Costs for posting transaction data to Ethereum L1 via EigenDA
- Sequencer Operations: Costs associated with transaction ordering and batch processing
Request Parameters
This method accepts no parameters.
Response Body
Gas price oracle data object containing current pricing information for the modular L2 rollup.
Implementation Example
curl -X POST https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY \\
-H "Content-Type: application/json" \\
-d '{
"jsonrpc": "2.0",
"method": "rollup_gasPrices",
"params": [],
"id": 1
}'Understanding Gas Prices on Mantle
Price Components
- L2 Gas Price: Cost per gas unit for execution on Mantle's modular L2
- L1 Gas Price: Current Ethereum L1 gas price for data posting via EigenDA
- Overhead: Fixed overhead cost for L1 data posting
- Scalar: Scaling factor for L1 cost calculation
- 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 via EigenDA
- 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 MantleGasPriceMonitor(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_plan3. 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;
}Related Methods
eth_gasPrice- Get current L2 gas priceeth_feeHistory- Historical fee dataeth_estimateGas- Estimate transaction gasrollup_getInfo- Get rollup configuration
Need help? Contact our support team or check the Mantle documentation.
eth_estimateL1Fee - Estimate L1 data posting fee
Estimate L1 data posting fee on Mantle Network. Essential for understanding transaction costs on the modular L2 rollup.
rollup_getInfo - Get modular L2 rollup config...
Get modular L2 rollup configuration on Mantle Network. Essential for understanding the optimistic rollup parameters and settings.