Skip to main content

Coinbase Developer Platform (CDP) TypeScript SDK

Table of Contents

[!TIP] If you’re looking to contribute to the SDK, please see the Contributing Guide.

CDP SDK

This module contains the TypeScript CDP SDK, which is a library that provides a client for interacting with the Coinbase Developer Platform (CDP). It includes a CDP Client for interacting with EVM and Solana APIs to create accounts and send transactions, policy APIs to govern transaction permissions, as well as authentication tools for interacting directly with the CDP APIs.

Documentation

CDP SDK has auto-generated docs for the Typescript SDK. Further documentation is also available on the CDP docs website:

Installation

API Keys

To start, create a CDP API Key. Save the API Key ID and API Key Secret for use in the SDK. You will also need to create a wallet secret in the Portal to sign transactions. Most CDP API endpoints require API key credentials. Public (unauthenticated) endpoints can be called without credentials, and authenticated endpoints will raise a clear request-time error if credentials are missing.

Usage

Initialization

Load client config from shell

One option is to export your CDP API Key and Wallet Secret as environment variables:
Then, initialize the client:
If you are only calling public (unauthenticated) endpoints, constructing CdpClient without credentials is supported:

Load client config from .env file

Another option is to save your CDP API Key and Wallet Secret in a .env file:
Then, load the client config from the .env file:

Pass the API Key and Wallet Secret to the client

Another option is to directly pass the API Key and Wallet Secret to the client:

Client Lifecycle

The CDP client wraps an HTTP client (Axios) and should be created once and reused throughout your application’s lifecycle. The underlying HTTP client handles connection pooling automatically, so there’s no need to recreate the client per request—doing so would be less efficient.
  • Long-lived services: Create a single client instance at startup
  • Serverless/request-based runtimes: Create once per cold start, or use a module-level singleton
  • Concurrency: The client is safe to use across concurrent async operations

Creating EVM or Solana accounts

Create an EVM account as follows:

Import an EVM account as follows:

Create a Solana account as follows:

Import a Solana account as follows:

Exporting EVM or Solana accounts

Export an EVM account as follows:

Export a Solana account as follows:

Get or Create an EVM account as follows:

Get or Create a Solana account as follows:

Get or Create a Smart Account as follows:

Creating EVM or Solana accounts with policies

Create an EVM account with policy as follows:

Create a Solana account with policy as follows:

Updating EVM or Solana accounts

Update an EVM account as follows:

Update a Solana account as follows:

Testnet faucet

You can use the faucet function to request testnet ETH or SOL from the CDP.

Request testnet ETH as follows:

Request testnet SOL as follows:

Sending transactions

EVM

You can use CDP SDK to send transactions on EVM networks.
CDP SDK is fully viem-compatible, so you can optionally use a walletClient to send transactions.

Solana

You can use CDP SDK to send transactions on Solana. For complete examples, check out sendTransaction.ts, sendManyTransactions.ts, and sendManyBatchedTransactions.ts.
To have CDP sponsor the transaction fees, pass useCdpSponsor: true. When enabled, CDP pays the network fee so the sender does not need SOL for fees.

EIP-7702 delegation

You can create an EIP-7702 delegation for an existing EOA, upgrading it with smart account capabilities on supported networks. The delegated EOA can then use batched transactions and gas sponsorship via paymaster.
For a runnable example that includes faucet and receipt waiting, see examples/typescript/evm/eip7702/createEip7702Delegation.ts.

EVM Smart Accounts

For EVM, we support Smart Accounts which are account-abstraction (ERC-4337) accounts. Currently there is only support for Base Sepolia and Base Mainnet for Smart Accounts.

Create an EVM account and a smart account as follows:

Sending User Operations

In Base Sepolia, all user operations are gasless by default. If you’d like to specify a different paymaster, you can do so as follows:

EVM Swaps

You can use the CDP SDK to swap tokens on EVM networks using both regular accounts (EOAs) and smart accounts. The SDK provides three approaches for performing token swaps: The simplest approach for performing swaps. Creates and executes the swap in a single line of code: Regular Account (EOA):
Smart Account:

2. Get pricing information

Use getSwapPrice for quick price estimates and display purposes. This is ideal for showing exchange rates without committing to a swap:
Note: getSwapPrice does not reserve funds or signal commitment to swap, making it suitable for more frequent price updates with less strict rate limiting - although the data may be slightly less precise.

3. Create and execute separately

Use account.quoteSwap() / smartAccount.quoteSwap() when you need full control over the swap process. This returns complete transaction data for execution: Important: quoteSwap() signals a soft commitment to swap and may reserve funds on-chain. It is rate-limited more strictly than getSwapPrice to prevent abuse. Regular Account (EOA):
Smart Account:

When to use each approach:

  • All-in-one (account.swap() / smartAccount.swap()): Best for most use cases. Simple, handles everything automatically.
  • Price only (getSwapPrice): For displaying exchange rates, building price calculators, or checking liquidity without executing. Suitable when frequent price updates are needed - although the data may be slightly less precise.
  • Create then execute (account.quoteSwap() / smartAccount.quoteSwap()): When you need to inspect swap details, implement custom logic, or handle complex scenarios before execution. Note: May reserve funds on-chain and is more strictly rate-limited.

Key differences between Regular Accounts (EOAs) and Smart Accounts:

  • Regular accounts (EOAs) return transactionHash and execute immediately on-chain
  • Smart accounts return userOpHash and execute via user operations with optional gas sponsorship through paymasters
  • Smart accounts require an owner account for signing operations
  • Smart accounts support batch operations and advanced account abstraction features
All approaches handle Permit2 signatures automatically for ERC20 token swaps. Make sure tokens have proper allowances set for the Permit2 contract before swapping.

Example implementations

To help you get started with token swaps in your application, we provide the following fully-working examples demonstrating different scenarios: Regular account (EOA) swap examples: Smart account swap examples: BYO wallet (viem) regular account (EOA) swap examples: BYO wallet (viem + account abstraction) smart account swap examples: Note: The viem smart account examples require additional dependencies (permissionless package) and external service setup (bundler, optional paymaster). For simpler smart account usage, consider CDP’s built-in smart account features instead.

Transferring tokens

EVM

For complete examples, check out evm/account.transfer.ts and evm/smartAccount.transfer.ts. You can transfer tokens between accounts using the transfer function:
You can then wait for the transaction receipt with a viem Public Client:
Smart Accounts also have a transfer function:
One difference is that the transfer function returns the user operation hash, which is different from the transaction hash. You can use the returned user operation hash in a call to waitForUserOperation to get the result of the transaction:
Using Smart Accounts, you can also specify a paymaster URL:
Transfer amount must be passed as a bigint. To convert common tokens from whole units, you can use utilities such as parseEther and parseUnits from viem.
You can pass usdc or eth as the token to transfer, or you can pass a contract address directly:
You can also pass another account as the to parameter:

Solana

For complete examples, check out solana/account.transfer.ts. You can transfer tokens between accounts using the transfer function:
You can also easily send USDC:
If you want to use your own RPC client, you can pass one to the network parameter:

Account Actions

Account objects have actions that can be used to interact with the account. These can be used in place of the cdp client.

EVM account actions

Here are some examples for actions on EVM accounts. For example, instead of:
You can use the listTokenBalances action:
EvmAccount supports the following actions:
  • listTokenBalances
  • requestFaucet
  • signTransaction
  • sendTransaction
  • transfer
EvmSmartAccount supports the following actions:
  • listTokenBalances
  • requestFaucet
  • sendUserOperation
  • waitForUserOperation
  • getUserOperation
  • transfer

Solana account actions

Here are some examples for actions on Solana accounts.
You can use the signMessage action:
SolanaAccount supports the following actions:
  • requestFaucet
  • signMessage
  • signTransaction

Policy Management

You can use the policies SDK to manage sets of rules that govern the behavior of accounts and projects, such as enforce allowlists and denylists.

Create a Project-level policy that applies to all accounts

This policy will accept any account sending less than a specific amount of ETH to a specific address.

Create an Account-level policy

This policy will accept any transaction with a value less than or equal to 1 ETH to a specific address.

Create a Solana Allowlist Policy

List Policies

You can filter by account:
You can also filter by project:

Retrieve a Policy

Update a Policy

This policy will update an existing policy to accept transactions to any address except one.

Delete a Policy

[!WARNING] Attempting to delete an account-level policy in-use by at least one account will fail.

Validate a Policy

If you’re integrating policy editing into your application, you may find it useful to validate policies ahead of time to provide a user with feedback. The CreatePolicyBodySchema and UpdatePolicyBodySchema can be used to get actionable structured information about any issues with a policy. Read more about handling ZodErrors.

Supported Policy Rules

We currently support the following policy rules: Server wallet rules: End user rules:
  • SignEndUserEvmTransactionRule — operation: signEndUserEvmTransaction (criteria: ethValue, evmAddress, evmData, netUSDChange)
  • SendEndUserEvmTransactionRule — operation: sendEndUserEvmTransaction (criteria: ethValue, evmAddress, evmNetwork, evmData, netUSDChange)
  • SignEndUserEvmMessageRule — operation: signEndUserEvmMessage (criteria: evmMessage)
  • SignEndUserEvmTypedDataRule — operation: signEndUserEvmTypedData (criteria: evmTypedDataField, evmTypedDataVerifyingContract)
  • SignEndUserSolTransactionRule — operation: signEndUserSolTransaction (criteria: solAddress, solValue, splAddress, splValue, mintAddress, solData, programId)
  • SendEndUserSolTransactionRule — operation: sendEndUserSolTransaction (criteria: solAddress, solValue, splAddress, splValue, mintAddress, solData, programId, solNetwork)
  • SignEndUserSolMessageRule — operation: signEndUserSolMessage (criteria: solMessage)
End user rules use the same criteria types as their server wallet counterparts. For example, signEndUserEvmTransaction supports the same ethValue, evmAddress, and evmData criteria as signEvmTransaction.

End User Policies

You can create policies that govern end-user operations using the same criteria types available for server wallet policies. The only difference is the operation value, which targets end-user-specific actions.

End User EVM Policy

This policy restricts end-user EVM transaction signing to a max value and allowlisted recipients — the same criteria used in signEvmTransaction:

End User Solana Policy

This policy restricts end-user Solana transaction signing to allowlisted recipients under a SOL value threshold — the same criteria used in signSolTransaction:
For a comprehensive example demonstrating all 7 end-user operations, see createEndUserPolicy.ts.

End-user Management

You can use the End User SDK to manage the users of your applications.

Create End User

You can create an end user with authentication methods and optionally create EVM and Solana accounts for them.

Import End User

You can import an existing private key for an end user:
You can also import a Solana private key:

Add EVM Account to End User

Add an additional EVM EOA (Externally Owned Account) to an existing end user. You can call the method directly on the EndUser object:

Add EVM Smart Account to End User

Add an EVM smart account to an existing end user:

Add Solana Account to End User

Add an additional Solana account to an existing end user:

Validate Access Token

When your end user has signed in with an Embedded Wallet, you can check whether the access token they were granted is valid, and which of your user’s it is associated with.

Delegated Signing Operations

When an end user has granted a delegation, you can sign and send transactions on their behalf using the cdp.endUser client methods or directly on the EndUserAccount object. All delegated operations are available both as client methods (passing userId explicitly) and as convenience methods on the EndUserAccount object (where userId is automatically bound and address defaults to the first account if not specified).

Revoke Delegation

Revoke all active delegations for an end user:
For a complete example, see end-users/revokeDelegation.ts.

EVM Signing

Sign an EVM Transaction

Sign an EVM Message (EIP-191)

Sign EVM Typed Data (EIP-712)

EVM Sending

Send an EVM Transaction

For a complete example, see end-users/sendEvmTransaction.ts.

Send an EVM Asset

Send tokens (e.g. USDC) on behalf of an end user:
For a complete example, see end-users/sendEvmAsset.ts.

Send a User Operation (Smart Account)

Send a user operation via an end user’s smart account:
For a complete example, see end-users/sendUserOperation.ts.

EVM EIP-7702 Delegation

Create an EIP-7702 delegation on behalf of an end user, upgrading their EOA with smart account capabilities:
For a complete example, see end-users/createEvmEip7702Delegation.ts.

Solana Signing

Sign a Solana Message

For a complete example, see end-users/signSolanaMessage.ts.

Sign a Solana Transaction

Solana Sending

Send a Solana Transaction

Send a Solana Asset

x402 Payment Protocol

x402 is an open payment protocol that lets clients pay for HTTP requests using the 402 Payment Required status code. The SDK ships x402 support in the @coinbase/cdp-sdk/x402 subpath, which builds on top of the @x402 packages:
  • Payment client (CdpX402Client) — pay for x402-protected APIs with a CDP-managed wallet
  • Spend controls — SDK-managed guardrails (per-payment caps, cumulative caps, allowlists) for autonomous agents
  • Resource server (createX402Server) — add x402 payment gating to your HTTP endpoints
  • Facilitator (createCdpFacilitatorClient) — the CDP-hosted payment facilitator for verifying and settling payments
  • Signer adapters (fromCdpEvmAccount, fromCdpSmartWallet, cdpSolanaAccountToSvmSigner) — bridge CDP accounts into an existing @x402 setup
  • Direct signing (signX402Payment) — sign a payment payload with a CDP account without an HTTP round-trip
All entry points resolve CDP_API_KEY_ID, CDP_API_KEY_SECRET, and (where a wallet is required) CDP_WALLET_SECRET from environment variables, and accept explicit overrides via config. See the x402 examples for complete, runnable programs. @x402/core, @x402/evm, @x402/extensions, and @x402/svm are optional peer dependencies — install the ones you need alongside @coinbase/cdp-sdk (e.g. npm install @x402/core @x402/evm @x402/svm) rather than expecting them to come along automatically. @x402/fetch isn’t used by the SDK itself, but pairs well with CdpX402Client if you want its wrapFetchWithPayment helper — install it separately if so.

Pay for an x402-protected API

CdpX402Client extends @x402/core’s x402Client and auto-provisions a CDP-managed wallet on the first payment. Pass it to wrapFetchWithPayment from @x402/fetch to transparently pay for 402-gated requests.
The wallet used for payment is managed internally (a CDP Server Wallet named "x402-client-wallet-1" by default). To find its address — for example, to fund it before paying — call getAddresses(), which provisions the wallet eagerly instead of waiting for the first payment:
By default the client uses a CDP Server Wallet (EOA). To pay from a CDP Smart Account instead, supply a walletConfig:

Apply spend controls

Attach spendControls to CdpX402Client to enforce per-payment and cumulative caps, restrict networks/assets/payees, and receive callbacks as spend approaches a limit. A blocked payment throws a SpendControlError with a machine-readable code.
Spend controls can also be applied to any @x402/core client directly via applySpendControls(client, controls). Provide a persistent SpendStore (via the store option) if you need the cumulative ledger to survive process restarts — the default store is in-memory.

Gate an HTTP endpoint

createX402Server provisions a receiver wallet and returns a server descriptor you can hand to an @x402 HTTP middleware (for example @x402/express).

Use the CDP-hosted facilitator

createCdpFacilitatorClient returns a CDP-authenticated HTTPFacilitatorClient that verifies and settles payments through the CDP-hosted facilitator. It is a drop-in replacement for a self-hosted facilitator and only needs API-key credentials (no wallet secret).

Use a CDP wallet with an existing x402 client

If you already have an @x402 client set up, use the signer adapters to sign with a CDP-managed account instead of a local private key.
Use fromCdpSmartWallet for a CDP Smart Account and cdpSolanaAccountToSvmSigner for a CDP Solana account.

Sign an x402 payment payload directly

CDP accounts can also sign x402 payment payloads directly. Direct signing is useful when the payment payload needs to travel over non-HTTP transports such as gRPC metadata, MCP tool results, queues, or batch jobs. Use signX402Payment(paymentRequired, acceptedIndex) on any CDP-managed EVM account, EVM smart account, or Solana account. paymentRequired is the x402 payment requirement object returned by a resource server. acceptedIndex selects which entry in paymentRequired.accepts to sign.
For smart accounts (supports the EIP-3009 exact flow only — smart accounts sign with an ERC-1271/ERC-6492 contract signature, so the Permit2-based upto scheme and exact requirements that use the Permit2 transfer method are not supported):
For Solana accounts, the same surface produces an exact SVM payment payload:

Webhooks

You can use the webhooks SDK to subscribe to on-chain and wallet events and receive notifications at a URL of your choice.

Create Subscription

Create a webhook subscription to receive event notifications:
The available wallet event types are:
  • wallet.transaction.created
  • wallet.transaction.broadcast
  • wallet.transaction.pending
  • wallet.transaction.replaced
  • wallet.transaction.confirmed
  • wallet.transaction.failed
  • wallet.transaction.signed
  • wallet.typed_data.signed
  • wallet.message.signed
  • wallet.hash.signed
  • wallet.delegation.created
  • wallet.delegation.revoked
For a complete working example, see webhooks/createWebhookSubscription.ts.

Authentication tools

This SDK also contains simple tools for authenticating REST API requests to the Coinbase Developer Platform (CDP). See the Auth README for more details.

Error Reporting

This SDK contains error reporting functionality that sends error events to CDP. If you would like to disable this behavior, you can set the DISABLE_CDP_ERROR_REPORTING environment variable to true.

Usage Tracking

This SDK contains usage tracking functionality that sends usage events to CDP. If you would like to disable this behavior, you can set the DISABLE_CDP_USAGE_TRACKING environment variable to true.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For feature requests, feedback, or questions, please reach out to us in the #cdp-sdk channel of the Coinbase Developer Platform Discord.

Security

If you discover a security vulnerability within this SDK, please see our Security Policy for disclosure information.

FAQ

Common errors and their solutions.

TypeScript compilation errors with generateJwt or moduleResolution

If you encounter TypeScript compilation errors when using the CDP SDK, particularly with generateJwt or import statements, you may need to update your TypeScript configuration. Error symptoms:
  • Type errors with generateJwt function
  • Module resolution errors
  • Import/export type mismatches
Solution: Update your tsconfig.json to use a modern module resolution strategy. Change moduleResolution from node to node16 or nodenext:
The CDP SDK is built as an ESM package and moduleResolution: "node16" or "nodenext" should be used for proper type resolution. The legacy "node" setting doesn’t correctly resolve ESM package exports.

AggregateError [ETIMEDOUT]

This is an issue in Node.js itself: https://github.com/nodejs/node/issues/54359. While the fix is implemented, the workaround is to set the environment variable:

Error [ERR_REQUIRE_ESM]: require() of ES modules is not supported.

Use Node v20.19.0 or higher. CDP SDK depends on jose v6, which ships only ESM. Jose supports CJS style imports in Node.js versions where the require(esm) feature is enabled by default (^20.19.0 || ^22.12.0 || >= 23.0.0). See here for more info.

Jest encountered an unexpected token

If you’re using Jest and see an error like this:
Add a file called jest.setup.ts next to your jest.config file with the following content:
Then, add the following line to your jest.config file:
x402 support for the CDP SDK. Import from @coinbase/cdp-sdk/x402 to access:
  • Resource server: createX402Server — add x402 payment gating to HTTP endpoints
  • Payment client: CdpX402Client — pay for x402-protected APIs
  • Facilitator: createCdpFacilitatorClient — CDP-hosted payment facilitator
  • Spend controls: guardrails for autonomous agents
  • Signer adapters: bridge CDP accounts into existing x402 setups

Quick start

Gate an endpoint

Pay for an x402-protected API

Use a CDP-managed wallet with an existing x402Client

Classes

Interfaces

CdpX402ServerConfig

Defined in: server.ts:264 Configuration for createX402Server(). All credential fields fall back to environment variables, so an empty object {} with a routes map is sufficient in most environments. Pass configPath to load routes (and optionally credentials) from a JSON file instead of specifying them inline.

Properties

apiKeyId?
Defined in: server.ts:269 CDP API key ID. Falls back to CDP_API_KEY_ID env var.
apiKeySecret?
Defined in: server.ts:274 CDP API key secret. Falls back to CDP_API_KEY_SECRET env var.
walletSecret?
Defined in: server.ts:280 CDP wallet secret used to provision the receiver wallet. Falls back to CDP_WALLET_SECRET env var. Not required when payToConfig.type is "address".
environment?
Defined in: server.ts:289 Deployment environment. Controls which networks are used by default.
  • "production" (default) — Base mainnet + Solana mainnet.
  • "development" — Base Sepolia + Solana Devnet.
Falls back to CDP_X402_SERVER_ENVIRONMENT env var.
payToConfig?
Defined in: server.ts:299 Receiver wallet / payTo configuration. Defaults to { type: "eoa" } which provisions a CDP Server Wallet (EOA) named "x402-receiver-wallet-1". Use { type: "address", evm: "0x...", solana: "..." } to provide your own addresses without provisioning a CDP wallet.
routes?
Defined in: server.ts:313 Payment-protected routes served by this server. Map of HTTP method + path pattern → route config. Keys use the "METHOD /path" convention, e.g. "GET /report". Each value is either:
  • A CdpRouteConfig — simplified format, just price + optional fields.
  • A RouteConfig — full x402 format with an accepts array/object.
Both formats can be mixed within the same map. May be omitted when configPath supplies the routes.
configPath?
Defined in: server.ts:335 Path to a JSON file whose fields are merged with this inline config. Inline config takes precedence over file config when both specify the same field. The file mirrors CdpX402ServerConfig (minus configPath).
Example
A full JSON Schema for the file lives at examples/typescript/x402/servers/express/x402.config.schema.json. Security: this file may carry credentials (apiKeySecret / walletSecret). Prefer environment variables for credentials and use the file for routes; if secrets are stored here, keep the file out of version control.

CdpRouteConfig

Defined in: server.ts:169 Simplified CDP-owned route configuration. Specifying just price (and optionally description / networks) is enough for most routes. createX402Server automatically expands this into the full x402 RouteConfig format with scheme, payTo, and maxTimeoutSeconds filled in. For routes that need fine-grained control (custom scheme, explicit payTo, etc.) pass a full x402 RouteConfig instead — both formats are accepted in the same routes map.

Properties

price
Defined in: server.ts:174 Payment amount required to access this route, e.g. "$0.01". Accepts any amount string supported by the x402 protocol.
description?
Defined in: server.ts:176 Human-readable description of what this route provides.
scheme?
Defined in: server.ts:186 Payment scheme to use for this route. Defaults to "exact". The "upto" and "batch-settlement" schemes are EVM-only — networks must not include Solana or other non-EVM chains when they are specified. When an EVM-only scheme is used without an explicit networks list the default falls back to the environment’s EVM networks (Base mainnet or Base Sepolia depending on environment).
networks?
Defined in: server.ts:193 CAIP-2 network identifiers for which the route accepts payments. Defaults to CDP_SERVER_DEFAULT_NETWORKS (Base mainnet + Solana mainnet) for the "exact" scheme, or CDP_SERVER_DEFAULT_EVM_NETWORKS (Base mainnet only) for "upto".
maxTimeoutSeconds?
Defined in: server.ts:198 Maximum seconds a payment token is valid before expiry. Defaults to 300 (5 minutes).
extensions?
Defined in: server.ts:206 Extension overrides for this route. All three CDP extensions (eip2612GasSponsoring, erc20ApprovalGasSponsoring, and bazaar) are injected automatically. Use this field to override the auto-generated Bazaar declaration with richer discovery metadata.

CdpSchemeRegistration

Defined in: server-extensions.ts:161 A scheme+network pair used to register payment schemes on an x402ResourceServer.

Properties

network
Defined in: server-extensions.ts:163 CAIP-2 network identifier, e.g. "eip155:*" or "solana:*".
server
Defined in: server-extensions.ts:165 Scheme server implementation for this network.

CdpX402ClientConfig

Defined in: client.ts:60 Configuration for CdpX402Client.

Properties

apiKeyId?
Defined in: client.ts:62 CDP API key ID. Falls back to CDP_API_KEY_ID env var.
apiKeySecret?
Defined in: client.ts:64 CDP API key secret. Falls back to CDP_API_KEY_SECRET env var.
walletSecret?
Defined in: client.ts:66 CDP wallet secret. Falls back to CDP_WALLET_SECRET env var.
walletConfig?
Defined in: client.ts:70 Wallet configuration. Defaults to { type: "eoa" }.
spendControls?
Defined in: client.ts:74 Optional SDK-managed spend controls.
rpcUrls?
Defined in: client.ts:87 JSON-RPC endpoints used for payment signing, keyed by CAIP-2 network identifier. Base and Base Sepolia already resolve an RPC automatically via the CDP-authenticated node endpoint, so no override is required for those. Every other network (Polygon, Arbitrum, World, etc.) has no default and must be supplied here to backfill optional EVM extension capabilities (for example, eip2612 gas-sponsoring enrichment). Falls back to CDP_X402_RPC_URLS env var (JSON object mapping CAIP-2 IDs to URL strings).

CdpX402WalletAddresses

Defined in: client.ts:276 Wallet addresses provisioned by a CdpX402Client.

Properties

evmAddress
Defined in: client.ts:278 EVM address (EOA or Smart Contract Wallet) used for payment signing.
svmAddress
Defined in: client.ts:280 Solana address used for payment signing.
ownerWallet?
Defined in: client.ts:282 Name of the owner EOA account backing a "smart" wallet, if configured.

CdpFacilitatorClientArgs

Defined in: facilitator.ts:114 Args for createCdpFacilitatorClient.

Properties

apiKeyId?
Defined in: facilitator.ts:118 CDP API key ID. Falls back to the CDP_API_KEY_ID environment variable.
apiKeySecret?
Defined in: facilitator.ts:122 CDP API key secret. Falls back to the CDP_API_KEY_SECRET environment variable.
baseUrl?
Defined in: facilitator.ts:139 Override the facilitator base URL. Defaults to the CDP production endpoint (https://api.cdp.coinbase.com/platform/v2/x402). The hostname and per-operation paths are derived from this URL, so JWT signing is automatically bound to the correct host and paths. Use this to point at a staging, canary, or local facilitator without changing any other configuration.
Example

SpendControlsRegistry

Defined in: guardrails/apply.ts:52 Settlement-aware finalization handlers attached to a client by applySpendControls.

Methods

confirm()
Defined in: guardrails/apply.ts:58 Mark a previously-created payment as settled on-chain.
Parameters
paymentPayload
PaymentPayload The payment payload to confirm.
Returns
Promise<void>
rollback()
Defined in: guardrails/apply.ts:64 Undo a previously-recorded provisional spend after the payment did not settle.
Parameters
paymentPayload
PaymentPayload The payment payload to roll back.
Returns
Promise<void>

SpendStore

Defined in: guardrails/types.ts:124 Storage interface for the spend ledger. The default implementation is in-memory and process-local. For production workloads where the cap must be enforced across restarts or replicas, implement this interface against a shared durable backend (Redis, Postgres, DynamoDB, etc.) and pass an instance via SpendControls.store.

Methods

size()?
Defined in: guardrails/types.ts:126
  • Optional: return the current entry count.
Returns
Promise<number>
load()
Defined in: guardrails/types.ts:128
  • Returns all entries currently held by the store.
Returns
Promise<SpendLedgerEntry[]>
append()
Defined in: guardrails/types.ts:130
  • Adds a single entry to the store.
Parameters
entry
SpendLedgerEntry
Returns
Promise<void>
prune()?
Defined in: guardrails/types.ts:132
  • Optional: drop entries older than olderThanMs.
Parameters
olderThanMs
number
Returns
Promise<void>
dropOldest()?
Defined in: guardrails/types.ts:134
  • Optional: drop the oldest n entries.
Parameters
n
number
Returns
Promise<void>
removeEntry()?
Defined in: guardrails/types.ts:136
  • Optional: remove a specific entry by its field values.
Parameters
entry
SpendLedgerEntry
Returns
Promise<void>

SpendTrackerOptions

Defined in: guardrails/spend-tracker.ts:17 Constructor options for SpendTracker.

Properties

maxLedgerEntries?
Defined in: guardrails/spend-tracker.ts:21 Maximum number of entries to hold. Defaults to DEFAULT_MAX_LEDGER_ENTRIES.
store?
Defined in: guardrails/spend-tracker.ts:25 Storage backend. Defaults to an in-memory array-backed store.

RecordSpendInput

Defined in: guardrails/spend-tracker.ts:31 Argument shape for SpendTracker.record.

Properties

atomicAmount
Defined in: guardrails/spend-tracker.ts:33
  • Payment amount in base units.
asset
Defined in: guardrails/spend-tracker.ts:35
  • Asset identifier.
network
Defined in: guardrails/spend-tracker.ts:37
  • Network the payment was made on.
payTo
Defined in: guardrails/spend-tracker.ts:39
  • Payee address.

TotalSpendQuery

Defined in: guardrails/spend-tracker.ts:45 Argument shape for SpendTracker.total.

Properties

asset
Defined in: guardrails/spend-tracker.ts:47
  • Asset to sum.
since?
Defined in: guardrails/spend-tracker.ts:49
  • Inclusive lower bound (ms since epoch). Entries strictly older are excluded.

CdpSmartAccount

Defined in: account-signers.ts:39 The subset of a CDP Smart Account (EvmSmartAccount) required to sign x402 payments. Its signTypedData mirrors the SDK smart-account signature, which requires a network derived from the EIP-712 domain’s chainId.

Properties

address
Defined in: account-signers.ts:40

Methods

signTypedData()
Defined in: account-signers.ts:41
Parameters
options
Omit<SignTypedDataOptions, "address"> & { network: string; }
Returns
Promise<`0x${string}`>

CdpSolanaAccount

Defined in: account-signers.ts:97 Minimal interface for a CDP Solana account. Matches the relevant methods from CdpClient’s SolanaAccount.

Properties

address
Defined in: account-signers.ts:98

Methods

signTransaction()
Defined in: account-signers.ts:99
Parameters
options
transaction
string
Returns
Promise<{ signedTransaction: string; }>

Type Aliases

Variables

Functions