@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 thedisableAnalytics configuration option to true.
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 withprojectId
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 URIchains:['solana:mainnet', 'solana:devnet']accounts: Array ofReadonlyWalletAccountfeatures: Supported wallet standard features
standard:connect- Connect to the walletstandard:disconnect- Disconnect from the walletstandard:events- Listen for wallet eventssolana:signTransaction- Sign transactionssolana:signAndSendTransaction- Sign and send transactionssolana:signMessage- Sign arbitrary messagescdp:- CDP-specific feature flag
Authentication Flow
- User Authentication: User signs in via CDP (email/SMS OTP)
- Wallet Creation: CDP creates embedded Solana accounts
- Hook Activation:
useCdpSolanaStandardWalletdetects accounts - Wallet Registration: Wallet is registered with wallet standard
- Ready State:
ready: trueindicates wallet is available - 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)