An x402 protocol implementation using state channels for high-frequency payments between AI agents.
We built a payment infrastructure that lets AI agents pay for resources in real-time—100+ transactions in under 10 seconds, each settling in ~50 milliseconds. This is the payment layer autonomous agents need.
The Problem with Current x402 Implementations:
The x402 protocol (HTTP 402 Payment Required) already exists—Coinbase and others have implementations. But they all share a critical flaw: every payment settles on-chain.
Speed: Each on-chain transaction takes 12-15 seconds on Ethereum, 2-4 seconds even on "fast" L2s Gas fees: Every payment costs $0.01-$5+ in gas, making micropayments economically impossible Network congestion: During high traffic, transactions queue up or fail entirely Throughput ceiling: ~15 TPS on Ethereum mainnet, ~100-1000 TPS on L2s
For AI agents making hundreds of API calls per minute, on-chain x402 is unusable. An agent can't wait 12 seconds between API requests. Gas fees exceed the payment value. Network congestion causes unpredictable failures.
Our Solution: Yellow Network State Channels
Yellow Network moves payments off-chain while preserving on-chain security:
~50ms settlement vs 12+ seconds on-chain Zero gas fees during operation (gas only for channel open/close) No congestion — payments bypass the blockchain entirely Unlimited throughput — limited only by WebSocket speed
What We Demonstrated: 100 API payments in ~8 seconds (12+ minutes with on-chain x402) $0 in gas fees (vs $1-500+ for 100 on-chain transactions) 100% success rate (no failed transactions from congestion) Autonomous execution — no wallet popups, no human approval
This unlocks what on-chain x402 promised but couldn't deliver: true micropayments for AI agents, real-time API billing, and high-frequency machine-to-machine commerce.
The Problem We Solved: Existing x402 implementations require on-chain settlement per payment. We built x402 on Yellow Network state channels—same protocol, 1000x faster, zero gas.
Architecture:
Frontend: Next.js 15 demo with real-time payment visualization Backend: Express.js with x402 middleware for any endpoint Yellow Network: @erc7824/nitrolite SDK for off-chain payments via ClearNode How Yellow Network Solves On-Chain x402 Problems:
State Channels vs On-Chain:
On-chain x402: Every payment = blockchain transaction = 12s + gas Yellow x402: Payments update off-chain state = ~50ms + $0 On-chain only needed to open/close the channel No Network Congestion:
On-chain: Competes with all Ethereum/L2 traffic Yellow: Direct WebSocket to ClearNode, bypasses blockchain entirely Demo ran 100 payments without a single congestion-related failure Economically Viable Micropayments:
On-chain: $0.50 gas for a $0.01 payment = 50x overhead Yellow: $0 gas for unlimited payments, settle once at the end Makes per-API-call billing actually profitable Why This Matters for AI Agents:
Current on-chain x402 is human-speed infrastructure. AI agents operate at machine speed:
An agent making 10 API calls/second can't wait 12 seconds per payment Gas fees for 1000 daily API calls would cost more than the service itself Network congestion causes unpredictable agent failures Yellow Network gives agents the payment rails they need: instant, free, reliable.
Technical Implementation:
Ephemeral Session Keys: Agent signs once (EIP-712), then uses the session key for all payments. No wallet popups, no human approval loops.
Persistent WebSocket: Single authenticated connection to ClearNode. The 100-payment demo runs through one WebSocket—no reconnection overhead.
Push-Based Verification: ClearNode broadcasts "tr" notifications when payments arrive. Server caches by transaction ID. Verification is a cache lookup, not a blockchain query.
x402 Protocol Compliance:
GET /api → 402 + payment requirements Pay via Yellow (~50ms) GET /api + X-PAYMENT header → 200 + data Same protocol as on-chain x402, but 1000x faster.
The X-PAYMENT Header:
{ "x402Version": 1, "scheme": "yellow", "network": "clearnet", "payload": { "transactionId": 12345, "fromAccount": "0x...", "amount": "10000" } }
Any x402 client can integrate—just swap the payment backend from on-chain to Yellow Network.
Stack: TypeScript, WebSocket, viem/wagmi, @erc7824/nitrolite, SSE for real-time UI.
What Makes This Different: We didn't just implement x402—we fixed its fundamental scalability problem. On-chain x402 is a great protocol with unusable economics. Yellow x402 makes the economics work.

