Skip to main content

MegaETH - Build on the First Real-Time Blockchain

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

Get your API key →

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:

🔗 RPC Endpoints

MainnetChain ID: 1
Mainnet
HTTPS
https://api-megaeth-mainnet.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>
✓ Archive Node✓ WebSocket

Quick Connect:

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

Installation & Setup#

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#

Chain ID

4326

Mainnet

Block Time

0.01 seconds

Real-time

Gas Token

ETH

Native token

RPC Standard

Ethereum

JSON-RPC 2.0

JSON-RPC 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)

Available JSON-RPC Methods

Reading Blockchain Data

Query blocks, transactions, and account states
+

Sending Transactions

Submit and manage transactions
+

Smart Contract Interaction

Call and interact with smart contracts
+

Node & Network Info

Query node status and network information
+

Ready to integrate Base into your dApp?

Get your API key →

Common Integration Patterns#

⚡ Real-Time Transaction Streaming#

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

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

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

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

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:

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

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

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

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

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

# 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#

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

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:

// 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
// ⚠️ Different chain ID (4326)
// ⚠️ Some debug methods unavailable
// ⚠️ Gas limits apply (10M for call/estimateGas)
// ⚠️ Full block queries disabled

Resources & Tools#

Official Resources#

Developer Tools#

Need Help?#


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