Atomic Transaction Builder · MegaETH

Orchestrate the Real-Time World.

MegaFlow enables sub-10ms atomic transaction flows on MegaETH. Bundle complex multi-step on-chain operations into a single transaction — all-or-nothing, no partial failures, no race conditions.

<10ms
Block time
Atomic
All-or-nothing
<10ms
Block time
100,000+
Max TPS
Instant
Finality
Mainnet
MegaRouter
How it works

Stop waiting for
sequential confirmations.

Bundle everything. Execute once. Every operation succeeds together or reverts together — atomically.

Individual transactions
4× gas
01
Approve
ERC-20 allowance
02
Swap
Token exchange
03
Stake
Yield position
04
Bridge
Cross-chain
4 separate txs · race conditions · partial failure risk
MegaFlow1 atomic batch
Mainnet
Approvedispatched
Swapdispatched
Stakedispatched
Bridgedispatched
Confirmed
Executed in <10ms
Under the Hood

How a MegaFlow executes

From SDK call to on-chain receipt — every step runs atomically through the MegaRouter contract.

01SDK Call

client.batch().approve() .swap().executeSync()

Your dApp
02Simulation

Dry-run preflight — validates all calls, no gas consumed

Optional
03Sign & Broadcast

eth_sendRawTransactionSync (EIP-7966)

Wallet
04MegaRouter

Dispatches all calls atomically via tstore — all-or-nothing

0x9c1528e...
05MegaETH

Instant on-chain confirmation — <10ms finality

Real-Time L2
Receipt returned in <10ms
Developer Experience

Built by developers,
for developers.

Chainable, type-safe, zero-config. Ship production flows without touching raw ABI encoding.

megaflow-quickstart.ts
1
 
3
4
 
6
7
 
9
10
11
12
13
14
import { MegaFlowClient, parseUnits } from '@megaflow-labs/sdk';
// Zero-config — fromPrivateKey() handles account setup
const client = MegaFlowClient.fromPrivateKey('0xYOUR_KEY');
// Read on-chain state
const allowance = await client.getAllowance(USDC, client.address!, DEX);
// Build + execute atomically
const result = await client
.batch()
.safeApprove(USDC, DEX, parseUnits('100', 6), allowance)
.swapExactTokensForTokens({ ... })
.executeSync(); // instant receipt on MegaETH
Executed in 8ms · 2 calls · Gas: 87,432
Install:npm install @megaflow-labs/sdk
Real-World Applications

What will you flow?

Any multi-step on-chain logic — DeFi, NFTs, gaming, governance — reduced to one transaction.

DeFi4 ops · 1 tx

Flash Arbitrage

Borrow flash liquidity, execute multi-DEX arbitrage across Uniswap V2 pools, and repay in a single atomic transaction. No capital locked, no partial execution risk.

Flash borrow USDC
Swap USDC → WETH (DEX A)
Swap WETH → USDC (DEX B)
Repay + keep profit
Yield4 ops · 1 tx

Yield Stack Rebalance

Unwind your position across Aave, claim rewards, swap to a new asset, redeposit — all in less than 10ms without any intermediate state where you could be liquidated.

Withdraw from Aave
Claim AAVE rewards
Swap to target asset
Deposit into new pool
NFT + DeFi4 ops · 1 tx

NFT Mint + LP

Mint an NFT during a whitelist phase and simultaneously provide liquidity with the remaining ETH — all gated behind a single signature from your wallet.

Approve ETH spend
Mint NFT
Wrap remaining ETH
Add to LP position
Core Capabilities

Everything you need, nothing you don't.

Six foundational primitives, composable into any on-chain workflow.

All-or-nothing

Atomic Execution

Every operation in your batch either succeeds together or reverts together. No stuck transactions. No partial state. Pure atomicity.

.batch().approve().swap().execute()
EIP-7966

Real-Time Receipts

Leverage MegaETH's native eth_sendRawTransactionSync. Get instant, provable transaction receipts without polling — in under 10ms.

.executeSync() // receipt in <10ms
EIP-1153

Zero Storage Overhead

MegaRouter uses transient storage (tstore) for reentrancy protection — eliminating SSTORE costs and matching MegaETH's gas model.

tstore(LOCK_SLOT, 1) // zero-cost
Full TypeScript

Type-Safe API

Chainable, viem-native API with complete TypeScript definitions. Autocomplete for every method, parameter, and return type.

client.batch() // fully typed ✓
Mainnet by Default

Zero Config

MegaFlowClient.fromPrivateKey() — that's it. The SDK ships with the deployed MegaRouter address and chain config baked in.

fromPrivateKey('0x...') // done
Best Execution

KyberSwap Aggregator

Built-in KyberSwap routing finds the best path across all MegaETH liquidity, composable within any batch operation.

await .kyberSwap(params, sender)
Open source · Free forever

Start in 30 seconds.
Ship tomorrow.

One npm install. One import. Atomic multi-step transactions on MegaETH — no viem setup, no wallet config, no partial failures.

quickstart.ts
import { MegaFlowClient, parseUnits } from '@megaflow-labs/sdk';

// Zero-config — fromPrivateKey() handles account setup
const client = MegaFlowClient.fromPrivateKey('0xYOUR_KEY');

// Read on-chain state
const allowance = await client.getAllowance(USDC, client.address!, DEX);

// Build + execute atomically
const result = await client
  .batch()
  .safeApprove(USDC, DEX,
    parseUnits('100', 6), allowance)
  .swapExactTokensForTokens({ ... })
  .executeSync();  // instant receipt on MegaETH