@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
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 ofReadonlyWalletAccount
features
: 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:
useCdpSolanaStandardWallet
detects accounts - Wallet Registration: Wallet is registered with wallet standard
- Ready State:
ready: true
indicates 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)
Contributing
This package is part of the CDP Frontend SDK. See this page for contributing guidelines.Functions
useCdpSolanaStandardWallet()
- Creates and registers a CdpSolanaWallet when accounts are available
- Returns a ready flag indicating when the wallet is instantiated and registered
- Returns the wallet instance for direct usage
- Handles cleanup/unregistration on unmount
Parameters
Parameter | Type | Description |
---|---|---|
config? | Config | Optional CDP configuration. If provided, will initialize the SDK. If omitted, assumes SDK is already initialized (e.g., via CDPHooksProvider). |
Returns
object
Object containing ready flag and wallet instance
ready
wallet
Example
useSolanaStandardWallets()
- Gets all wallets using getWallets().get()
- Listens for wallet registration/unregistration events
- Returns the complete list including the CDP wallet once registered
Returns
object
Object containing array of all registered wallets
wallets
Example
Classes
CdpWalletAccount
CDP Wallet Account implementation for Solana accounts. This class represents a Solana account within the CDP wallet ecosystem.Implements
WalletAccount
Accessors
address
Get Signature
Returns
string
The base58 encoded Solana address
Implementation of
publicKey
Get Signature
Returns
Uint8Array
<ArrayBuffer
>
A copy of the public key bytes
Implementation of
chains
Get Signature
Returns
readonly ["solana:mainnet"
, "solana:devnet"
]
Array of supported Solana chains
Implementation of
features
Get Signature
Returns
readonly ["solana:signAndSendTransaction"
, "solana:signTransaction"
, "solana:signMessage"
]
Array of supported wallet standard features
Implementation of
Constructors
Constructor
Parameters
Parameter | Type | Description |
---|---|---|
publicKey | Uint8Array | The public key bytes for this account (must be exactly 32 bytes for Solana) |
Returns
CdpWalletAccount
Throws
If publicKey is null, undefined, or not exactly 32 bytesCdpSolanaWallet
CDP Solana Wallet implementation for the Wallet Standard. This wallet integrates CDP’s embedded Solana accounts with the wallet standard ecosystem, allowing dapps to interact with CDP wallets through standardized interfaces.Implements
Wallet
Accessors
name
Get Signature
Returns
"CDP Solana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g2M2wxNi42NzMyLTE3LjQxOTgxYy4yNTctLjI2ODYyLjQyOC0uNjA0NjEuNDkyLS45NjY2OXMuMDE4LS43MzQ0Ny0uMTMyLTEuMDcxNDJjLS4xNTEtLjMzNjk1LS4zOTktLjYyMzc4NC0uNzE0LS44MjUyNTctLjMxNTYtLjIwMTQ3NC0uNjg0NS0uMzA4ODEwNTktMS4wNjE2LS4zMDg4MjNoLTc5LjAzNDNjLS41Mjk5LjAwMDg3ODQtMS4wNTM5LjEwNzY5OS0xLjUzOTcuMzEzODQ4LS40ODU3LjIwNjE1LS45MjI4LjUwNzIzOS0xLjI4NDMuODg0NjMybC0xNi42ODEzNzcgMTcuNDE5ODJjLS4yNTcwNDIuMjY4My0uNDI4MTAzMi42MDQtLjQ5MjIwNDUuOTY1Ni0uMDY0MTAxNC4zNjE3LS4wMTg0NTYxLjczMzguMTMxMzM3NSAxLjA3MDYuMTQ5Nzk0LjMzNjguMzk3MjI1LjYyMzYuNzExOTQ4LjgyNTQuMzE0NzI2LjIwMTguNjgzMDU2LjMwOTcgMS4wNTk4MjYuMzEwNnoiIGZpbGw9InVybCgjYSkiLz48L3N2Zz4="
The wallet icon as base64 data URI
Implementation of
chains
Get Signature
Returns
readonly ["solana:mainnet"
, "solana:devnet"
]
Array of supported Solana chains
Implementation of
version
Get Signature
Returns
"1.0.0"
The wallet standard version
Implementation of
accounts
Get Signature
Returns
ReadonlyWalletAccount
[]
Array of readonly wallet accounts
Implementation of
features
Get Signature
Returns
StandardConnectFeature
& StandardDisconnectFeature
& StandardEventsFeature
& SolanaSignAndSendTransactionFeature
& SolanaSignTransactionFeature
& SolanaSignMessageFeature
& CdpFeature
Wallet standard features supported by this wallet
Implementation of
Constructors
Constructor
Parameters
Parameter | Type | Description |
---|---|---|
solanaAddresses | string [] | Array of Solana addresses (base58 encoded) |
Returns
CdpSolanaWallet