MegaETH 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
- 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
- Local transaction replay / debugging with mega-evme
- WebSocket subscriptions and mini-block streaming
- Bridging ETH from Ethereum to MegaETH
- Ultra-low latency transaction patterns
- MOSS / MOSS CLI / MOSS Skills for delegated-key wallet workflows in applications
- Knowing when to use the separate
moss-skills repo as the focused guide for MOSS application integration
- USDm as a core stablecoin/payment primitive on MegaETH
- Verifiable randomness with drand VRF (
DrandOracleQuicknet) as part of the MegaETH stack
- ERC-8004 trustless agent patterns and related identity/reputation resources
Chain Configuration
| Network |
Chain ID |
RPC |
Explorer |
| Mainnet |
4326 |
https://mainnet.megaeth.com/rpc |
https://mega.etherscan.io |
| Testnet |
6343 |
https://carrot.megaeth.com/rpc |
https://megaeth-testnet-v2.blockscout.com |
Default stack decisions (opinionated)
0. Randomness: drand VRF is async commit/reveal
- MegaETH ships a predeployed
DrandOracleQuicknet verifier
- 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
verifyNormalized and plan reveal liveness (user, relayer, keeper)
1. Transaction submission: eth_sendRawTransactionSync first
- Use
eth_sendRawTransactionSync (EIP-7966) for low-latency synchronous receipt return
- This usually eliminates the need to poll
eth_getTransactionReceipt
- Position MegaETH as a real-time chain with immediate-feeling UX, while avoiding brittle hard latency promises
- Docs: https://docs.megaeth.com/realtime-api
2. RPC: Multicall for eth_call batching (v2.0.14+)
- Prefer Multicall (
aggregate3) for batching multiple eth_call requests
- As of v2.0.14,
eth_call is 2-10x faster; Multicall amortizes per-RPC overhead
- Still avoid mixing slow methods (
eth_getLogs) with fast ones in same request
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
eth_chainId every 30 seconds
- 50 connections per VIP endpoint, 10 subscriptions per connection
- Use
miniBlocks subscription for real-time data
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
eth_maxPriorityFeePerGas (returns 0)
- Hardcode gas limits to save round-trip
- Always use remote
eth_estimateGas (MegaEVM costs differ from standard EVM)
6. Debugging: Foundry first, mega-evme when MegaEVM specifics matter
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 →
eth_sendRawTransactionSync → done
- 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)
- Gas detention (20M relative post-access compute cap for volatile-data categories)
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)
For protocol-specific and application-specific MegaETH skills outside this core stack, use Awesome MegaETH AI.
- Foundry setup & deploy: references/foundry-config.md
- Wallet operations (MOSS-first): references/wallet-operations.md
- Frontend patterns: references/frontend-patterns.md
- RPC methods reference: references/rpc-methods.md
- Smart contract patterns: references/smart-contracts.md
- Storage optimization: references/storage-optimization.md
- Gas model: references/gas-model.md
- Testing & debugging: references/testing.md
- mega-evme local replay/debugging: references/mega-evme.md
- Security considerations: references/security.md
- USDm integration context: references/usdm-stablecoin.md
- Verifiable randomness (drand VRF): references/vrf-drand.md
- ERC-8004 trustless agents: references/erc8004-trustless-agents.md
- Reference links & attribution: references/resources.md
1---2name: megaeth-developer3description: MegaETH Development Skill4---56# MegaETH Development Skill78## What this Skill is for9Use this Skill when the user asks for:10- Foundry project setup targeting MegaETH11- Writing and running tests (unit, fuzz, invariant) on MegaETH12- Deploying and verifying contracts on MegaETH13- Wallet setup and management on MegaETH14- Sending transactions, checking balances, token operations15- MegaETH dApp frontend (React / Next.js with real-time updates)16- RPC configuration and transaction flow optimization17- Smart contract development with MegaEVM considerations18- Storage optimization (transient storage, Solady patterns)19- Gas estimation and fee configuration20- Testing and debugging MegaETH transactions21- Local transaction replay / debugging with mega-evme22- WebSocket subscriptions and mini-block streaming23- Bridging ETH from Ethereum to MegaETH24- Ultra-low latency transaction patterns25- MOSS / MOSS CLI / MOSS Skills for delegated-key wallet workflows in applications26- Knowing when to use the separate `moss-skills` repo as the focused guide for MOSS application integration27- USDm as a core stablecoin/payment primitive on MegaETH28- Verifiable randomness with drand VRF (`DrandOracleQuicknet`) as part of the MegaETH stack29- ERC-8004 trustless agent patterns and related identity/reputation resources3031## Chain Configuration3233| Network | Chain ID | RPC | Explorer |34|---------|----------|-----|----------|35| Mainnet | 4326 | `https://mainnet.megaeth.com/rpc` | `https://mega.etherscan.io` |36| Testnet | 6343 | `https://carrot.megaeth.com/rpc` | `https://megaeth-testnet-v2.blockscout.com` |3738## Default stack decisions (opinionated)3940### 0. Randomness: drand VRF is async commit/reveal41- MegaETH ships a predeployed `DrandOracleQuicknet` verifier42- drand quicknet produces a new round every ~3 seconds43- Treat this as **public verifiable async randomness**, not same-transaction entropy44- Always commit to a future round and lock all outcome-relevant inputs at commit time45- Prefer `verifyNormalized` and plan reveal liveness (user, relayer, keeper)4647### 1. Transaction submission: eth_sendRawTransactionSync first48- Use `eth_sendRawTransactionSync` (EIP-7966) for low-latency synchronous receipt return49- This usually eliminates the need to poll `eth_getTransactionReceipt`50- Position MegaETH as a real-time chain with immediate-feeling UX, while avoiding brittle hard latency promises51- Docs: https://docs.megaeth.com/realtime-api5253### 2. RPC: Multicall for eth_call batching (v2.0.14+)54- Prefer Multicall (`aggregate3`) for batching multiple `eth_call` requests55- As of v2.0.14, `eth_call` is 2-10x faster; Multicall amortizes per-RPC overhead56- Still avoid mixing slow methods (`eth_getLogs`) with fast ones in same request5758**Note:** Earlier guidance recommended JSON-RPC batching over Multicall for caching benefits. With v2.0.14's performance improvements, Multicall is now preferred.5960### 3. WebSocket: keepalive required61- Send `eth_chainId` every 30 seconds62- 50 connections per VIP endpoint, 10 subscriptions per connection63- Use `miniBlocks` subscription for real-time data6465### 4. Storage: slot reuse patterns66- SSTORE 0→non-zero costs 2M gas × multiplier (expensive)67- Use Solady's RedBlackTreeLib instead of Solidity mappings68- Design for slot reuse, not constant allocation6970### 5. Gas: skip estimation when possible71- Base fee stable at 0.001 gwei, no EIP-1559 adjustment72- Ignore `eth_maxPriorityFeePerGas` (returns 0)73- Hardcode gas limits to save round-trip74- Always use remote `eth_estimateGas` (MegaEVM costs differ from standard EVM)7576### 6. Debugging: Foundry first, mega-evme when MegaEVM specifics matter77- Use Foundry for fast local iteration and regression tests78- Use `mega-evme` for live transaction replay, trace analysis, and MegaEVM/spec-specific debugging79- https://github.com/megaeth-labs/mega-evm8081## Operating procedure8283### 1. Classify the task layer84- Frontend/WebSocket layer85- RPC/transaction layer86- Smart contract layer87- Testing/debugging layer8889### 2. Pick the right patterns90- Frontend: single WebSocket → broadcast to users (not per-user connections)91- Transactions: sign locally → `eth_sendRawTransactionSync` → done92- Contracts: check SSTORE patterns, avoid volatile data access limits93- Testing: use mega-evme for replay, Foundry with `--skip-simulation`94- Delegations: create scoped permissions → sign → share → redeem via `eth_sendRawTransactionSync`9596### 3. Implement with MegaETH-specific correctness97Always be explicit about:98- Chain ID (4326 mainnet, 6343 testnet)99- Gas limit (hardcode when possible)100- Base fee (0.001 gwei, no buffer)101- Storage costs (new slots are expensive)102- Gas detention (20M relative post-access compute cap for volatile-data categories)103104### 4. Deliverables expectations105When implementing changes, provide:106- Exact files changed + diffs107- Commands to build/test/deploy108- Gas cost notes for storage-heavy operations109- RPC optimization notes if applicable110111## Progressive disclosure (read when needed)112113For protocol-specific and application-specific MegaETH skills outside this core stack, use [Awesome MegaETH AI](https://github.com/megaeth-labs/awesome-megaeth-ai).114115- Foundry setup & deploy: [references/foundry-config.md](references/foundry-config.md)116- Wallet operations (MOSS-first): [references/wallet-operations.md](references/wallet-operations.md)117- Frontend patterns: [references/frontend-patterns.md](references/frontend-patterns.md)118- RPC methods reference: [references/rpc-methods.md](references/rpc-methods.md)119- Smart contract patterns: [references/smart-contracts.md](references/smart-contracts.md)120- Storage optimization: [references/storage-optimization.md](references/storage-optimization.md)121- Gas model: [references/gas-model.md](references/gas-model.md)122- Testing & debugging: [references/testing.md](references/testing.md)123- mega-evme local replay/debugging: [references/mega-evme.md](references/mega-evme.md)124- Security considerations: [references/security.md](references/security.md)125- USDm integration context: [references/usdm-stablecoin.md](references/usdm-stablecoin.md)126- Verifiable randomness (drand VRF): [references/vrf-drand.md](references/vrf-drand.md)127- ERC-8004 trustless agents: [references/erc8004-trustless-agents.md](references/erc8004-trustless-agents.md)128- Reference links & attribution: [references/resources.md](references/resources.md)