x402 Facilitator

Accept crypto payments on your API or website with zero integration complexity. This is an independent x402 facilitator — it handles payment verification and on-chain settlement so you don't have to. Status: ⏳ checking…

  • Only Optimism facilitator in the x402 ecosystem — if you sell on Optimism, this is your facilitator
  • 0.01 USDC flat fee per settlement — no percentage, no minimums
  • Community-first experiment — can we make a sustainable, independent facilitator work? Join us and find out
  • Open source, self-hostable, no vendor lock-in
  • Other chains on request — Base support is ready, more can be added if there is interest

Quick start

Three steps to accept x402 payments on your service:

1 Return a 402 response from your server

When a client requests a paid resource without payment, respond with HTTP 402 and your payment requirements. Replace 0xYourMerchantAddress with your wallet address and set amount to your price in USDC (6 decimals — 100000 = $0.10).

// HTTP 402 response body:
{
  "x402Version": 2,
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:10",
    "amount": "70000",
    "asset": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
    "payTo": "0xYourMerchantAddress",
    "maxTimeoutSeconds": 60,
    "extra": { "name": "USD Coin", "version": "2" }
  }],
  "facilitatorUrl": "https://facilitator.fretchen.eu"
}

2 Approve the facilitator for fee collection

The facilitator collects a 0.01 USDC fee per settlement via ERC-20 transferFrom. You need a one-time USDC approval. Connect your seller wallet below to check your current approval and set it:

Connect your wallet to check and manage your USDC approval for the facilitator.

3 Verify and settle payments

When a client sends a request with a PAYMENT-SIGNATURE header, verify the payment before delivering the resource, then settle it on-chain:

// 1. Verify payment (before delivering resource)
const verifyRes = await fetch("https://facilitator.fretchen.eu/verify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ x402Version: 2, scheme: "exact",
    network: "eip155:10", payload, details })
});
const { valid } = await verifyRes.json();
if (!valid) return new Response("Payment invalid", { status: 402 });

// 2. Deliver your resource
const result = await generateImage(prompt);

// 3. Settle payment (after successful delivery)
await fetch("https://facilitator.fretchen.eu/settle", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ x402Version: 2, scheme: "exact",
    network: "eip155:10", payload, details })
});

return new Response(JSON.stringify(result), { status: 200 });

That's it — your service now accepts crypto payments. See the agent onboarding guide for a complete walkthrough.

Fee model

The facilitator charges a flat 0.01 USDC per settlement, collected post-settlement via ERC-20 transferFrom. There is no percentage fee, no monthly minimum, no hidden costs.

Cost comparison

Your priceFacilitator feeEffective rateStripe (2.9% + $0.30)
$0.07$0.0114.3%impossible (below minimum)
$0.50$0.012.0%$0.31 (62.9%)
$1.00$0.011.0%$0.33 (32.9%)
$10.00$0.010.1%$0.59 (5.9%)

The flat-fee model is especially competitive for micropayments — exactly the range where traditional payment processors are prohibitively expensive or unavailable.

Fee Collection Flow

The fee amount and facilitator address are advertised in the /supported endpoint under the facilitator_fee extension.

How it works

x402 implements the long-dormant HTTP 402 Payment Required status code. A resource server (you) responds with payment requirements, the client signs a payment, and the facilitator handles verification and on-chain settlement.

x402 Payment Flow

Key properties:

  • Stateless — no accounts, sessions, or stored payment details
  • HTTP-native — uses standard headers and status codes
  • Machine-friendly — AI agents can pay autonomously
  • Micropayment-ready — sub-cent network fees on L2
  • Gasless for buyers — EIP-3009 authorization, facilitator submits the transaction

API reference

The facilitator at facilitator.fretchen.eu exposes three endpoints:

POST /verify

Validates a signed payment off-chain. Checks signature validity, sufficient balance, correct recipient, and expiration. Call this before delivering your resource.

curl -X POST https://facilitator.fretchen.eu/verify \
  -H "Content-Type: application/json" \
  -d '{
    "x402Version": 2,
    "scheme": "exact",
    "network": "eip155:10",
    "payload": "<base64-encoded-payment>",
    "details": {
      "scheme": "exact",
      "network": "eip155:10",
      "amount": "100000",
      "asset": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
      "payTo": "0xYourMerchantAddress"
    }
  }'

Response: { "valid": true } or { "valid": false, "invalidReason": "..." }

POST /settle

Executes the payment on-chain via EIP-3009 transferWithAuthorization. Call this after successful verification and resource delivery.

curl -X POST https://facilitator.fretchen.eu/settle \
  -H "Content-Type: application/json" \
  -d '{
    "x402Version": 2,
    "scheme": "exact",
    "network": "eip155:10",
    "payload": "<base64-encoded-payment>",
    "details": {
      "scheme": "exact",
      "network": "eip155:10",
      "amount": "100000",
      "asset": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
      "payTo": "0xYourMerchantAddress"
    }
  }'

Response: { "success": true, "txHash": "0x..." }

GET /supported

Returns supported networks, payment schemes, and fee configuration.

curl https://facilitator.fretchen.eu/supported

Returns a JSON object with kinds (supported network/scheme pairs), extensions (fee configuration), and signers (facilitator addresses per network).

Payment scheme

The facilitator supports the exact scheme with ERC-20 tokens (USDC) via EIP-3009 transferWithAuthorization. The buyer signs an off-chain authorization — no gas required from the buyer. The facilitator submits the transaction on-chain.

Full integration example

Buyer-side (TypeScript)

Using the official @x402/fetch SDK, a client can pay for any x402 resource automatically:

import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(`0x${PRIVATE_KEY}`);
const client = new x402Client();
registerExactEvmScheme(client, { signer });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);

// Payment is handled automatically on 402 response
const response = await fetchWithPayment(
  "https://imagegen-agent.fretchen.eu/genimg",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ prompt: "A futuristic cityscape" }),
  }
);

const result = await response.json();
console.log("Image:", result.imageUrl);
console.log("NFT:", result.tokenId);

Your server (resource server)

Full example of a Node.js endpoint protected by x402. Adapt the resource generation to your use case:

// Express / Node.js example
app.post("/api/resource", async (req, res) => {
  const paymentHeader = req.headers["payment-signature"];

  // No payment → return 402 with requirements
  if (!paymentHeader) {
    return res.status(402).json({
      x402Version: 2,
      accepts: [{
        scheme: "exact",
        network: "eip155:10",
        amount: "70000",  // 0.07 USDC
        asset: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
        payTo: "0xYourMerchantAddress",
        maxTimeoutSeconds: 60,
        extra: { name: "USD Coin", version: "2" }
      }],
      facilitatorUrl: "https://facilitator.fretchen.eu"
    });
  }

  // Verify payment
  const payload = paymentHeader;
  const details = { scheme: "exact", network: "eip155:10",
    amount: "70000",
    asset: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
    payTo: "0xYourMerchantAddress" };

  const verifyRes = await fetch("https://facilitator.fretchen.eu/verify", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ x402Version: 2, scheme: "exact",
      network: "eip155:10", payload, details })
  });

  const { valid, invalidReason } = await verifyRes.json();
  if (!valid) return res.status(402).json({ error: invalidReason });

  // Deliver resource
  const result = await generateYourResource(req.body);

  // Settle payment
  await fetch("https://facilitator.fretchen.eu/settle", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ x402Version: 2, scheme: "exact",
      network: "eip155:10", payload, details })
  });

  return res.json(result);
});

Supported networks

NetworkChain IDUSDC addressEnvironment
Optimismeip155:100x0b2C…Ff85Production
Baseeip155:84530x8335…2913Production
OP Sepoliaeip155:111554200x5fd8…30D7Testnet
Base Sepoliaeip155:845320x036C…CF7eTestnet

All wallets that support WalletConnect work — MetaMask, Coinbase Wallet, Rainbow, and others. Your customers need a small amount of USDC on any supported network.

What your customers experience

When a user interacts with your x402-protected service, the payment flow is invisible and instant:

  1. They make a request — your server responds with the price.
  2. Their wallet asks them to sign a payment authorization — no funds leave yet.
  3. The signed authorization is sent with the request.
  4. You deliver the resource.
  5. The payment settles on-chain — they receive the result.

Each payment is individually signed via EIP-3009. The authorization is bound to a specific amount, recipient, and expiration. The protocol never has blanket access to your customer's funds. See the AI Image Generator for a live example.

Links