API
Realtime API
Use MegaETH realtime methods to replace polling-heavy flows with subscription-native UX.
Why Realtime
| Capability | Standard RPC | Realtime API |
|---|---|---|
| Receipt availability | Poll until mined | Direct/near-immediate receipt path |
| State stream | Periodic polling | Push via eth_subscribe |
| Latency profile | Block-bound | Mini-block-bound |
Subscription Channels
| Channel | Description | Latency |
|---|---|---|
| miniBlocks | Mini block objects with tx context | <1ms |
| newHeads | EVM block headers | ~1s |
| pendingTransactions | Hashes 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