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 Chains

MegaETH - The First Real-Time Blockchain

Complete guide to MegaETH integration with Dwellir RPC. Learn how to build on the first real-time blockchain with sub-millisecond latency and 100,000+ TPS.

MegaETH RPC endpoint: endpoint URLs, plans and pricing.

MegaETH iconMegaETH icon

MegaETH RPC

With Dwellir, you get access to our global MegaETH network which always routes your API requests to the nearest available location, ensuring low latency and the fastest speeds.

Get your API key

MegaETH RPC plans and rate limits

  • Free plan: 20 responses per second, up to 100,000 responses a day.
  • Plans: $49/mo, $299/mo, $999/mo with 25M, 150M, and 500M included responses. Overages billed at $5/$3/$2 per million responses respectively.
  • Paid rate limits: 100 to 5,000 responses per second (bursts from 500 to 10,000), no daily limit.
  • Billing: 1 response = 1 API credit on every shared plan, over HTTPS or WebSocket (WSS) where MegaETH supports it.

Details: Pricing · Rate limits · Authentication · Archive nodes

Why Build on MegaETH?

MegaETH is the world's first real-time blockchain, delivering unprecedented performance while maintaining full EVM compatibility:

Real-Time Performance

  • Sub-millisecond latency - Transaction streaming in real-time, not batches
  • 100,000+ TPS sustained - Orders of magnitude faster than traditional L2s
  • 0.01 second block time - Near-instant transaction finality

Battle-Tested Security

  • Ethereum-secured - Inherits Ethereum's L1 security guarantees
  • Backed by Vitalik Buterin - Co-founded by Ethereum's creator
  • Full EVM compatibility - All existing Ethereum tools work seamlessly

Ideal for High-Frequency Applications

  • High-frequency DeFi - Enable latency-sensitive trading strategies
  • Gaming & Real-Time Apps - Build truly responsive onchain experiences
  • Instant UX - Deliver web2-like responsiveness with web3 security

Quick Start with MegaETH

Connect to MegaETH in seconds with Dwellir's optimized endpoints:

MegaETH iconMegaETH iconMegaETH RPC Endpoints
HTTPS
curl -sS -X POST https://api-megaeth-mainnet.n.dwellir.com/<your-api-key> \  -H 'Content-Type: application/json' \  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Installation & Setup

JavaScript
import { JsonRpcProvider } from 'ethers';

// Connect to MegaETH mainnet
const provider = new JsonRpcProvider(
  'https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// Get the latest block
const block = await provider.getBlock('latest');
console.log('Latest block:', block.number);

// Query account balance
const balance = await provider.getBalance('0x...');
console.log('Balance:', balance.toString());

Network Information

ParameterValueDetails
Chain ID4326Mainnet
Block Time0.01 secondsReal-time
Gas TokenETHNative token
RPC StandardEthereumJSON-RPC 2.0

API Reference

MegaETH supports a subset of the Ethereum JSON-RPC API specification optimized for real-time performance.

Method Availability

MegaETH implements core Ethereum JSON-RPC methods with some modifications for performance:

  • Debug methods are not available (debug_, trace_)
  • Full block queries are disabled for eth_getBlockByHash and eth_getBlockByNumber
  • Gas limits apply to certain methods (10,000,000 gas for eth_call, eth_createAccessList, eth_estimateGas)
  • Block range limits apply to eth_feeHistory (maximum 10,000 blocks)

Common Integration Patterns

Real-Time Transaction Streaming

Leverage MegaETH's real-time capabilities for instant transaction updates:

JavaScript
// Subscribe to pending transactions via WebSocket
const wsProvider = new ethers.WebSocketProvider(
  'wss://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// Watch for new blocks in real-time (every 0.01s)
wsProvider.on('block', async (blockNumber) => {
  console.log('New block:', blockNumber);
  const block = await wsProvider.getBlock(blockNumber);
  console.log('Block timestamp:', block.timestamp);
});

// Watch for specific transaction confirmations
async function streamTransaction(txHash) {
  const receipt = await wsProvider.waitForTransaction(txHash, 1);
  console.log('Transaction confirmed in:', receipt.blockNumber);
  return receipt;
}

Gas Optimization

Optimize gas costs on MegaETH:

JavaScript
// Get current fee data
const feeData = await provider.getFeeData();

// Estimate gas for transaction
const gasEstimate = await provider.estimateGas(tx);

// Calculate total cost
const totalCost = gasEstimate * feeData.gasPrice;
console.log('Estimated cost:', totalCost);

Event Filtering

Efficiently query contract events with MegaETH's fast block times:

JavaScript
// Query recent events (fast with 0.01s blocks)
async function getRecentEvents(contract, eventName, blocksBack = 1000) {
  const latestBlock = await provider.getBlockNumber();
  const fromBlock = latestBlock - blocksBack;

  const filter = contract.filters[eventName]();
  const events = await contract.queryFilter(filter, fromBlock, latestBlock);

  return events;
}

Performance Best Practices

1. WebSocket for Real-Time Updates

Use WebSockets to leverage MegaETH's real-time streaming capabilities:

JavaScript
const wsProvider = new ethers.WebSocketProvider(
  'wss://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// Subscribe to new blocks (every 0.01s)
wsProvider.on('block', (blockNumber) => {
  console.log('New block:', blockNumber);
});

// Handle reconnection
wsProvider.on('error', () => {
  console.log('WebSocket error, reconnecting...');
});

2. Connection Pooling

Reuse provider instances to minimize connection overhead:

JavaScript
// Singleton pattern for provider
class MegaETHProvider {
  static instance = null;

  static getInstance() {
    if (!this.instance) {
      this.instance = new JsonRpcProvider(
        'https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
      );
    }
    return this.instance;
  }
}

3. Respect Gas Limits

MegaETH enforces a 10,000,000 gas limit for certain methods:

JavaScript
// When calling contracts, stay within gas limits
const result = await provider.call({
  to: contractAddress,
  data: calldata,
  // MegaETH enforces 10M gas limit
  gasLimit: 10000000
});

Troubleshooting Common Issues

Error: "Gas limit exceeded"

MegaETH limits certain methods to 10,000,000 gas:

JavaScript
// Split large queries into smaller batches
async function batchCall(contract, method, args, batchSize = 100) {
  const results = [];
  for (let i = 0; i < args.length; i += batchSize) {
    const batch = args.slice(i, i + batchSize);
    const result = await contract[method](batch);
    results.push(...result);
  }
  return results;
}

Error: "Full block queries disabled"

Use the standard block query format without transaction details:

JavaScript
// Don't request full transaction objects
const block = await provider.getBlock(blockNumber, false);

// If you need transaction details, fetch them separately
for (const txHash of block.transactions) {
  const tx = await provider.getTransaction(txHash);
  console.log('Transaction:', tx);
}

Error: "Block range too large"

For eth_feeHistory, limit your range to 10,000 blocks:

JavaScript
// Query fee history in 10k block batches
async function getFeeHistory(blockCount, newestBlock) {
  const maxRange = 10000;
  if (blockCount > maxRange) {
    // Split into multiple requests
    const batches = Math.ceil(blockCount / maxRange);
    const results = [];
    for (let i = 0; i < batches; i++) {
      const batchSize = Math.min(maxRange, blockCount - (i * maxRange));
      const batchResult = await provider.send('eth_feeHistory', [
        batchSize,
        newestBlock - (i * maxRange),
        []
      ]);
      results.push(batchResult);
    }
    return results;
  }
  return provider.send('eth_feeHistory', [blockCount, newestBlock, []]);
}

Smoke Tests

Test Connection with cURL

Bash
# Test MegaETH mainnet
curl -X POST https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Test with Ethers.js

JavaScript
// Test mainnet connection
const mainnetProvider = new JsonRpcProvider(
  'https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
);

const blockNumber = await mainnetProvider.getBlockNumber();
const network = await mainnetProvider.getNetwork();

console.log('Block number:', blockNumber);
console.log('Chain ID:', network.chainId); // Should be 4326n

Test with Web3.py

Python
from web3 import Web3

# Test connection
web3 = Web3(Web3.HTTPProvider(
  'https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
))

print('Connected:', web3.is_connected())
print('Chain ID:', web3.eth.chain_id)  # Should be 4326
print('Block number:', web3.eth.block_number)

Migration Guide

From Other EVM Chains

MegaETH is fully EVM-compatible, making migration straightforward:

JavaScript
// Before (Ethereum/other L2)
const provider = new JsonRpcProvider('https://eth-rpc.example.com');

// After (MegaETH)
const provider = new JsonRpcProvider(
  'https://api-megaeth-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// Smart contracts work identically
// Same tooling and libraries
// Note: Different chain ID (4326)
// Note: Some debug methods unavailable
// Note: Gas limits apply (10M for call/estimateGas)
// Note: Full block queries disabled

Resources & Tools

Official Resources

  • MegaETH Documentation
  • MegaETH Website
  • MegaETH Block Explorer

Developer Tools

  • Hardhat - Full EVM compatibility
  • Foundry - Fast Solidity testing
  • Truffle - Development framework

Need Help?

  • Email: support@dwellir.com
  • Docs: You're here!
  • Dashboard: dashboard.dwellir.com

Start building on MegaETH with Dwellir's enterprise-grade RPC infrastructure. Get your API key

rollup_getInfo - Get modular L2 rollup config...

Get modular L2 rollup configuration on Mantle Network. Essential for understanding the optimistic rollup parameters and settings.

eth_blockNumber

Get the current block height on MegaETH. Essential for syncing dApps, monitoring transaction confirmations, and blockchain state tracking.

On this page

MegaETH RPC plans and rate limitsWhy Build on MegaETH?Real-Time PerformanceBattle-Tested SecurityIdeal for High-Frequency ApplicationsQuick Start with MegaETHInstallation & SetupNetwork InformationAPI ReferenceCommon Integration PatternsReal-Time Transaction StreamingGas OptimizationEvent FilteringPerformance Best Practices1. WebSocket for Real-Time Updates2. Connection Pooling3. Respect Gas LimitsTroubleshooting Common IssuesError: "Gas limit exceeded"Error: "Full block queries disabled"Error: "Block range too large"Smoke TestsTest Connection with cURLTest with Ethers.jsTest with Web3.pyMigration GuideFrom Other EVM ChainsResources & ToolsOfficial ResourcesDeveloper ToolsNeed Help?