megaeth-developer
End-to-end MegaETH development playbook (Feb 2026). Covers Foundry project setup with MegaETH-specific config, wallet operations, token swaps (Kyber Network), eth_sendRawTransactionSync (EIP-7966) for instant receipts, JSON-RPC batching, real-time mini-block subscriptions, storage-aware contract patterns (Solady RedBlackTreeLib, transient storage), MegaEVM multidimensional gas model, WebSocket keepalive, bridging from Ethereum, Privy headless signing for ultra-low latency, debugging with mega-evme, x402 Permit2 payments on MegaETH (standard flow via x402ExactPermit2Proxy/x402UptoPermit2Proxy at canonical addresses), legacy Meridian x402 payments, and Warren Protocol for on-chain website hosting. Use when building on MegaETH, using Foundry, managing wallets, sending transactions, deploying contracts, integrating Privy embedded wallets, ERC-7710 delegation framework for scoped on-chain permissions, MetaMask Smart Accounts Kit for smart account creation and delegation management, integrating x402 Permit2 payments or Meridian/x402 paid APIs or agent actions, hosting websites on-chain with Warren, or integrating MegaNames (.mega naming service) for name registration, resolution, subdomains, subdomain marketplace (selling/buying subdomains with token gating), and text records.
git clone https://github.com/0xBreadguy/megaeth-ai-developer-skills
git clone --depth=1 https://github.com/0xBreadguy/megaeth-ai-developer-skills ~/.claude/skills/0xbreadguy-megaeth-ai-developer-skills-megaeth-developer
SKILL.mdMegaETH Development Skill
What this Skill is for
Use this Skill when the user asks for:
- Foundry project setup targeting MegaETH
- Writing and running tests (unit, fuzz, invariant) on MegaETH
- Deploying and verifying contracts on MegaETH
- Wallet setup and management on MegaETH
- Sending transactions, checking balances, token operations
- Token swaps via Kyber Network aggregator
- MegaETH dApp frontend (React / Next.js with real-time updates)
- RPC configuration and transaction flow optimization
- Smart contract development with MegaEVM considerations
- Storage optimization (transient storage, Solady patterns)
- Gas estimation and fee configuration
- Testing and debugging MegaETH transactions
- WebSocket subscriptions and mini-block streaming
- Bridging ETH from Ethereum to MegaETH
- Privy integration for headless/automated signing
- x402 payments on MegaETH (Permit2 — preferred)
- Meridian / x402 legacy payments on MegaETH
- Ultra-low latency transaction patterns
- ERC-7710 delegations (scoped permissions, spending limits, redelegation chains)
- MetaMask Smart Accounts (ERC-4337 accounts, signers, user operations)
- Advanced permissions (ERC-7715) via MetaMask
- MegaNames (.mega naming service) — registration, resolution, subdomains, subdomain marketplace, text records
- Verifiable randomness with drand VRF (
) for lotteries, reveals, and game mechanicsDrandOracleQuicknet
Chain Configuration
| Network | Chain ID | RPC | Explorer |
|---|---|---|---|
| Mainnet | 4326 | | |
| Testnet | 6343 | | |
Default stack decisions (opinionated)
0. Randomness: drand VRF is async commit/reveal
- MegaETH ships a predeployed
verifierDrandOracleQuicknet - drand quicknet produces a new round every ~3 seconds
- Treat this as public verifiable async randomness, not same-transaction entropy
- Always commit to a future round and lock all outcome-relevant inputs at commit time
- Prefer
and plan reveal liveness (user, relayer, keeper)verifyNormalized
1. Transaction submission: eth_sendRawTransactionSync first
- Use
(EIP-7966) — returns receipt in <10mseth_sendRawTransactionSync - Eliminates polling for
eth_getTransactionReceipt - Docs: https://docs.megaeth.com/realtime-api
2. RPC: Multicall for eth_call batching (v2.0.14+)
- Prefer Multicall (
) for batching multipleaggregate3
requestseth_call - As of v2.0.14,
is 2-10x faster; Multicall amortizes per-RPC overheadeth_call - Still avoid mixing slow methods (
) with fast ones in same requesteth_getLogs
Note: Earlier guidance recommended JSON-RPC batching over Multicall for caching benefits. With v2.0.14's performance improvements, Multicall is now preferred.
3. WebSocket: keepalive required
- Send
every 30 secondseth_chainId - 50 connections per VIP endpoint, 10 subscriptions per connection
- Use
subscription for real-time dataminiBlocks
4. Storage: slot reuse patterns
- SSTORE 0→non-zero costs 2M gas × multiplier (expensive)
- Use Solady's RedBlackTreeLib instead of Solidity mappings
- Design for slot reuse, not constant allocation
5. Gas: skip estimation when possible
- Base fee stable at 0.001 gwei, no EIP-1559 adjustment
- Ignore
(returns 0)eth_maxPriorityFeePerGas - Hardcode gas limits to save round-trip
- Always use remote
(MegaEVM costs differ from standard EVM)eth_estimateGas
6. Debugging: mega-evme CLI
- Replay transactions with full traces
- Profile gas by opcode
- https://github.com/megaeth-labs/mega-evm
Operating procedure
1. Classify the task layer
- Frontend/WebSocket layer
- RPC/transaction layer
- Smart contract layer
- Testing/debugging layer
2. Pick the right patterns
- Frontend: single WebSocket → broadcast to users (not per-user connections)
- Transactions: sign locally →
→ doneeth_sendRawTransactionSync - Contracts: check SSTORE patterns, avoid volatile data access limits
- Testing: use mega-evme for replay, Foundry with
--skip-simulation - Delegations: create scoped permissions → sign → share → redeem via
eth_sendRawTransactionSync
3. Implement with MegaETH-specific correctness
Always be explicit about:
- Chain ID (4326 mainnet, 6343 testnet)
- Gas limit (hardcode when possible)
- Base fee (0.001 gwei, no buffer)
- Storage costs (new slots are expensive)
- Volatile data limits (20M total compute gas cap, retroactive, when block.timestamp accessed)
4. Deliverables expectations
When implementing changes, provide:
- Exact files changed + diffs
- Commands to build/test/deploy
- Gas cost notes for storage-heavy operations
- RPC optimization notes if applicable
Progressive disclosure (read when needed)
- Foundry setup & deploy: foundry-config.md
- Wallet operations: wallet-operations.md
- Frontend patterns: frontend-patterns.md
- Privy integration: privy-integration.md
- x402 payments (Permit2): x402-payments.md
- Meridian payments (legacy): meridian.md
- RPC methods reference: rpc-methods.md
- Smart contract patterns: smart-contracts.md
- Storage optimization: storage-optimization.md
- Gas model: gas-model.md
- Testing & debugging: testing.md
- Security considerations: security.md
- ERC-7710 delegations: erc7710-delegations.md
- MetaMask Smart Accounts: smart-accounts.md
- Warren Protocol (on-chain websites): warren.md
- MegaNames (.mega naming): meganames.md
- Verifiable randomness (drand VRF): vrf-drand.md
- Reference links & attribution: resources.md