The official debugging tool for MegaETH transactions.
git clone https://github.com/megaeth-labs/mega-evm
cd mega-evm/bin/mega-evme
cargo build --release# Basic replay
mega-evme replay <txhash> --rpc https://mainnet.megaeth.com/rpc
# With execution trace
mega-evme replay <txhash> --trace --trace.output trace.json --rpc <endpoint>
# With call tracer
mega-evme replay <txhash> --trace --tracer call --trace.output calls.jsonDocs: https://github.com/megaeth-labs/mega-evm/tree/main/bin/mega-evme
# 1. Get debug trace
cast run <txhash> --rpc-url <vip-endpoint> > trace.json
# 2. Profile opcodes
python scripts/trace_opcode_gas.py trace.jsonScript: https://github.com/megaeth-labs/mega-evm/blob/main/scripts/trace_opcode_gas.py
op count total avg min max
SSTORE 29 85400 2944.8 100 22100
SLOAD 473 121300 256.4 100 2100
LOG2 25 598601 23944.0 14257 25521
KECCAK256 288 12108 42.0 36 60
Local gas estimation uses standard EVM costs. MegaEVM differs.
Fix:
# Foundry: skip local simulation
forge script Deploy.s.sol --gas-limit 5000000 --skip-simulation
# Or use higher hardcoded limitWith eth_sendRawTransactionSync, this can mean:
- Tx already executed (check receipt)
- Race condition with pending tx
Debug:
# Check current nonce
cast nonce <address> --rpc-url <endpoint> --block pendingPublic endpoint only keeps ~15 days of state.
Solutions:
- Use Alchemy/QuickNode for historical calls
- Run archive node
- Use VIP endpoint with longer retention
Connection drops after idle period.
Fix: Send keepalive every 30s:
setInterval(() => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'eth_chainId',
params: [],
id: Date.now()
}));
}, 30000);Error after using block.timestamp + heavy computation.
Cause: 20M total compute gas cap (retroactive) when any block metadata opcode is accessed. The cap applies to the entire transaction's compute gas, not just gas used after the opcode.
Fix: Keep total compute gas under 20M in transactions that touch block metadata. For heavy computation + time-awareness, split into separate transactions or use the timestamp oracle.
# Estimate gas
cast estimate --from <addr> --to <addr> --value 0.001ether \
--rpc-url https://mainnet.megaeth.com/rpc
# Call at specific block
cast call --block <number> <contract> "method(args)" \
--rpc-url https://mainnet.megaeth.com/rpc
# Get transaction details
cast tx <txhash> --rpc-url https://mainnet.megaeth.com/rpc
# Decode calldata
cast 4byte-decode <calldata>For debugging frontend RPC patterns:
# Export HAR from browser devtools, then:
python parse_eth_rpc_har.py export.har > calls.csv
python method_activity_timeline.py calls.csvIdentifies:
- Unnecessary RPC calls
- Batching opportunities
- Slow methods blocking UX
# Detailed timing breakdown
curl -i -X POST https://mainnet.megaeth.com/rpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' \
-w "dns: %{time_namelookup} | connect: %{time_connect} | total: %{time_total}\n"| Network | Explorer |
|---|---|
| Mainnet | https://mega.etherscan.io |
| Testnet | https://megaeth-testnet-v2.blockscout.com |
Etherscan may lag a few blocks behind real-time.
- Check transaction on explorer
- Replay with mega-evme locally
- Profile gas by opcode
- Contact MegaETH team with:
- Transaction hash
- Error message
- Reproduction steps