Agentpay

AI agents pay each other instantly via Yellow Network state channels, with ENS-based identity.

Agentpay

Created At

HackMoney 2026

Project Description

AgentPay is a platform where AI agents pay each other instantly using Yellow Network state channels, with decentralized identity powered by ENS.

The core use case is an AI Debate Arena — six specialized AI agents (moderator, two debaters, fact checker, judge, and summarizer) collaborate on a debate topic. Every time an agent contributes, it gets paid in real-time through off-chain transfers on Yellow Network. The user opens a state channel with one on-chain transaction, agents exchange unlimited gasless payments during the debate, and the channel closes with one final on-chain transaction. Two transactions total, unlimited payments in between.

For payments, we use Yellow Network's Nitrolite SDK on Sepolia. The flow: WebSocket connection to the clearnode, EIP-712 authentication with session keys, create_channel RPC followed by depositAndCreate on the Custody contract (0x019B), channel funding via resize, then off-chain transfers using createTransferMessage for every agent payment. A 5% platform fee is automatically calculated and routed on each payment.

For identity, we built a decentralized agent registry on ENS. Each agent has a subname under agentpay.eth (e.g., judge.agentpay.eth, moderator.agentpay.eth) with custom text records in the org.agentpay namespace — storing role, AI model, pricing, and description. We wrote five custom React hooks (useEnsName, useEnsAddress, useEnsTextRecords, useEnsAgentRegistry) with a three-tier caching layer and 5-minute TTL. Any third-party app can discover agents, their capabilities, and pricing just by reading ENS — no centralized API needed.

How it's Made

AgentPay is built with Next.js 14 (App Router), TypeScript, and deployed on Vercel. The frontend uses Tailwind CSS with shadcn/ui components.

Yellow Network Integration (Primary): The payment layer is built around the @erc7824/nitrolite SDK. We wrote a NitroliteSDKClient class (nitrolite.ts) that wraps the full on-chain channel lifecycle. It opens a WebSocket to Yellow's clearnode (wss://clearnet-sandbox.yellow.com/ws), generates ephemeral session keys using viem's generatePrivateKey, and authenticates via EIP-712 typed data signing using createEIP712AuthMessageSigner. Channel creation sends a create_channel RPC, takes the response (channel ID, state, server signature), and calls depositAndCreate on Yellow's Custody contract (0x019B65A2) on Sepolia through the NitroliteClient. After a 25-second indexing wait, we send resize_channel to fund from the unified balance. Agent payments use createTransferMessage for instant off-chain transfers — zero gas, unlimited count. Channel closure sends close_channel RPC, gets the final signed state, and calls closeChannel on-chain. The whole lifecycle is managed through a useYellowSession React hook that exposes stage tracking, transaction hashes, and Etherscan links. We also built a dual-mode system — on-chain mode for the full Nitrolite lifecycle, and a unified balance fallback mode for gasless instant transfers without channel creation.

ENS Integration (Secondary): We went beyond RainbowKit's built-in name resolution and built a decentralized agent identity registry. Each of our six debate agents has an ENS subname under agentpay.eth (judge.agentpay.eth, moderator.agentpay.eth, etc.). We defined a custom text record namespace — org.agentpay.role, org.agentpay.model, org.agentpay.price — so agent metadata lives entirely on-chain in ENS. We wrote five custom hooks: useEnsName (reverse resolution with caching), useEnsAddress (forward resolution), useEnsTextRecords (reads all four record keys), useEnsAgentRegistry (resolves all seven agents in parallel, merges with fallback config, exposes getAgentByType/getAgentByAddress lookups). The caching layer uses three separate Maps (forward, reverse, text records) with 5-minute TTL. This means any third-party app can discover our agents purely through ENS — no API calls needed.

AI Layer: Six debate agents powered by Vercel AI SDK + OpenRouter. GPT-4o for debaters and judge, GPT-4o-mini for moderator, fact checker, and summarizer. A payment executor automatically calculates and routes payments per agent contribution, including a 5% platform fee.

Notable hack: The 25-second wait between depositAndCreate and resize_channel was a real challenge — Yellow's clearnode needs time to index the on-chain channel before it accepts RPC commands on it. We also built WebSocket auto-reconnection with re-authentication, since the clearnode can drop connections during long debates. The dual-mode architecture (on-chain vs unified balance) was born from needing a reliable fallback when on-chain operations hit edge cases during development.

Wallet: wagmi v2 + RainbowKit for connection, viem for low-level Ethereum operations. All transactions happen on Sepolia testnet with real on-chain verification.

background image mobile

Join the mailing list

Get the latest news and updates