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.
To cover exact and upto on Base and Solana, pass getCdpDefaultSchemes():
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.

How each scheme moves money

exact moves an exact amount of money from the buyer to the seller.
x402 exact payment flow between a client, resource server, and facilitator

Configure non-default schemes

exact and upto are registered for Base and Solana. exact is the default for every route. To use upto, set it on the route:
Omitting networks expands the route to Base and Solana. Pass an explicit networks list to limit which networks the route accepts.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.

(Optional) Choose an exact payment flow

EVM and Solana exact support two payment flows:
Authorization is the default. The facilitator verifies the payment before your endpoint runs and settles it after the work succeeds.
Authorization payment flow, where the facilitator verifies before the endpoint runs and settles afterward
Set paymentFlow on an exact route to use Upfront:
Upfront reduces the risk of completing work without payment and, for long-running Solana endpoints, gas-price slippage before settlement. If the work fails, the client has already paid and you must handle the refund outside x402. Escrow deposits or locks funds before work and distributes or releases them afterward. It is defined by schemes such as EVM auth-capture and Solana upto; you cannot select it for a scheme that does not support it. See section 6.1, “Asset Transfer Methods and Payment Flow Models,” of the x402 specification for details.

Configure who receives payment

Configure an onchain address to receive payments. This can be a CDP custodial wallet, a CDP non-custodial wallet, Coinbase Prime, Coinbase Business, a Coinbase retail deposit address, or a wallet you custody yourself. You only need CDP_WALLET_SECRET if the SDK should provision an API Key Wallet to receive payments.
By default, createX402Server provisions an API Key Wallet, which requires CDP_WALLET_SECRET. Use payToConfig with type: "address" to receive at an address you already control, with no wallet secret:
To provision a Smart Contract Wallet instead:

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.

Handle pending settlements

Resource servers using the CDP SDK or the canonical x402 Foundation packages automatically retry once when the CDP Facilitator broadcasts a transaction but cannot confirm it within the synchronous settlement window. If you call the Facilitator API directly, or if the automatic retry remains pending, reconcile the original transaction before requesting another payment. See Settlement Pending and Reconciliation for the automatic SDK behavior and the manual procedure.