Follow these steps to get started:
- Get a CDP API key and wallet secret from the CDP Portal
- Fill in your API key and wallet secret in
.env.example, then runmv .env.example .env - In the root
typescript/folder, runpnpm install && pnpm build. You only need to do this once - In the
examples/typescriptfolder, runpnpm installto install the dependencies
To run an example, use pnpm tsx followed by the path to the example file, for example:
pnpm tsx evm/createAccount.tsExamples for paying for and gating x402-protected APIs with CDP-managed wallets live in x402/. See the x402 examples README for setup, funding, and environment variables.
x402/clients/payForApi.ts— pay for an x402-protected API with a CDP-managed wallet usingCdpX402Client.x402/clients/payForApiWithSpendControls.ts— the same flow with per-payment and cumulative spend caps, anallowedNetworksallowlist, and anonApproachingLimitcallback.x402/clients/x402DevMigration.ts— migrate from a self-managed private key to a CDP signer, shown two ways.x402/servers/express— an Express resource server that gates a paid route usingcreateX402Serverand the CDP-hosted facilitator.