Skip to main content
Use this guide to move beyond the seller quickstart defaults and configure your x402 server for production. Choose the sections relevant to your deployment.

Use CDP with an existing x402 server

Already have an x402 server? Add createCdpFacilitatorClient() for CDP settlement without migrating to createX402Server. It uses your CDP API key and secret.
This works with x402HTTPResourceServer and x402MCPResourceServer. See server.ts for a runnable example.

Choose your environment

createX402Server supports Base and Solana by default:
  • "development" uses testnets and test funds.
  • "production" uses mainnets and real funds.
Routes inherit this setting unless they list specific networks. Switching environment changes every inherited route:
To accept specific networks, list them on the route:
For the complete chain and token matrix, see the CDP Facilitator’s supported networks, tokens, and schemes.

Choose a payment scheme

A payment scheme defines when the amount is determined and how the payment settles:
  • exact charges a known price for a synchronous endpoint.
  • upto authorizes a maximum, then settles the amount used by a synchronous endpoint.
  • batch-settlement supports repeated, high-throughput payments by redeeming per-request commitments later in batches.
Use exact unless your endpoint requires usage-based pricing or payment channels.

Configure non-default schemes

exact is registered automatically and is the default for every route. To use upto, set it on the route:
Your handler must report the final amount. See the Express usage-based pricing example for the complete flow.batch-settlement requires the full x402 RouteConfig and direct scheme registration. See the x402 batch-settlement guide.

Configure who receives payment

By default, createX402Server provisions a CDP Server Wallet. Use payToConfig to provision a Smart Contract Wallet or receive payment at an address you provide:

Resolve the recipient dynamically

Use the full x402 route format when the receiving address depends on the request:

Accept other tokens

Routes can accept tokens other than USDC.
Use the full x402 RouteConfig to set the asset for each payment option. Check the CDP Facilitator’s supported networks and tokens first.

Add onchain attribution

Builder Codes attribute the application that exposed a paid endpoint. The CDP Facilitator records this code in ERC-8021 Schema 2 calldata when it settles an EVM payment.
Pass your Builder Code to createX402Server:
The server advertises the code on every EVM route. Solana-only routes are skipped because Builder Code attribution uses EVM calldata.
Each code must contain 1–32 lowercase letters, numbers, or underscores. Omit the option or extension to leave application attribution unset. See the builder-code specification for the attribution fields and protocol flow.

Lifecycle hooks

Use resource-server hooks for payment lifecycle events. Available hooks include onProtectedRequest, onBeforeVerify, onAfterVerify, onVerifyFailure, onBeforeSettle, onAfterSettle, onSettleFailure, and onVerifiedPaymentCanceled.