Docs
Docs
Home
Getting Started
Agent Tooling
CLI
Supported Chains
Acala
Aptos
Arbitrum
Arc
Asset Hub
Astar
Avalanche
Base
Berachain
Bifrost
Binance Smart Chain
Bittensor
Blast
Boba Network
Bridge Hub
Celo
Centrifuge
Chiliz
Cronos
Enjin
Ethereum
Etherlink
Flow EVM Gateway
Gnosis
Hydration
Hyperliquid
Immutable
Ink
IoTeX
Kusama
Linea
LISK
Manta Atlantic
Manta Pacific
Mantle
MegaETH
Monad
Movement
Neuroweb
opBNB
Optimism
Plasma
Polkadot
Polygon
Pulsechain
Robinhood
Ronin
Scroll
Sonic
Starknet
Taiko
Tempo
Sui
TRON
Unichain
Viction
World Chain
XDC Network
XX Network
Zetachain
zkSync Era
Zora
Supported ChainsMantleMantle-Specific Methods

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.

Mantle RPC endpoint: endpoint URLs, plans and pricing.

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
cURL request
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
      }'

Implementation Example

Understanding Gas Prices on Mantle

Price Components

  1. L2 Gas Price: Cost per gas unit for execution on Mantle's modular L2
  2. L1 Gas Price: Current Ethereum L1 gas price for data posting via EigenDA
  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 via EigenDA
  • Overhead and scalar factors

Common Use Cases

1. Gas Price Monitoring

JavaScript
// 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

Python
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

JavaScript
// 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 price
  • eth_feeHistory - Historical fee data
  • eth_estimateGas - Estimate transaction gas
  • rollup_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.

On this page

OverviewImplementation ExampleUnderstanding Gas Prices on MantlePrice ComponentsCost CalculationCommon Use Cases1. Gas Price Monitoring2. Cost Optimization3. Historical AnalysisRelated Methods