@dexterai/x402
@dexterai/x402 is Dexter's full-stack x402 SDK.
It is the package you use when you want to:
- protect an API endpoint with x402 payments
- make x402 payments from Node.js scripts
- make x402 payments from browser apps
- add payment-aware React UI flows
- use Access Pass instead of signing every request
- implement dynamic or token-based pricing
When To Use It
Use @dexterai/x402 when you are building:
- a paid API
- a wallet-connected browser app
- a React application that needs payment state
- a client that should handle
402 Payment Requiredautomatically - an endpoint that needs dynamic or usage-based pricing
Do not use this package when your main goal is:
- OpenClaw-native agent payments: use
@dexterai/clawdexter - local stdio discovery/payment for editor or CLI agents: use
@dexterai/opendexter
Install
What It Exports
The published package currently exports:
@dexterai/x402/client@dexterai/x402/server@dexterai/x402/react@dexterai/x402/adapters@dexterai/x402/utils
Which Surface To Use
client
Use @dexterai/x402/client when you need payment-aware fetch behavior.
The main entry points documented in the source README are:
wrapFetchcreateX402ClientcreateKeypairWallet
Use wrapFetch for Node.js scripts and server-side callers.
Use createX402Client for browser or wallet-connected environments.
server
Use @dexterai/x402/server when you are protecting endpoints or building seller infrastructure.
Main server surfaces documented in the package source:
x402Middlewarex402AccessPasscreateX402ServercreateDynamicPricingcreateTokenPricing
react
Use @dexterai/x402/react when you want hook-based payment state in a React app.
Main React surfaces:
useX402PaymentuseAccessPass
adapters
Use @dexterai/x402/adapters when you need lower-level chain adapter control.
Examples listed in the source README:
createSolanaAdaptercreateEvmAdapter
utils
Use @dexterai/x402/utils for amount conversion helpers.
Examples listed in the source README:
toAtomicUnitsfromAtomicUnits
Minimal Paths
Fastest buyer path: Node.js client
Fastest browser path
Fastest seller path
Supported Networks
The package source README explicitly documents verified support for:
- Solana Mainnet
- Base Mainnet
The package metadata and docs in this repo also position the SDK around:
- Polygon
- Arbitrum
- Optimism
- Avalanche
For exact current chain support and facilitator behavior, use:
What The SDK Covers
The source README and this docs section together confirm coverage for:
- automatic 402 handling
- client fetch wrappers
- browser wallet flows
- React hooks
- Express middleware
- Access Pass
- dynamic pricing
- token pricing
- facilitator-based settlement
Common Failure Modes
Wrong wallet context
The client needs a compatible wallet for a chain the endpoint accepts.
Missing funds
The payment flow cannot complete if the configured wallet is not funded with USDC on the accepted chain.
Choosing the wrong surface
Use:
wrapFetchfor Node scriptscreateX402Clientfor browser appsuseX402Paymentfor React UIx402Middlewarefor protected endpointsx402AccessPasswhen repeated reads should not require repeated signing
Needing package-level detail but starting in the wrong page
If you are here for one specific implementation path, jump directly to the specialized subpages below.