MEGAETHDOCS
GitHubGet started →
API

Realtime API

Use MegaETH realtime methods to replace polling-heavy flows with subscription-native UX.

Why Realtime

CapabilityStandard RPCRealtime API
Receipt availabilityPoll until minedDirect/near-immediate receipt path
State streamPeriodic pollingPush via eth_subscribe
Latency profileBlock-boundMini-block-bound

Subscription Channels

ChannelDescriptionLatency
miniBlocksMini block objects with tx context<1ms
newHeadsEVM block headers~1s
pendingTransactionsHashes entering sequencer mempool<0.5ms

Keep-Alive Requirement

keepalive.tsts
setInterval(() => {
ws.send(JSON.stringify({
  jsonrpc: "2.0",
  id: 0,
  method: "eth_chainId",
  params: [],
}));
}, 30000);

Try It Live

POSThttps://rpc.megaeth.commainnet
Request Preview
{
  "jsonrpc": "2.0",
  "method": "eth_blockNumber",
  "params": [],
  "id": 1
}
no params · returns current block
POSThttps://rpc.megaeth.commainnet
txHash
Request Preview
{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionReceipt",
  "params": [
    ""
  ],
  "id": 1
}
status decoded + gas + log count
disconnectedwss://rpc.megaeth.com
subscription
--:--:--···Subscribe to see live events

Was this page helpful?

Edit on GitHub