Skip to content

Settlement Strategies

tollbooth uses a pluggable settlement system to verify and collect payments. By default it delegates to a remote facilitator, but you can swap in a different strategy depending on your needs — from zero-config hosted settlement to fully self-sovereign on-chain verification.

Delegates payment verification and on-chain settlement to an x402 facilitator service. The default facilitator is https://x402.org/facilitator.

# Optional — this is the default behavior
facilitator: https://x402.org/facilitator

The facilitator verifies the payer’s EIP-712 signature, submits the USDC transferWithAuthorization transaction on-chain, and sponsors gas so you don’t need to hold ETH.

When to use: production deployments where you want zero infrastructure overhead. Works out of the box with no wallets, RPC nodes, or gas management.

Tradeoff: depends on a third-party service for settlement.

Uses Circle’s Nanopayments Gateway for gas-free, sub-cent USDC transfers with batched on-chain settlement. Instead of settling each payment individually on-chain, Circle’s Gateway batches multiple TransferWithAuthorization signatures into periodic settlements — making payments as small as $0.000001 economically viable.

settlement:
strategy: nanopayments
network: testnet # "testnet" (default) or "mainnet"

Under the hood, the nanopayments strategy:

  1. Clients sign against Circle’s GatewayWalletBatched EIP-712 domain (instead of the standard per-token domain)
  2. tollbooth forwards the signed payment to Circle Gateway’s /v1/x402/verify and /v1/x402/settle endpoints — the same verify/settle pattern as the facilitator strategy
  3. Circle Gateway batches these authorizations and settles them on-chain periodically

The verifyingContract address is automatically discovered from Circle Gateway’s /v1/x402/supported endpoint at startup and included in 402 responses so clients sign against the correct contract.

Supported networks: Base, Ethereum, Arbitrum, Optimism, Polygon, Avalanche (mainnets and testnets).

When to use: high-frequency micropayment use cases like AI agent billing, per-request API pricing, or any scenario where individual on-chain settlement per request would be too expensive. Ideal for sub-cent payments.

Tradeoff: settlement is batched and asynchronous — funds don’t arrive instantly on-chain like with the facilitator. Depends on Circle’s Gateway infrastructure.

You can also point to a custom Circle Gateway URL instead of the built-in testnet/mainnet URLs:

settlement:
strategy: nanopayments
url: https://my-gateway.example.com

For more details on Circle Nanopayments, see the Circle Nanopayments documentation.

Uses the Machine Payments Protocol to support multiple payment methods through a single gateway — stablecoins via the tempo method and fiat card payments via Stripe. MPP is backwards-compatible with x402 and on the IETF standardization track.

settlement:
strategy: mpp
methods:
- type: tempo # stablecoins via x402 facilitator
- type: stripe # fiat card payments
secretKey: "${STRIPE_SECRET_KEY}"

When using the mpp strategy, tollbooth advertises payment options via standard WWW-Authenticate: Payment headers alongside payment-required, and accepts credentials via Authorization: Payment alongside payment-signature. This means both x402 and MPP clients work seamlessly.

When to use: you want to accept fiat card payments alongside stablecoins, or need compatibility with MPP-native agents.

Tradeoff: Stripe method requires a Stripe account. Tempo method has the same tradeoffs as the facilitator strategy.

For the full MPP guide, see MPP (Machine Payments Protocol).

Settles x402 payments on Tempo through an x402 facilitator that supports Tempo. It adds subscription-style routes (price: "$10/month"), per-customer attribution, and invoice memos.

settlement:
strategy: tempo
tempo:
url: "${TEMPO_FACILITATOR_URL}" # required: no default Tempo facilitator
recipient: "0xYourMerchantAddress"
recurring:
interval: monthly
memo:
invoice_id: "{customer_id}-{period}"

When to use: billing on Tempo where you want each settlement tagged with a customer and an invoice reference, or monthly-style access to an API.

Tradeoff: you need a facilitator that supports Tempo. Memos and attribution are tollbooth metadata (logs, hooks, receipts), not on-chain data.

For the full guide, see Tempo Settlement.

The built-in facilitator covers most use cases, but you can go further when you need more control.

OpenFacilitator is the open-source facilitator that powers x402.org/facilitator. You can self-host it and point tollbooth at your own instance:

facilitator: https://facilitator.yourdomain.com

This gives you full control over the settlement service — your own logs, your own uptime, your own infrastructure — while keeping the same facilitator protocol tollbooth already speaks.

You can also override the facilitator per-route:

facilitator: https://primary-facilitator.example.com
routes:
"POST /ai/claude":
upstream: anthropic
path: "/v1/messages"
price: "$0.075"
facilitator: https://backup-facilitator.example.com

Skip the facilitator entirely and settle payments directly from tollbooth. This means verifying EIP-712 signatures locally and submitting transactions via viem to an RPC endpoint.

Requirements:

  • A gas wallet with ETH to pay for on-chain transactions
  • An RPC endpoint (Alchemy, Infura, or your own node)

Tradeoff: you manage gas and RPC infrastructure, but remove all third-party dependencies. Settlement is fully self-sovereign.

For settlement logic that doesn’t fit the facilitator model, implement the SettlementStrategy interface. This lets you handle payment verification however you want — off-chain ledgers, subscription checks, free tiers, or hybrid approaches.

import type { SettlementStrategy } from "x402-tollbooth";
const myStrategy: SettlementStrategy = {
async verify(payment, requirements) {
// Validate the payment against the requirements
// Return a SettlementVerification, e.g. { payer: "0x..." }
},
async settle(verification) {
// Execute the settlement using the verification result
// Return a SettlementInfo: { payer, amount, transaction, network }
},
};
export default myStrategy;

Example use cases:

  • Free tier — verify an API key and skip settlement for free-tier users
  • Subscription check — validate against a Stripe subscription instead of per-request payment
  • Off-chain ledger — debit from a prepaid balance in your database
  • Hybrid — use the facilitator for on-chain payments but fall back to a ledger for known customers
StrategyInfra neededSpeedSettlementUse case
facilitatorNone~200 msImmediate on-chainProduction default
nanopaymentsNone~200 msBatched (async)Sub-cent micropayments, AI agents
mppStripe account (optional)~200 msImmediateUniversal agent payments (stablecoins + fiat)
tempoTempo-capable facilitatorDepends on facilitatorImmediate on-chainTempo billing with attribution, memos, monthly access
local (future)Gas wallet + RPC~2–5 sImmediate on-chainFull self-sovereignty
CustomVariesVariesVariesFree tiers, subscriptions, hybrid

The settlement strategy (which service settles) is separate from settlement timing (when settlement happens relative to the upstream request). tollbooth supports two timing modes:

  • before-response (default) — settle before calling the upstream
  • after-response — settle only after the upstream responds successfully

Settlement timing applies to any strategy. See the Refund Protection guide for details on configuring timing and writing custom refund hooks.


Next: Dynamic Pricing →