Skip to main content
Route Gateway payments through your existing x402 facilitator alongside standard onchain payments. Connected sellers gain gas-free batched settlement without changing seller-side code.
This guide is for infrastructure providers and payment processors running x402 facilitators.

Prerequisites

Before you begin, ensure that you’ve:
  • Built an x402 facilitator service using @x402/core.
  • Installed Node.js v18+.
  • Familiarized yourself with the x402 protocol and how facilitators verify and settle payments.

Steps

1

Install the SDK

Install @circle-fin/x402-batching alongside its required peer dependencies:
2

Add a Gateway client for verification, settlement, and discovery

The BatchFacilitatorClient handles all communication with Circle Gateway, including verification using the Verify x402 Payment API endpoint, settlement using the Settle x402 Payment API endpoint, and supported-network discovery using the Get Supported x402 Payment Kinds API endpoint. See the SDK reference for the full BatchFacilitatorClient API.
3

Route payments by type

Your facilitator acts as a router. Use isBatchPayment() to detect Gateway payments and delegate them to the BatchFacilitatorClient. Route all other payments to your existing onchain logic.Gateway payments are identified by the extra metadata field: extra.name === "GatewayWalletBatched".
Gateway’s settle() endpoint is optimized for low latency and guarantees settlement. Use settle() directly rather than calling verify() followed by settle() in production flows.
For background on how Gateway batches payments, see How batched settlement works.
4

Wire up HTTP endpoints

Expose your routing logic through standard x402 facilitator endpoints:
5

Connect sellers to your facilitator

Once your facilitator supports Gateway, sellers connect to it and automatically gain access to both standard and gas-free payment options. Sellers new to the Gateway middleware can start from the seller quickstart.Sellers connect using one of two setups.
Sellers using x402ResourceServer connect to your facilitator with HTTPFacilitatorClient:

Alternative: gas-free-only facilitator

If you are building a new facilitator that only needs to support gas-free payments (without standard onchain settlement), use BatchFacilitatorClient directly with x402ResourceServer:

Preserve Gateway signing metadata

When using x402ResourceServer with BatchFacilitatorClient, register GatewayEvmScheme to ensure payment requirements include the metadata that Gateway clients need for EIP-712 signing. GatewayEvmScheme extends the standard ExactEvmScheme to:
  • Preserve extra metadata (verifyingContract, name, version) in payment requirements
  • Set maxTimeoutSeconds to 604900 (7 days plus a small buffer) for batched settlement
  • Register USDC money parsers for all Gateway-supported networks
The base ExactEvmScheme discards the extra field from supported kinds when building payment requirements. Gateway clients require extra.verifyingContract to construct valid EIP-712 signatures. GatewayEvmScheme preserves this data.