x402 SDK
@dexterai/x402 adds payments to HTTP requests. A service responds with its price, your client pays, and the request returns the service's result. You can use the SDK to buy data and other services from code, or to collect payments for an API you run.
- The client requests the resource.
- The API returns HTTP 402 and its payment requirements.
- The client authorizes payment and retries with its proof.
- The API asks the facilitator to verify and settle the payment.
- The facilitator returns the settlement result.
- After successful settlement, the API returns the resource and receipt.
Make Payments
Your code supplies a funded wallet and spending limits. Direct x402 payments work with a compatible wallet you control, independently of Dexter Account beta access.
- Pay From Node.js includes a complete script for buying a service with a
Solana keypair.
- For an app where a person approves payments through their browser wallet, follow Pay From a Browser.
Set Spending Limits before running repeated requests. Errors and Retries covers rejected payments and interrupted requests.
For service catalog search from an agent client or terminal, see OpenDexter.
Accept Payments
The seller middleware adds a price to an Express endpoint and verifies payment before your handler delivers the response. Choose the network, price, and receiving address for that endpoint.
Charge for an Endpoint walks through a working server. Once it is reachable, see how to submit a service to Indexter.
The Facilitator verifies payment authorizations and submits settlement. Its guide covers the public endpoint and network-specific configuration.
Use Track Settlement to match the response to its payment. For metered payments through a Vault-backed session, see Tabs.
Networks and Package
The guides identify the wallet and network each example uses. Networks and Packages lists chain identifiers and the SDK releases used by the examples. These examples use Node.js 22 or newer. The pinned SDK declares the Vault package as a peer dependency. Installing it requires no Vault account.
Last Updated: