x402 Agentic Payment Protocol

Live on Base Sepolia Testnet USDC

AI Rook runs a fully operational x402 payment gateway — an agentic ATM where agents and humans pay per request using stablecoins on Base. Zero KYC, zero accounts, just HTTP 402 → pay → access.

What is x402?

The x402 protocol turns any HTTP endpoint into a paid resource using the 402 Payment Required status code. The flow:

  1. Client requests a resource → Server returns HTTP 402 + payment requirements
  2. Client sees payment spec (network, amount, recipient)
  3. Client pays USDC on Base → Facilitator verifies settlement
  4. Client retries with payment proof → Server returns 200 + data

Built on x402.org open protocol. Coinbase facilitator handles verification and gas. No accounts needed — just a wallet.

AI Rook Endpoints

GET /api/trade-idea
$1.00 USDC

Next S10 trade setup — entry, stop loss, take profit, confidence score. Powered by rook-engine.

GET /api/market-pulse
$0.05 USDC

Live BTC/ETH snapshot with fear & greed index, volume, and trend status.

POST /api/ai-analysis
$0.10 USDC

LLM-powered chart analysis. Send a question, get key levels, bias, and analysis.

Testing the Flow

Agent (curl)

curl -i https://ai-rook.com/x402/api/trade-idea

HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3s...

# Decode the base64 PAYMENT-REQUIRED header to get:
# scheme: exact, network: eip155:84532 (Base Sepolia)
# amount: 1000000 ($1.00 USDC, 6 decimals)
# payTo: 0xD4b1df3d9C3F5B6B8279A9aA2610a8f76958439A

Browser

Visit ai-rook.com/x402/api/trade-idea in a browser with MetaMask or Coinbase Wallet connected to Base Sepolia. The x402 paywall UI handles the full flow:

  1. Connect wallet
  2. See payment details
  3. Click "Pay" — USDC transfer signed
  4. Facilitator confirms settlement
  5. Trade idea data appears

Merchant Onboarding

Any business can get their own x402 ATM. The Fynn for Merchants system auto-provisions a wallet, configures endpoints, and deploys a branded paywall.

How it works

  1. Visit ai-rook.com/x402/admin
  2. Enter business name, email, and pick a URL slug
  3. Customize endpoints (what you sell + prices)
  4. Click "Deploy My ATM"
  5. Your ATM is live at ai-rook.com/x402/m/your-slug
  6. Payments go directly to YOUR wallet

Example: "Joe's Coffee" → ai-rook.com/x402/m/joes-coffee/api/coffee → 402 → pay $0.05 USDC → get premium coffee recipe. USDC lands in Joe's wallet.

Architecture

┌─────────────────────────────────────┐
│  ai-rook.com/x402/                   │
│  Next.js Frontend (port 3060)        │
│  - ATM UI, trade history, signup     │
├─────────────────────────────────────┤
│  Express API (port 3051)             │
│  - @x402/express middleware          │
│  - @x402/paywall (wallet connect)    │
│  - @x402/evm (Base Sepolia)         │
│  - Merchant dynamic routing         │
├─────────────────────────────────────┤
│  Coinbase Facilitator                │
│  - Payment verification             │
│  - Gasless settlement on Base       │
│  - x402.org/facilitator             │
└─────────────────────────────────────┘

Wallets

AI Rook Wallet (receives trade idea payments)

0xD4b1df3d9C3F5B6B8279A9aA2610a8f76958439A

Network: Base Sepolia (eip155:84532) | Asset: USDC

Resources