Skip to main content
The CDP SDK provides comprehensive examples demonstrating how to use the SDK across TypeScript, Python, Rust, and Go. These examples show you how to build real applications with the SDK.

What You’ll Find

Our examples cover the full range of CDP SDK functionality:
  • Account Management - Create, import, export, and manage EVM and Solana accounts
  • Transactions - Sign and send transactions, handle user operations
  • Smart Accounts - Work with EIP-4337 smart accounts and user operations
  • Token Operations - Check balances, transfer tokens, swap assets
  • Policies - Create and manage spending limits and access controls
  • End User Management - Handle end user accounts and authentication
  • Network Integration - Work with multiple blockchain networks

Repository Structure

All examples are located in the CDP SDK repository under examples/:
examples/
├── typescript/     # TypeScript/Node.js examples
├── python/        # Python examples
├── rust/          # Rust examples
└── go/            # Go examples
Each language directory contains runnable examples organized by feature area (EVM, Solana, smart accounts, etc.).

Getting Started

Prerequisites

Before running any examples, you’ll need:
  1. CDP API Credentials - Get your API key and wallet secret from the CDP Portal
  2. Language Runtime - Install the appropriate runtime for your language:
    • TypeScript: Node.js 18+ and pnpm
    • Python: Python 3.9+ and uv
    • Rust: Rust 1.70+
    • Go: Go 1.21+

Configuration

All examples use environment variables for configuration:
.env
CDP_API_KEY_ID=your_api_key_id
CDP_API_KEY_SECRET=your_api_key_secret
CDP_WALLET_SECRET=your_wallet_secret
Each language directory contains a .env.example file. Copy it to .env and fill in your credentials:
cp .env.example .env
Never commit your .env file to version control. It contains sensitive credentials.

Quick Start by Language

TypeScript

Modern async/await patterns with full TypeScript support

Python

Pythonic async examples with type hints

Rust

Type-safe examples with async/await

Go

Idiomatic Go examples with goroutines

Common Patterns

Client Initialization

All examples start by initializing the CDP client with your credentials:
import { CdpClient } from "@coinbase/cdp-sdk";
import "dotenv/config";

const cdp = new CdpClient();

Account Creation

Creating accounts follows a consistent pattern:
const account = await cdp.evm.createAccount();
console.log("Created account:", account.address);

Example Categories

EVM Examples

Work with Ethereum and EVM-compatible chains:
  • Account creation and management
  • Transaction signing and sending
  • Smart contract interactions
  • Token transfers and swaps
  • Smart accounts (EIP-4337)

Solana Examples

Build on Solana:
  • Solana account management
  • Transaction and message signing
  • SPL token operations
  • Program interactions

Policy Examples

Implement access controls:
  • Spending limits
  • Allowlist/blocklist policies
  • Time-based restrictions
  • Custom policy rules

Integration Examples

Integrate with popular tools:
  • Viem integration (TypeScript)
  • Web3.py integration (Python)
  • Custom RPC providers

Testing with Testnets

Most examples are designed to work with testnets:
  • Base Sepolia - Primary testnet for EVM examples
  • Solana Devnet - Primary testnet for Solana examples
Many examples include faucet requests to fund test accounts automatically.
Testnet tokens have no real value. Use testnets for development and testing before moving to mainnet.

Running Examples

Each language has its own execution pattern:
pnpm tsx path/to/example.ts

Next Steps

Explore examples for your preferred language:

TypeScript Examples

Browse 100+ TypeScript examples

Python Examples

Explore Python SDK examples

Rust Examples

View Rust implementation examples

Go Examples

Check out Go SDK examples

Need Help?

If you encounter issues with the examples:

Build docs developers (and LLMs) love