Skip to main content
This guide shows how to accept x402 payments for your API endpoints using Semantic’s facilitator on Plasma or Stable. By the end you’ll have an Express server that gates routes behind USD₮ payments.
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:
  1. A buyer hits your endpoint without a payment header
  2. Your middleware responds with 402 Payment Required and the payment terms
  3. The buyer’s x402 client signs an EIP-3009 authorization and retries
  4. Your middleware forwards the signed payload to Semantic’s facilitator
  5. The facilitator verifies the signature, settles on-chain, and confirms
  6. Your route handler runs and returns the resource
You never touch private keys, gas tokens, or on-chain transactions. You just specify the price and the address to receive funds.

Pricing

The price 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.
The 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

Plasma

eip155:9745 · 0xB8C...5ebb

Stable

eip155:988 · 0x779...3736
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 to paymentMiddleware maps routes to payment requirements. The key format is METHOD /path.
Routes not listed in the config are not gated — they behave like normal Express routes. This is why /health works without payment in the examples above.

Lifecycle events

The Semantic facilitator supports an optional X-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

Example: receiving events

Add a POST endpoint to your server:
Then configure the facilitator client to include the callback header. Since HTTPFacilitatorClient from @x402/core doesn’t support custom headers directly, wrap fetch:
With this in place, every /verify and /settle call to the facilitator will include the callback header, and your /payment-events endpoint will receive events like:
For the full event reference, see the Facilitator API docs.

Environment variables

Using with other frameworks

x402 also provides middleware for Hono and Next.js:
The pattern is the same: create a facilitator client, register the EVM scheme for your network(s), and apply middleware. See the x402 examples for framework-specific code.
Last modified on February 17, 2026