███████╗███████╗██╗     ███████╗██╗  ██╗██╗  ██╗ ██████╗ ██████╗
 ██╔════╝██╔════╝██║     ██╔════╝╚██╗██╔╝██║  ██║██╔═████╗╚════██╗
 ███████╗█████╗  ██║     █████╗   ╚███╔╝ ███████║██║██╔██║ █████╔╝
 ╚════██║██╔══╝  ██║     ██╔══╝   ██╔██╗ ╚════██║████╔╝██║██╔═══╝
 ███████║███████╗███████╗██║     ██╔╝ ██╗     ██║╚██████╔╝███████╗
 ╚══════╝╚══════╝╚══════╝╚═╝     ╚═╝  ╚═╝     ╚═╝ ╚═════╝ ╚══════╝

 ███████╗ █████╗  ██████╗██╗██╗     ██╗████████╗ █████╗ ████████╗ ██████╗ ██████╗
 ██╔════╝██╔══██╗██╔════╝██║██║     ██║╚══██╔══╝██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗
 █████╗  ███████║██║     ██║██║     ██║   ██║   ███████║   ██║   ██║   ██║██████╔╝
 ██╔══╝  ██╔══██║██║     ██║██║     ██║   ██║   ██╔══██║   ██║   ██║   ██║██╔══██╗
 ██║     ██║  ██║╚██████╗██║███████╗██║   ██║   ██║  ██║   ██║   ╚██████╔╝██║  ██║
 ╚═╝     ╚═╝  ╚═╝ ╚═════╝╚═╝╚══════╝╚═╝   ╚═╝   ╚═╝  ╚═╝   ╚═╝    ╚═════╝ ╚═╝  ╚═╝
    

🚀 System Status

Network celo (Chain ID: 42220)
USDC Contract 0xcebA9300f2b948710d2653dD7B07f33A8B32118C
Database 🟢 Connected (Supabase)
Deferred Payments 🟢 Enabled (x402 PR #426)
Deep Link Polling 🟢 Enabled
Self Protocol 🟢 Enabled (proof-of-unique-human)

📡 Standard x402 Endpoints

GET/supported
Returns supported payment schemes (exact, deferred)
POST/verify
Verify x402 payment payload
POST/settle
Settle verified payment on-chain (EIP-3009)

💎 Deferred Payment Endpoints x402 PR #426

POST/deferred/verify
Verify and store off-chain voucher (99% gas savings)
POST/deferred/settle
Aggregate and settle vouchers on-chain
GET/deferred/balance/:payee
Get accumulated unsettled balance

🔐 Self Protocol Endpoints

POST/verify-celo
Verify Celo payment + Self proof (tiered pricing)
POST/api/verify
Self QR verification endpoint (deep link callback)
GET/verify-status/:sessionId
Poll verification status (mobile-first flow)

🛠️ System Endpoints

GET/health
Health check with network info (JSON)

🔌 Quick Integration Guide

Connect any API service to this facilitator in 3 simple steps:

📦 Step 1: Install Framework
npm install selfx402-framework
⚙️ Step 2: Configure Facilitator URL
// src/config/x402.ts
export const x402Config = {
  network: "celo",
  facilitatorUrl: "https://facilitator.selfx402.xyz",
  paymentPrice: "0.001", // $0.001 for verified humans
  walletAddress: process.env.PAYMENT_WALLET_ADDRESS
};
🛡️ Step 3: Add Payment Middleware
import { celoPaymentMiddleware } from "selfx402-framework/middleware";

const paymentMiddleware = celoPaymentMiddleware({
  facilitatorUrl: x402Config.facilitatorUrl,
  network: x402Config.network,
  paymentPrice: x402Config.paymentPrice,
  walletAddress: x402Config.walletAddress,
  enableSelfProtocol: true, // Enable proof-of-unique-human
});

// Apply to protected routes
app.get("/api/protected", paymentMiddleware, (req, res) => {
  const tier = req.tier; // "verified_human" | "unverified"
  res.json({ message: "Access granted!", tier });
});
✅ Step 4: Add Service Discovery (Optional but Recommended)
app.get("/.well-known/x402", (req, res) => {
  res.json({
    version: 1,
    facilitatorUrl: "https://facilitator.selfx402.xyz",
    payment: {
      network: "celo",
      asset: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
      payTo: x402Config.walletAddress,
    },
    verification: {
      enabled: true,
      requirements: {
        minimumAge: 18,
        excludedCountries: [], // ISO 3166-1 alpha-3
        ofac: false,
      },
      scope: "my-api-v1", // Unique identifier
    },
    pricing: {
      tiers: {
        unverified: { price: "1.00", description: "Bot pricing" },
        verified_human: { price: "0.001", description: "1000x cheaper" }
      }
    }
  });
});
🎉 That's it! Your API now accepts:
  • x402 micropayments (EIP-712 signatures)
  • Self Protocol verification (proof-of-unique-human)
  • Tiered pricing (bots pay 1000x more)
  • Deferred payments (99% gas savings)

📚 Resources & Documentation

📦 NPM: selfx402-framework
📦 Widget: selfx402-pay-widget
📖 Docs: GitHub Repository
🌐 Explorer: https://celoscan.io
🔗 x402: x402.gitbook.io
🔑 Self Protocol: docs.self.xyz

Built with ❤️ for the Self ZK Residency (Oct 14-31, 2025)

Self Protocol • x402 • Celo • TypeScript • Express • Supabase