SDK Reference

The OpenFacilitator SDK provides a type-safe way to interact with any x402-compatible facilitator.

Installation

npm install @openfacilitator/sdk

Quick Example

import { OpenFacilitator } from '@openfacilitator/sdk';
 
// Uses https://pay.openfacilitator.io by default
const facilitator = new OpenFacilitator();
 
// Verify payment
const verification = await facilitator.verify(payment, requirements);
 
// Settle payment
const settlement = await facilitator.settle(payment, requirements);
 
// Get supported networks
const supported = await facilitator.supported();

API Reference

MethodDescription
verify()Verify a payment is valid
settle()Settle/broadcast a payment
supported()Get supported networks
getFeePayer()Get Solana fee payer address
getFeePayerMap()Get all fee payers by network

Utilities

FunctionDescription
getNetwork()Get network info by ID
toV2NetworkId()Convert v1 to v2 network ID
toV1NetworkId()Convert v2 to v1 network ID

Error Handling

See Error Handling for details on error types and handling.