Skip to main content
Configure x402 payments for your application after completing the buyer quickstart. Connect an existing client, choose payment schemes, enforce spend limits, and respond to payment lifecycle events.

Use CDP with an existing x402 client

Already have an x402Client built on @x402/core with your own key? Add a CDP-managed signer without migrating to CdpX402Client:
fromCdpEvmAccount has counterparts for other account types: fromCdpSmartWallet for a Smart Contract Wallet, and cdpSolanaAccountToSvmSigner for Solana. See x402DevMigration.ts for a runnable example.

Payment schemes

A scheme is the payment behavior a server asks for, such as charging a fixed amount. The server advertises what it accepts, and your client picks a matching registered scheme.
CdpX402Client registers exact and upto for you. batch-settlement is opt-in through its networkSchemes option. The upto scheme uses Permit2, but the CDP Facilitator sponsors that approval, so the buyer does not need to pay a network fee.For exact signatures and configuration, see the CDP SDK x402 reference.

Set spend limits

Spend controls enforce a client-side budget on top of what the server charges.
Spend is reserved before paying, then confirmed or rolled back once settlement is known. An ambiguous outcome remains reserved so the guardrail fails toward under-spending rather than over-spending. Blocked payments throw SpendControlError with a machine-readable code.See the full runnable version in payForApiWithSpendControls.ts.

Add onchain attribution

Builder Codes attribute the clients and intermediaries that create x402 payments. The CDP Facilitator records these codes in ERC-8021 Schema 2 calldata when it settles an EVM payment.
Pass your Builder Code to CdpX402Client:
Composite applications can pass an array to attribute multiple clients or middleware layers.
Each code must contain 1–32 lowercase letters, numbers, or underscores. Omit the option or extension to leave client attribution unset. See the builder-code specification for the attribution fields and protocol flow.

Lifecycle hooks

x402HTTPClient provides onPaymentRequired. Its underlying x402Client provides onBeforePaymentCreation, onAfterPaymentCreation, onPaymentCreationFailure, and onPaymentResponse. CdpX402Client inherits these hooks.