See a full working demo at github.com/SemanticPay/x402-usdt0-demo
Install
How it works
Your server doesn’t handle payments directly. It delegates to Semantic’s facilitator:- A buyer hits your endpoint without a payment header
- Your middleware responds with
402 Payment Requiredand the payment terms - The buyer’s x402 client signs an EIP-3009 authorization and retries
- Your middleware forwards the signed payload to Semantic’s facilitator
- The facilitator verifies the signature, settles on-chain, and confirms
- Your route handler runs and returns the resource
Pricing
Theprice field is a structured object that tells the buyer exactly what token to pay, how much, and on which chain. USDT0 uses 6 decimals, so "1000" = $0.001.
extra fields are passed through to the buyer’s client for EIP-712 signature construction. name and version must match what the on-chain USDT0 contract expects.
USDT0 Deployments
Full deployment list at docs.usdt0.to.Minimal server (single chain)
Multi-chain server (Plasma + Stable)
Accept payments on both chains. The buyer’s client picks whichever network it has funds on.Route configuration
The first argument topaymentMiddleware maps routes to payment requirements. The key format is METHOD /path.
/health works without payment in the examples above.
Lifecycle events
The Semantic facilitator supports an optionalX-Event-Callback header on /verify and /settle requests. When provided, the facilitator POSTs real-time lifecycle events to that URL as verification and settlement happen. This is useful for building dashboards, logging pipelines, or payment flow visualizations.
Events are fire-and-forget and do not block the facilitator’s response. If the callback URL is unreachable, events are silently dropped. If no header is provided, no events are sent.
Event types
| Type | When | Key fields |
|---|---|---|
verify_started | Facilitator begins verifying the payment | details.network, details.checks |
verify_completed | Verification finished | details.isValid |
verify_failed | Verification threw an error | details.error |
settle_started | Facilitator is broadcasting the on-chain transaction | details.network |
settle_completed | Transaction confirmed on-chain | details.transactionHash |
settle_failed | Settlement threw an error | details.error |
Example: receiving events
Add a POST endpoint to your server:HTTPFacilitatorClient from @x402/core doesn’t support custom headers directly, wrap fetch:
/verify and /settle call to the facilitator will include the callback header, and your /payment-events endpoint will receive events like:
