Skip to main content

@coinbase/cdp-solana-standard-wallet

A React hook and wallet implementation that integrates CDP (Coinbase Developer Platform) embedded Solana wallets with the Wallet Standard.

Features

  • 🔗 Wallet Standard Integration - Works with any dapp that supports the wallet standard
  • 🔐 CDP Authentication - Uses CDP’s secure embedded wallet infrastructure
  • ⚛️ React Hooks - Easy-to-use hooks for React applications
  • 🎯 TypeScript Support - Full type safety with TypeScript
  • 🚀 Auto-Registration - Automatically registers with wallet standard ecosystem
  • 🔄 Event-Driven - Real-time updates via CDP auth state changes
  • 📱 Multi-Network - Supports both Solana mainnet and devnet

Installation

Peer Dependencies

Optional Dependencies

Depending on your usage pattern, you may also need:

Usage

Option 1: With CDPHooksProvider

Option 2: With CDPReactProvider

Option 3: Standalone Usage

Analytics Opt-Out

By default the SDK will emit usage analytics to help us improve the SDK. If you would like to opt-out, you can do so by setting the disableAnalytics configuration option to true.
Or if you’re using the standalone usage, you can pass the disableAnalytics configuration option to the hook:

Using All Standard Wallets

Direct Wallet Usage

API Reference

useCdpSolanaStandardWallet(config?)

Hook that manages CDP Solana wallet creation and registration. Parameters:
  • config (optional): CDP configuration object with projectId
Returns:

useSolanaStandardWallets()

Hook that returns all registered Solana wallets in the wallet standard. Returns:

CdpSolanaWallet

The wallet implementation that integrates with CDP. Properties:
  • name: “CDP Solana Wallet”
  • icon: Solana logo as base64 data URI
  • chains: ['solana:mainnet', 'solana:devnet']
  • accounts: Array of ReadonlyWalletAccount
  • features: Supported wallet standard features
Supported Features:
  • standard:connect - Connect to the wallet
  • standard:disconnect - Disconnect from the wallet
  • standard:events - Listen for wallet events
  • solana:signTransaction - Sign transactions
  • solana:signAndSendTransaction - Sign and send transactions
  • solana:signMessage - Sign arbitrary messages
  • cdp: - CDP-specific feature flag

Authentication Flow

  1. User Authentication: User signs in via CDP (email/SMS OTP)
  2. Wallet Creation: CDP creates embedded Solana accounts
  3. Hook Activation: useCdpSolanaStandardWallet detects accounts
  4. Wallet Registration: Wallet is registered with wallet standard
  5. Ready State: ready: true indicates wallet is available
  6. Dapp Integration: Dapps can discover and use the wallet

Network Support

  • Mainnet: solana:mainnet → CDP network: solana
  • Devnet: solana:devnet → CDP network: solana-devnet

Error Handling

The hooks handle various error scenarios gracefully:
  • Unauthenticated User: ready: false, wallet: null
  • No Solana Accounts: ready: false, wallet: null
  • CDP Initialization Failure: Logs error, ready: false
  • Network Errors: Individual operations throw descriptive errors

Security

  • All cryptographic operations performed by CDP’s secure infrastructure
  • Private keys never exposed to application code
  • Authentication handled via CDP’s secure auth flow
  • Wallet disconnect clears wallet accounts but does not sign out user (maintains session)