TypeScript SDK

x402.facilitator

Creates a facilitator for the x402 payment protocol. Use this with any x402 middleware to enable settling transactions with your thirdweb server wallet.

Example

import { facilitator } from "thirdweb/x402";
import { createThirdwebClient } from "thirdweb";
const client = createThirdwebClient({
secretKey: "your-secret-key",
});
const thirdwebX402Facilitator = facilitator({
client: client,
serverWalletAddress: "0x1234567890123456789012345678901234567890",
});
// add the facilitator to any x402 payment middleware
const middleware = paymentMiddleware(
"0x1234567890123456789012345678901234567890",
{
"/api/paywall": {
price: "$0.01",
network: "base-sepolia",
config: {
description: "Access to paid content",
},
},
},
thirdwebX402Facilitator,
);
function facilitator(
): FacilitatorConfig;

Parameters

The configuration for the facilitator

Type

let config: {
baseUrl?: string;
client: ThirdwebClient;
serverWalletAddress: string;
vaultAccessToken?: string;
};

Returns

let returnType: FacilitatorConfig;

a x402 compatible FacilitatorConfig