Skip to main content
@rail402.dev/facilitator is the settlement engine the service runs. A resource server can run it in its own process and call it through inProcessClient, a stock x402 FacilitatorClient. Verification and settlement run the same checks with the same codes as over HTTP (stages 1 to 8 of Errors and verification rules), without the network hop. The HTTP request checks (stage 0) and the Bazaar are part of the service and are not included. The seller then holds a sponsor seed and pays its own settlement fees. Use this when you want no dependency on an external facilitator; otherwise point HTTPFacilitatorClient at a Rail402 instance.
The package runs on Node.js 24.11 or later. For durable settlement across processes, add @rail402.dev/store-postgres (see Options).

Example

An @x402/express seller that settles its own payments on testnet. The seller’s dependencies are the same as in the seller quickstart, plus @rail402.dev/facilitator:
server.ts
SPONSOR_SECRET is a funded testnet account (see Self-host with Docker for one way to create it), and PAY_TO an account with a USDC trustline. The stock buyer from the buyer quickstart pays this server unchanged.

Options

createStellarFacilitator({ networks, log }) takes one entry per network: The in-memory ledger and channel pool suit one process that can lose its state on restart. For durable, multi-process settlement, pass the Postgres stores the service itself uses, from @rail402.dev/store-postgres (PostgresSettlementLedger, PostgresChannelPool, createDatabase, migrate); see apps/rail402/src/runtime.ts for how the service wires them.

What you give up

  • Bazaar. Cataloging and discovery live in the Rail402 service, not in the facilitator package. An in-process facilitator does not catalog resources.
  • Operations. Readiness checks, metrics, rate limits and the sponsor balance polling are part of the service. Monitor the sponsor’s balance yourself, and run facilitator.reconcile() at startup and periodically, as the example does.