Skip to main content

x402 Facilitator

A production-ready x402 facilitator supporting both exact (per-request) and escrow (session-based) payment schemes.
What is x402? The HTTP 402 “Payment Required” status code, finally put to use. x402 is a protocol for API monetization using blockchain payments.

Two Payment Schemes

Quick Comparison

exactescrow
SignaturesEvery requestOnce per session
Gas costsPer requestOnce (session creation)
LatencyHigherInstant
Pre-depositNoYes (55-100)
Unused fundsN/A100% reclaimable
Best forInfrequent callsAI agents, high-frequency

Detailed Scheme Comparison

Learn when to use each scheme

Who Is This For?


Quick Start

exact scheme (per-request)

npm install @x402/core @x402/fetch wagmi viem
import { useWalletClient } from 'wagmi';
import { wrapFetchWithPayment } from '@x402/fetch';
import { x402Client } from '@x402/core/client';

// Get walletClient from wagmi (must have account + chain)
const { data: walletClient } = useWalletClient();

if (walletClient) {
  const x402 = new x402Client(walletClient);
  const paidFetch = wrapFetchWithPayment(fetch, x402);

  // User signs each request
  const response = await paidFetch('https://api.example.com/premium');
}

escrow scheme (session-based)

npm install @x402/core @agentokratia/x402-escrow viem
import { useWalletClient } from 'wagmi';
import { createEscrowFetch } from '@agentokratia/x402-escrow/client';

// Get walletClient from wagmi (must have account + chain)
const { data: walletClient } = useWalletClient();

if (walletClient) {
  const { fetch: escrowFetch } = createEscrowFetch(walletClient, {
    depositAmount: '10000000', // $10 USDC
  });

  // First call: signs once, creates session
  await escrowFetch('https://api.example.com/premium');

  // Subsequent calls: instant, no signature
  await escrowFetch('https://api.example.com/premium');
}

How It Works

exact scheme flow

escrow scheme flow


Key Features

Gasless for Users

ERC-3009 signatures - no ETH needed for gas

Non-Custodial

Escrow funds held in open-source smart contract

100% Reclaimable

Withdraw unused escrow funds anytime

Base Network

Low fees on Base L2 (mainnet + testnet)

Built on Commerce Payments Protocol

The escrow scheme is built on Base’s Commerce Payments Protocol - a production-grade payment infrastructure designed for high-volume commerce.

AuthCaptureEscrow Smart Contract

View the open-source smart contract on GitHub
The protocol implements a two-phase commit pattern (authorize → capture) that mirrors traditional payment systems:
OperationDescription
authorizeUser deposits funds into escrow (like a credit card hold)
captureFacilitator releases funds to receiver (partial captures supported)
voidCancel authorization, return all funds to user
reclaimUser retrieves uncaptured funds after expiry
refundReceiver returns previously captured funds
This architecture enables instant off-chain verification while maintaining on-chain security guarantees.

Networks

NetworkStatusUse For
Base SepoliaLiveDevelopment & testing
Base MainnetComing SoonProduction
Facilitator URL: https://facilitator.agentokratia.com

Next Steps