Skip to main content
This example demonstrates integration using the Coinbase Developer Platform (CDP) SDK with MPC-based key management and x402 v2. Perfect for backend applications requiring enterprise-grade security.

Overview

The CDP SDK provides server-side wallet management without exposing private keys. Keys are secured with Multi-Party Computation (MPC) technology. This example works with x402 v2 for both Base and Solana networks.

Features

  • MPC-based key management - No private keys in your code
  • Base (EVM) and Solana (SVM) network support
  • Enterprise security - Built by Coinbase
  • Server-side wallets - Perfect for backends
  • Type-safe TypeScript

Prerequisites

  • Node.js 18+
  • Coinbase CDP API credentials (Get them here)
  • USDC balance on Base or Solana
  • Existing CDP wallet address (Base) or Solana account

Installation

Quick Start

1. Get CDP Credentials

  1. Visit Coinbase Developer Platform
  2. Create an API key
  3. Save your API Key ID and Secret
  4. Create a wallet and fund it with USDC on Base

2. Set Up Environment

Create a .env file:

3. Implement Base (EVM) Payment

Create base-send.ts:

4. Implement Solana (SVM) Payment

Create solana-send.ts:

5. Run the Example

For Base network:
For Solana network:

Expected Output

How It Works

  1. Initialize CDP: Create CDP client with API credentials
  2. Get Wallet: Retrieve existing wallet by address
  3. Export Key: Export private key for transaction signing
  4. Create Account: Convert to viem account format
  5. Wrap Axios: Add x402 payment interceptor
  6. Send Payment: Make payment request

Why CDP SDK?

Security Benefits

  • No Private Key Management: Keys secured with MPC
  • Enterprise Grade: Built by Coinbase
  • Compliance: Meets regulatory requirements
  • Audit Trail: Complete transaction history

Best For

  • Backend applications
  • Enterprise deployments
  • High-value transactions
  • Compliance-focused apps

Supported Platforms

Send payments to:

Error Handling

CDP Wallet Management

Creating a Wallet

Funding the Wallet

Transfer USDC to your wallet address on Base network before making payments.

Full Example Repository

View on GitHub → Includes:
  • Complete implementation
  • Environment setup
  • Configuration examples
  • Detailed README

Next Steps

Dependencies

Learn More