Skip to main content

Overview

This Facilitator is provided by WTF Academy, currently focusing on stable support for BSC and USD1.

Quick integration (server)

import { X402Server } from "x402x-server";
import { Facilitator } from "x402x-facilitator";
import { createPublicClient, http } from "viem";
import { bsc } from "viem/chains";

const client = createPublicClient({ chain: bsc, transport: http() });
const facilitator = new Facilitator({
  recipientAddress: process.env.RECIPIENT_ADDRESS!,          // obtained from app.x402x.ai
  baseUrl: "https://facilitator.x402x.ai",                   // default: WTF Facilitator
});

const server = new X402Server({ client, facilitator });

Example: create and process a payment

// USD1 (BSC) example address (18 decimals)
const USD1 = "0x8d0D000Ee44948FC98c9B98A4FA4921476f08B0d";

// 1) Create payment requirements (auto-detect or specify paymentType)
const requirements = await server.createRequirements({
  asset: USD1,
  maxAmountRequired: "1000000000000000000", // 1 USD1
  description: "Premium API",
});

// 2) Process (parse → verify → settle)
const result = await server.process(req.headers["x-payment"] as string, requirements);
if (!result.success) return res.status(result.status).json(result.response);

// 3) Return the resource
return res.json({ data: "ok", payer: result.data.payer, txHash: result.data.txHash });

Query supported capabilities

const supported = await facilitator.supported();
// { kinds: ["eip3009","permit","permit2"], networks: ["bsc", ...] } (example)

Notes

  • Works only on BSC; the current token is USD1
  • Use an EIP-7702 recipient address (see: Payment Platform)
  • In production, prefer waitUntil: "confirmed" and record txHash