VerifyRequest,
VerifyResponse, SettleRequest, SettleResponse, and the compliance-pipeline
composer. Actual on-chain RPC calls, Chainalysis API invocations, and audit-event
writes live in apps/web. The HTTP endpoints are mounted from
app/api/x402/facilitator/{verify,settle}/route.ts.
F1 IRON RULE: The facilitator’s SettleResponse.txHash is the facilitator’s
claim, not verified fact. Operators MUST independently RPC-verify the on-chain
transaction before persisting it to any audit row. This package surfaces the
facilitator’s response verbatim and leaves the verification step to the consumer.
The reference implementation is the serverFetchChainTx dependency in the MCP
x402.pay tool.
Install
Two-phase protocol
x402 uses a verify-then-settle protocol:/verify— facilitator validates the off-chain EIP-712 payment payload and runs the compliance pipeline. Returns{isValid, invalidReason}without touching chain state./settle— facilitator broadcasts the on-chain transaction after a TOCTOU re-verify pass. Returns{success, txHash, network}.
handleVerify and handleSettle orchestrators implement this contract.
Settlement uses a store-before-broadcast pattern: a pending sentinel is written
before invoking broadcast so a process kill mid-broadcast does not re-broadcast
on replay.
API surface
Wiring the /verify route
Compliance pipeline
The pipeline is composable — each screener returns'allow' | 'block' | 'review'.
The first non-allow result short-circuits; 'review' is treated as block (conservative
posture).
Idempotency defense
The cache key is content-bound to defend against cross-tenant cache poisoning. An attacker who guesses a victim’s idempotency key also needs to match the exact(payTo, network, paymentPayload) triple:
Verify response invalidReason vocabulary
Reading list
- Money-safety contracts — the
F-rules, including F1 (server-side RPC verify) that governs
txHashhandling. @repo/connectors-coinbase-x402(workspace-internal — wraps@glideco/x402-facilitatorwith Coinbase CDP integration) — Coinbase CDP integration that wraps this facilitator for receiver-side flows.- Source on GitHub