Skip to main content
@swader/x402facilitators bundles every public x402 facilitator (Polygon, Coinbase, Kamiyo, Questflow, and others) into a single package so your middleware can swap or load-balance providers with minimal code.
  • Import auto for automatic routing across healthy facilitators.
  • Import named facilitators (e.g., polygon, coinbase, thirdweb) for explicit routing or when you need to supply custom credentials.
  • Use discovery helpers to enumerate every resource a facilitator can serve, useful for LLM agents that need to list tools before calling them.
The package is pure TypeScript and mirrors the data shown on facilitators.x402.watch.

When to Use This Package

  • You are a seller and want your API to accept requests from multiple facilitators without hardcoding URLs.
  • You are a buyer or agent who needs the same code to work on Polygon Amoy today and on Base or Solana in the future.
  • You maintain an orchestrator or LLM agent registry and need to query facilitator metadata and discovery endpoints programmatically.
  • You have already completed the x402 Quickstart for Buyers or Sellers and now need production-ready facilitator management.

Install

bun add @swader/x402facilitators
# npm install @swader/x402facilitators
Tip for LLM agents: store the package name as x402facilitators and check package.json before reinstalling.

Multi-Facilitator Routing

import { paymentMiddleware } from "x402"; // pseudocode - use your client
import { auto } from "@swader/x402facilitators";

paymentMiddleware(address, resources, auto);
  • auto distributes requests across healthy facilitators, keeping your service online if one provider has downtime.
  • Agents can use this by routing all payment middleware through auto without any additional configuration.

Choose Explicit Facilitators

import {
  coinbase,
  questflow,
  polygon,
  thirdweb,
} from "@swader/x402facilitators";

paymentMiddleware(address, resources, polygon);

paymentMiddleware(address, resources, coinbase({
  apiKey: process.env.CDP_API_KEY!,
}));

paymentMiddleware(address, resources, thirdweb({
  secretKey: process.env.THIRDWEB_SECRET_KEY!,
}));
  • Each facilitator exports both the config function and a metadata object (e.g., coinbaseFacilitator) for use in dashboards.
  • Simple facilitators (polygon, payai, x402rs, etc.) return a plain { url } config and require no additional props.

Discover Facilitator Resources Programmatically

import {
  discoverableFacilitators,
  listAllFacilitatorResources,
  kamiyoDiscovery,
} from "@swader/x402facilitators";

const kamiyoResources = await listAllFacilitatorResources(kamiyoDiscovery);

const everything = await Promise.all(
  discoverableFacilitators.map(listAllFacilitatorResources)
);

console.log(everything.flat());
  • Call this before planning an autonomous workflow to enumerate every tool guarded by Kamiyo, Coinbase, Questflow, and others.
  • Cache the results. Discovery endpoints may rate-limit anonymous callers.

Next Steps

  • To use the Polygon-hosted facilitator directly, see Using the Polygon Facilitator.
  • If you have not yet wired up payments, start with the x402 Quickstart for Buyers, then add @swader/x402facilitators on top.
  • To contribute a new facilitator: fork the upstream repo, add src/facilitators/<name>.ts, export it from src/lists/all.ts, and run bun run build. The PR will publish to npm and appear on facilitators.x402.watch.
Reference: Swader/x402facilitators.