project screenshot 1
project screenshot 2
project screenshot 3

Agentic Economy

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

Agentic Economy

Created At

ETHGlobal New York 2025

Winner of

Flow Foundation

Flow - Flow Builder Pool Prize

Prize Pool

Project Description

🔄 Complete Payment Flow

Phase 1: Service Discovery & Registration

  1. MCP Service Registration
    • Service providers register their APIs with the MCP Gateway
    • Specify accepted payment tokens (USDC, ETH, PYUSD, etc.)
    • Define pricing per API call
    • Register 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 Request

  1. AI Agent Initiates Payment
    • Agent on Base needs to call a vision API on Arbitrum
    • API requires USDC but agent only has PYUSD
    • Agent 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 Routing

  1. LayerZero Message Routing
    • X402 Payment Router locks PYUSD on source chain
    • Creates LayerZero message with payment details
    • Includes 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 Execution

  1. Automatic Token Conversion
    • LayerZero delivers message to destination chain
    • Token Swap Composer receives PYUSD
    • Automatically swaps PYUSD → USDC via DEX
    • Sends 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 Execution

  1. API Call Completion
    • Service provider receives payment in preferred token
    • Executes API call for the agent
    • Returns results through callback

🎯 Key Components Explained

  1. PYUSD OFT Adapter Purpose: Enable cross-chain PYUSD transfers maintaining 6 decimal precision

Key Features:

  • LayerZero V2 OFT (Omnichain Fungible Token) standard
  • Supports Ethereum, Base, Arbitrum, Optimism, Solana
  • Maintains consistent decimal precision across chains
  • Gas-optimized for micropayments

Deployed: 0x72924Fa9C3dB52fbFC6581979226340B996F3487

  1. Token Swap Composer Purpose: Automatic token conversion after cross-chain transfer

Key Features:

  • Implements LayerZero Composer pattern
  • Receives PYUSD and swaps to any token
  • Integrates with DEX aggregators (1inch, 0x, Uniswap)
  • Slippage protection and MEV resistance

Deployed: 0xAEAb897238015ce8d9C8a248B897D8aea3806795

  1. X402 Payment Router Purpose: Main orchestrator for cross-chain micropayments

Key Features:

  • Implements Coinbase x402 protocol
  • Service discovery and routing
  • Payment request management
  • Cross-chain message coordination

Contract: X402PaymentRouter.sol

  1. MCP Payment Gateway Purpose: Bridge between AI agents and blockchain payments

Key Features:

  • Service provider registration
  • Payment request handling
  • Multi-token support
  • Analytics and tracking

Contract: MCPPaymentGateway.sol

💡 Innovation Highlights

  1. Universal Payment Token (PYUSD)
  • Single token for all payments simplifies agent logic
  • Stable value reduces volatility risk
  • Wide exchange support ensures liquidity
  1. Automatic Token Conversion
  • Service providers receive preferred tokens
  • No manual swapping required
  • Optimized routing for best rates
  1. Cross-Chain Seamless
  • Agents on any chain can pay services on any other chain
  • No bridging complexity for agents
  • Atomic execution ensures reliability
  1. Micropayment Optimized
  • Batch processing for gas efficiency
  • Payment channels for frequent calls
  • Compressed messaging reduces costs

🚀 Real-World Use Cases

Use Case 1: Multi-Chain AI Workflow

1. 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 Ethereum

Use Case 2: Decentralized AI Marketplace

1. 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 token

Use Case 3: Autonomous Agent Economy

1. 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

How it's Made

🔄 Complete Payment Flow

Phase 1: Service Discovery & Registration

  1. MCP Service Registration
    • Service providers register their APIs with the MCP Gateway
    • Specify accepted payment tokens (USDC, ETH, PYUSD, etc.)
    • Define pricing per API call
    • Register 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 Request

  1. AI Agent Initiates Payment
    • Agent on Base needs to call a vision API on Arbitrum
    • API requires USDC but agent only has PYUSD
    • Agent 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 Routing

  1. LayerZero Message Routing
    • X402 Payment Router locks PYUSD on source chain
    • Creates LayerZero message with payment details
    • Includes 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 Execution

  1. Automatic Token Conversion
    • LayerZero delivers message to destination chain
    • Token Swap Composer receives PYUSD
    • Automatically swaps PYUSD → USDC via DEX
    • Sends 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 Execution

  1. API Call Completion
    • Service provider receives payment in preferred token
    • Executes API call for the agent
    • Returns results through callback

🎯 Key Components Explained

  1. PYUSD OFT Adapter Purpose: Enable cross-chain PYUSD transfers maintaining 6 decimal precision

Key Features:

  • LayerZero V2 OFT (Omnichain Fungible Token) standard
  • Supports Ethereum, Base, Arbitrum, Optimism, Solana
  • Maintains consistent decimal precision across chains
  • Gas-optimized for micropayments

Deployed: 0x72924Fa9C3dB52fbFC6581979226340B996F3487

  1. Token Swap Composer Purpose: Automatic token conversion after cross-chain transfer

Key Features:

  • Implements LayerZero Composer pattern
  • Receives PYUSD and swaps to any token
  • Integrates with DEX aggregators (1inch, 0x, Uniswap)
  • Slippage protection and MEV resistance

Deployed: 0xAEAb897238015ce8d9C8a248B897D8aea3806795

  1. X402 Payment Router Purpose: Main orchestrator for cross-chain micropayments

Key Features:

  • Implements Coinbase x402 protocol
  • Service discovery and routing
  • Payment request management
  • Cross-chain message coordination

Contract: X402PaymentRouter.sol

  1. MCP Payment Gateway Purpose: Bridge between AI agents and blockchain payments

Key Features:

  • Service provider registration
  • Payment request handling
  • Multi-token support
  • Analytics and tracking

Contract: MCPPaymentGateway.sol

💡 Innovation Highlights

  1. Universal Payment Token (PYUSD)
  • Single token for all payments simplifies agent logic
  • Stable value reduces volatility risk
  • Wide exchange support ensures liquidity
  1. Automatic Token Conversion
  • Service providers receive preferred tokens
  • No manual swapping required
  • Optimized routing for best rates
  1. Cross-Chain Seamless
  • Agents on any chain can pay services on any other chain
  • No bridging complexity for agents
  • Atomic execution ensures reliability
  1. Micropayment Optimized
  • Batch processing for gas efficiency
  • Payment channels for frequent calls
  • Compressed messaging reduces costs

🚀 Real-World Use Cases

Use Case 1: Multi-Chain AI Workflow

1. 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 Ethereum

Use Case 2: Decentralized AI Marketplace

1. 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 token

Use Case 3: Autonomous Agent Economy

1. 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
background image mobile

Join the mailing list

Get the latest news and updates