Skip to main content

x402 Facilitator

Legacy: The x402 facilitator and @agentokratia/x402-escrow packages have not yet been migrated to the new AgentaOS branding. Package names, facilitator URLs, and API keys remain under the agentokratia namespace for now. This will be updated in a future release.
A production-ready x402 facilitator supporting both exact (USDC-only) and escrow (multi-token) 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
Input tokensUSDC onlyUSDC, WETH, DAI, USDT
Output tokenUSDCUSDC (swapped automatically)
Signatures1 per request1 per request
Gas for userNone (gasless)None (gasless)
Best forSimple USDC paymentsMulti-token flexibility

Detailed Scheme Comparison

Learn when to use each scheme

Who Is This For?


Quick Start

exact scheme (USDC only)

npm install @x402/core @x402/fetch @x402/evm viem
import { wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm/exact/client';
import { privateKeyToAccount } from 'viem/accounts';

const account = privateKeyToAccount(process.env.PRIVATE_KEY);

const client = new x402Client()
  .register('eip155:8453', new ExactEvmScheme(account));

const paidFetch = wrapFetchWithPayment(fetch, client);

// 402 responses handled automatically
const response = await paidFetch('https://api.example.com/premium');

escrow scheme (multi-token)

npm install @x402/core @x402/fetch @x402/evm @agentokratia/x402-escrow viem
import { wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm/exact/client';
import { createWalletClient, createPublicClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
import {
  EscrowScheme,
  createBalanceSelector,
  preferTokenPolicy,
} from '@agentokratia/x402-escrow/client';

const WETH = '0x4200000000000000000000000000000000000006';
const USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';

const account = privateKeyToAccount(process.env.PRIVATE_KEY);

const walletClient = createWalletClient({
  account, chain: base, transport: http(),
});

const publicClient = createPublicClient({
  chain: base, transport: http(),
});

// Balance-aware: auto-picks token you can afford
const client = new x402Client(
  createBalanceSelector(publicClient, account.address)
)
  .register('eip155:8453', new ExactEvmScheme(account))
  .register('eip155:8453', new EscrowScheme(walletClient))
  .registerPolicy(preferTokenPolicy([WETH, USDC]));

const paidFetch = wrapFetchWithPayment(fetch, client);

const response = await paidFetch('https://api.example.com/premium');

How It Works

exact scheme flow

escrow scheme flow (with swap)


Key Features

Gasless for Users

ERC-3009 and Permit2 signatures - no ETH needed

Multi-Token Support

Pay with WETH, DAI, USDT - receiver gets USDC

Automatic Swaps

DEX quotes from Uniswap, Paraswap, OpenOcean

Base Network

Low fees on Base L2 (mainnet + testnet)

Networks

NetworkStatusUse For
Base Mainnet✅ LiveProduction
Base Sepolia✅ LiveDevelopment & testing
Facilitator URL: https://facilitator.agentokratia.com

Supported Input Tokens (Base Mainnet)

TokenAddress
USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
WETH0x4200000000000000000000000000000000000006
DAI0x50c5725949a6f0c72e6c4a641f24049a917db0cb
USDT0xfde4c96c8593536e31f229ea8f37b2ada2699bb2

Next Steps