← Back to home

Agentic Economy

Cross-chain payment infrastructure that enables AI agents to autonomously pay using PYUSD

Problem Statement

🔄 Complete Payment FlowPhase 1: Service Discovery & RegistrationMCP Service RegistrationService providers register their APIs with the MCP GatewaySpecify accepted payment tokens (USDC, ETH, PYUSD, etc.)Define pricing per API callRegister supported chains (Base, Arbitrum, Ethereum, Optimism)// Service provider registers their API mcpGateway.registerMCP( "gpt-vision-api.com", // Service endpoint 1000000, // Price: 1 USDC per call ["USDC", "USDT"], // Accepted tokens [30184, 30110] // Base & Arbitrum chains );Phase 2: Agent Payment RequestAI Agent Initiates PaymentAgent on Base needs to call a vision API on ArbitrumAPI requires USDC but agent only has PYUSDAgent calls x402 Payment Router// Agent initiates cross-chain payment const paymentRequest = await x402Router.requestPayment({ serviceId: "vision-api-123", amount: "1000000", // 1 PYUSD requestedToken: "USDC", // Service wants USDC destinationChain: 30110, // Arbitrum serviceData: encodedAPICall });Phase 3: Cross-Chain RoutingLayerZero Message RoutingX402 Payment Router locks PYUSD on source chainCreates LayerZero message with payment detailsIncludes composer message for token swap// Router creates cross-chain message bytes memory lzMessage = abi.encode( serviceProvider, paymentAmount, targetToken, // USDC minAmountOut ); // Send via LayerZero with composition endpoint.send( destinationChainId, lzMessage, options, composeMsg // Instructions for swap );Phase 4: Token Swap ExecutionAutomatic Token ConversionLayerZero delivers message to destination chainToken Swap Composer receives PYUSDAutomatically swaps PYUSD → USDC via DEXSends USDC to service provider// Composer receives and processes function lzCompose( address from, bytes32 guid, bytes calldata message ) external { (address recipient, uint256 amount, address targetToken) = abi.decode(message, (address, uint256, address)); // Swap PYUSD to USDC uint256 usdcAmount = _swapPYUSDToToken(amount, targetToken); // Transfer to service provider IERC20(targetToken).transfer(recipient, usdcAmount); }Phase 5: Service ExecutionAPI Call CompletionService provider receives payment in preferred tokenExecutes API call for the agentReturns results through callback🎯 Key Components ExplainedPYUSD OFT Adapter Purpose: Enable cross-chain PYUSD transfers maintaining 6 decimal precisionKey Features:LayerZero V2 OFT (Omnichain Fungible Token) standardSupports Ethereum, Base, Arbitrum, Optimism, SolanaMaintains consistent decimal precision across chainsGas-optimized for micropaymentsDeployed:0x72924Fa9C3dB52fbFC6581979226340B996F3487Token Swap Composer Purpose: Automatic token conversion after cross-chain transferKey Features:Implements LayerZero Composer patternReceives PYUSD and swaps to any tokenIntegrates with DEX aggregators (1inch, 0x, Uniswap)Slippage protection and MEV resistanceDeployed:0xAEAb897238015ce8d9C8a248B897D8aea3806795X402 Payment Router Purpose: Main orchestrator for cross-chain micropaymentsKey Features:Implements Coinbase x402 protocolService discovery and routingPayment request managementCross-chain message coordinationContract:X402PaymentRouter.solMCP Payment Gateway Purpose: Bridge between AI agents and blockchain paymentsKey Features:Service provider registrationPayment request handlingMulti-token supportAnalytics and trackingContract:MCPPaymentGateway.sol💡 Innovation HighlightsUniversal Payment Token (PYUSD)Single token for all payments simplifies agent logicStable value reduces volatility riskWide exchange support ensures liquidityAutomatic Token ConversionService providers receive preferred tokensNo manual swapping requiredOptimized routing for best ratesCross-Chain SeamlessAgents on any chain can pay services on any other chainNo bridging complexity for agentsAtomic execution ensures reliabilityMicropayment OptimizedBatch processing for gas efficiencyPayment channels for frequent callsCompressed messaging reduces costs🚀 Real-World Use CasesUse Case 1: Multi-Chain AI Workflow1. GPT Agent (Ethereum) needs image analysis 2. Vision API (Base) charges 1 USDC per image 3. Agent pays in PYUSD from Ethereum 4. System routes payment cross-chain 5. Swaps PYUSD → USDC on Base 6. API receives USDC and processes image 7. Results returned to agent on EthereumUse Case 2: Decentralized AI Marketplace1. Developer deploys new LLM on Arbitrum 2. Registers service with MCP Gateway 3. Sets pricing: 0.001 ETH per 1000 tokens 4. Agents worldwide can access service 5. Payments routed automatically 6. Developer receives ETH regardless of agent's tokenUse Case 3: Autonomous Agent Economy1. Trading bot (Base) needs market data 2. Data provider (Optimism) charges USDT 3. Bot pays PYUSD, system handles conversion 4. Multiple API calls batched for efficiency 5. Payment channels reduce per-call costs 6. Bot operates 24/7 without human intervention

Solution

🔄 Complete Payment FlowPhase 1: Service Discovery & RegistrationMCP Service RegistrationService providers register their APIs with the MCP GatewaySpecify accepted payment tokens (USDC, ETH, PYUSD, etc.)Define pricing per API callRegister supported chains (Base, Arbitrum, Ethereum, Optimism)// Service provider registers their API mcpGateway.registerMCP( "gpt-vision-api.com", // Service endpoint 1000000, // Price: 1 USDC per call ["USDC", "USDT"], // Accepted tokens [30184, 30110] // Base & Arbitrum chains );Phase 2: Agent Payment RequestAI Agent Initiates PaymentAgent on Base needs to call a vision API on ArbitrumAPI requires USDC but agent only has PYUSDAgent calls x402 Payment Router// Agent initiates cross-chain payment const paymentRequest = await x402Router.requestPayment({ serviceId: "vision-api-123", amount: "1000000", // 1 PYUSD requestedToken: "USDC", // Service wants USDC destinationChain: 30110, // Arbitrum serviceData: encodedAPICall });Phase 3: Cross-Chain RoutingLayerZero Message RoutingX402 Payment Router locks PYUSD on source chainCreates LayerZero message with payment detailsIncludes composer message for token swap// Router creates cross-chain message bytes memory lzMessage = abi.encode( serviceProvider, paymentAmount, targetToken, // USDC minAmountOut ); // Send via LayerZero with composition endpoint.send( destinationChainId, lzMessage, options, composeMsg // Instructions for swap );Phase 4: Token Swap ExecutionAutomatic Token ConversionLayerZero delivers message to destination chainToken Swap Composer receives PYUSDAutomatically swaps PYUSD → USDC via DEXSends USDC to service provider// Composer receives and processes function lzCompose( address from, bytes32 guid, bytes calldata message ) external { (address recipient, uint256 amount, address targetToken) = abi.decode(message, (address, uint256, address)); // Swap PYUSD to USDC uint256 usdcAmount = _swapPYUSDToToken(amount, targetToken); // Transfer to service provider IERC20(targetToken).transfer(recipient, usdcAmount); }Phase 5: Service ExecutionAPI Call CompletionService provider receives payment in preferred tokenExecutes API call for the agentReturns results through callback🎯 Key Components ExplainedPYUSD OFT Adapter Purpose: Enable cross-chain PYUSD transfers maintaining 6 decimal precisionKey Features:LayerZero V2 OFT (Omnichain Fungible Token) standardSupports Ethereum, Base, Arbitrum, Optimism, SolanaMaintains consistent decimal precision across chainsGas-optimized for micropaymentsDeployed:0x72924Fa9C3dB52fbFC6581979226340B996F3487Token Swap Composer Purpose: Automatic token conversion after cross-chain transferKey Features:Implements LayerZero Composer patternReceives PYUSD and swaps to any tokenIntegrates with DEX aggregators (1inch, 0x, Uniswap)Slippage protection and MEV resistanceDeployed:0xAEAb897238015ce8d9C8a248B897D8aea3806795X402 Payment Router Purpose: Main orchestrator for cross-chain micropaymentsKey Features:Implements Coinbase x402 protocolService discovery and routingPayment request managementCross-chain message coordinationContract:X402PaymentRouter.solMCP Payment Gateway Purpose: Bridge between AI agents and blockchain paymentsKey Features:Service provider registrationPayment request handlingMulti-token supportAnalytics and trackingContract:MCPPaymentGateway.sol💡 Innovation HighlightsUniversal Payment Token (PYUSD)Single token for all payments simplifies agent logicStable value reduces volatility riskWide exchange support ensures liquidityAutomatic Token ConversionService providers receive preferred tokensNo manual swapping requiredOptimized routing for best ratesCross-Chain SeamlessAgents on any chain can pay services on any other chainNo bridging complexity for agentsAtomic execution ensures reliabilityMicropayment OptimizedBatch processing for gas efficiencyPayment channels for frequent callsCompressed messaging reduces costs🚀 Real-World Use CasesUse Case 1: Multi-Chain AI Workflow1. GPT Agent (Ethereum) needs image analysis 2. Vision API (Base) charges 1 USDC per image 3. Agent pays in PYUSD from Ethereum 4. System routes payment cross-chain 5. Swaps PYUSD → USDC on Base 6. API receives USDC and processes image 7. Results returned to agent on EthereumUse Case 2: Decentralized AI Marketplace1. Developer deploys new LLM on Arbitrum 2. Registers service with MCP Gateway 3. Sets pricing: 0.001 ETH per 1000 tokens 4. Agents worldwide can access service 5. Payments routed automatically 6. Developer receives ETH regardless of agent's tokenUse Case 3: Autonomous Agent Economy1. Trading bot (Base) needs market data 2. Data provider (Optimism) charges USDT 3. Bot pays PYUSD, system handles conversion 4. Multiple API calls batched for efficiency 5. Payment channels reduce per-call costs 6. Bot operates 24/7 without human intervention

Hackathon

ETHGlobal New York 2025

2025

Prizes

  • 🏆

    Flow Builder Pool Prize

    Flow