---
name: Coinbase
description: Use when building onchain applications, creating and managing crypto wallets, executing transactions, trading assets, or integrating blockchain functionality into applications. Agents should reach for this skill when users need to interact with blockchain networks, manage digital assets, or build Web3 applications.
metadata:
    mintlify-proj: coinbase
    version: "1.0"
---

# Coinbase Developer Platform (CDP) Skill

## Product Summary

Coinbase Developer Platform (CDP) is a comprehensive suite of onchain crypto services that enables developers to build blockchain applications without managing complex infrastructure. It provides secure wallet management, transaction signing, token swaps, staking, and onchain data access through REST APIs and SDKs (Python, TypeScript). Key files: `.env` for credentials, `cdp_api_key.json` for API keys, `cdp_wallet_secret.txt` for wallet operations. CLI: `@coinbase/cdp-cli` for terminal access. Primary docs: https://docs.cdp.coinbase.com

## When to Use

Reach for this skill when:
- **Building onchain apps**: Creating Web3 applications that need wallet management, transactions, or smart contract interaction
- **Managing crypto wallets**: Creating accounts, signing transactions, or managing private keys securely
- **Trading and swaps**: Executing token swaps, price discovery, or programmatic trading
- **Staking operations**: Enabling users to stake cryptocurrencies across multiple protocols
- **Onchain data**: Querying token balances, transaction history, or blockchain data via SQL
- **AI agents**: Building autonomous agents that interact with blockchain networks
- **Payment integration**: Accepting crypto payments or enabling fiat-to-crypto onramps
- **Institutional operations**: Trading, custody, or settlement for enterprise users

## Quick Reference

### Authentication Types

| Key Type | Use Case | Exposure |
|----------|----------|----------|
| **Secret API Key** | Server-side REST API calls | Never expose; use environment variables |
| **Client API Key** | Client-side JSON-RPC calls | Safe to expose in frontend code |
| **Wallet Secret** | Sensitive wallet operations (signing, account creation) | Server-side only; rotate if compromised |
| **OAuth Client** | User login with Coinbase account | For "Sign in with Coinbase" flows |

### Key Algorithms

- **Ed25519** (default, recommended): Faster, newer, better security
- **ECDSA**: Required for Advanced Trade SDK and Coinbase App SDK

### Core Resources

| Resource | Purpose | Example |
|----------|---------|---------|
| **EVM Accounts** | Ethereum-compatible blockchain addresses | Create, sign transactions, manage across networks |
| **Solana Accounts** | Solana blockchain addresses | Create, sign, batch instructions |
| **Smart Accounts** | EIP-4337 accounts with advanced features | Gas sponsorship, spend permissions, batching |
| **Policies** | Transaction rules and restrictions | Approve/reject by value, address, or network |
| **Faucets** | Free testnet tokens | Request ETH on Base Sepolia, SOL on Devnet |

### Supported Networks

**EVM Testnets**: Base Sepolia, Ethereum Sepolia, Polygon Mumbai, Arbitrum Sepolia, Optimism Sepolia

**EVM Mainnets**: Base, Ethereum, Polygon, Arbitrum, Optimism

**Solana**: Devnet (testnet), Mainnet

### CLI Commands

```bash
# Authentication
cdp auth configure

# Account operations
cdp evm accounts create --name my-account
cdp evm accounts list
cdp evm accounts send --account-id <id> --to <address> --amount 0.1

# Solana
cdp solana accounts create --name sol-account
cdp solana accounts send --account-id <id> --to <address> --amount 1

# Data queries
cdp evm balances list --account-id <id>
cdp data sql "SELECT * FROM ethereum.core.fact_transactions LIMIT 10"

# Utilities
cdp util tx-decode <raw-tx>
cdp api evm accounts create --template
```

## Decision Guidance

### When to Use EVM vs Solana Accounts

| Scenario | Choose |
|----------|--------|
| Building on Ethereum, Base, Polygon, Arbitrum, Optimism | EVM Accounts |
| Building on Solana ecosystem | Solana Accounts |
| Need multi-network compatibility | EVM Accounts (work across all EVM chains) |
| Need transaction batching or gas sponsorship | Smart Accounts (EVM only) |
| Need simple transfers and swaps | Either (both supported) |

### When to Use Server Wallet vs Embedded Wallet

| Scenario | Choose |
|----------|--------|
| Backend/server-side wallet management | Server Wallet v2 |
| End-user wallets in web/mobile apps | Embedded Wallet |
| Automated trading or batch operations | Server Wallet v2 |
| User authentication required | Embedded Wallet |
| Multi-chain account management | Server Wallet v2 |

### When to Use REST API vs SDK

| Scenario | Choose |
|----------|--------|
| Building in Python or TypeScript | SDK (easier, type-safe) |
| Quick testing or ad-hoc operations | CLI or cURL |
| Language not supported by SDK | REST API |
| Need fine-grained control | REST API |
| Building AI agents | CLI with MCP server |

## Workflow

### 1. Set Up Authentication

1. **Create API credentials**: Go to https://portal.cdp.coinbase.com → API Keys → Create API Key
2. **Choose algorithm**: Select Ed25519 (default) unless using Advanced Trade SDK (requires ECDSA)
3. **Generate Wallet Secret**: Go to Server Wallet → Accounts → Generate Wallet Secret
4. **Store securely**: Use environment variables, never commit to version control
   ```bash
   export CDP_API_KEY_NAME="<key-id>"
   export CDP_API_KEY_PRIVATE_KEY="<private-key>"
   export CDP_WALLET_SECRET="<wallet-secret>"
   ```

### 2. Create an Account

**Using SDK (TypeScript)**:
```typescript
import { Coinbase } from "@coinbase/cdp-sdk";

const client = await Coinbase.configure({
  apiKeyName: process.env.CDP_API_KEY_NAME,
  privateKey: process.env.CDP_API_KEY_PRIVATE_KEY,
  walletSecret: process.env.CDP_WALLET_SECRET,
});

const wallet = await client.createWallet();
const account = wallet.getDefaultAccount();
console.log(`Account address: ${account.getAddress()}`);
```

**Using CLI**:
```bash
cdp auth configure
cdp evm accounts create --name my-account
```

### 3. Request Testnet Funds

```bash
# Using SDK
await account.faucet();

# Using CLI
cdp evm faucet --account-id <account-id>
```

### 4. Send a Transaction

**Using SDK**:
```typescript
const transfer = await account.transfer(amount, destinationAddress);
const result = await transfer.wait();
console.log(`Transaction: ${result.getTransactionHash()}`);
```

**Using CLI**:
```bash
cdp evm accounts send --account-id <id> --to <address> --amount 0.1
```

### 5. Verify and Monitor

- Check transaction on block explorer (link provided in response)
- Query balances: `cdp evm balances list --account-id <id>`
- Monitor with webhooks for production

## Common Gotchas

- **Never expose Secret API Keys**: Use environment variables, not hardcoded strings or downloaded files
- **Wallet Secret is required for signing**: Missing or incorrect Wallet Secret causes transaction failures
- **Ed25519 vs ECDSA mismatch**: Advanced Trade SDK and Coinbase App SDK only work with ECDSA keys; use Ed25519 for everything else
- **Testnet vs Mainnet confusion**: Base Sepolia is testnet; Base is mainnet. Funds don't transfer between them
- **Account scope in v1 vs v2**: v1 accounts are single-network; v2 accounts work across all EVM networks
- **Private key rotation**: v2 Server Wallet doesn't expose private keys; use Wallet Secret rotation for security
- **Gas sponsorship requires smart accounts**: Regular EOA accounts cannot sponsor gas; use Smart Accounts (EIP-4337)
- **Solana instruction batching**: Solana accounts support batching; EVM requires Smart Accounts for batching
- **Faucet rate limits**: Testnet faucets have daily limits; plan accordingly for testing
- **Webhook setup**: Native webhook support in Wallet API is coming; use Onchain Data Webhooks for now

## Verification Checklist

Before submitting work with CDP:

- [ ] API credentials are stored in environment variables, not hardcoded
- [ ] Wallet Secret is present and correct for sensitive operations
- [ ] Testing on testnet (Base Sepolia, Ethereum Sepolia, etc.) before mainnet
- [ ] Account creation succeeded and address is valid (0x... for EVM, base58 for Solana)
- [ ] Faucet request completed if using testnet funds
- [ ] Transaction hash is returned and can be verified on block explorer
- [ ] Balances queried to confirm transaction success
- [ ] Policies applied if transaction restrictions are needed
- [ ] Error handling implemented for network failures and rate limits
- [ ] Credentials rotated if exposed or compromised

## Resources

**Comprehensive navigation**: https://docs.cdp.coinbase.com/llms.txt

**Critical documentation**:
1. [CDP API v2 Authentication](/api-reference/v2/authentication) — How to authenticate and sign requests
2. [Server Wallet v2 Overview](/server-wallets/v2/introduction/welcome) — Wallet management, accounts, and security
3. [AgentKit Overview](/agent-kit/welcome) — Building AI agents with blockchain capabilities

---

> For additional documentation and navigation, see: https://docs.cdp.coinbase.com/llms.txt