import method and using a seed phrase.
Wallets can create new addresses, list their addresses, list their balances and transfer assets to other addresses or wallets.
Wallets are created on a specific network. Certain features are only available on certain networks. For example, faucets are only available on Base Sepolia and Ethereum Sepolia. Trades are only available on Base Mainnet.
Creating a Wallet
- Typescript
- Python
SDK DocumentationRefer to the Wallet class SDK docs for a full list of supported methods.A wallet starts with a single
defaultAddress. You can also create more addresses in the wallet, and list them:- Typescript
- Python
SDK Documentation
Securing a Wallet
There are two types of wallets that can be created using the CDP SDK, depending on how the private keys are managed: Coinbase-Managed (2-of-2) Wallets and Developer-Managed (1-of-1) Wallets. Developer-Managed wallets are best for rapid testing and prototyping, while Coinbase-Managed wallets are recommended for any production environments.Coinbase-Managed Wallets
Wallet API offers a state-of-the-art Multi-Party Computation (MPC) option that splits private keys into two shares between Coinbase and the developer, ensuring improved security. Even if a developer’s share of the private key is compromised, assets will not be at risk as long as the CDP API keys and account credentials remain secure. These Coinbase-Managed (2-of-2) wallets use the Server-Signer, a deployable component that simplifies key management and provides a secure way to sign transactions. For production applications requiring maximal security, we recommend using Coinbase-Managed Wallets.Developer-Managed Wallets
For Developer-Managed (1-of-1) Wallets, it is your responsibility as the developer to securely store the data required to re-instantiate your wallets. For example, you may choose to store this data in an encrypted database. As with any 1-of-1 wallet solution, losing access to the wallet could result in a loss of funds. The CDP SDK provides two key pieces of information to persist Developer-Managed (1-of-1) Wallets:- Seed: a 32-byte hexadecimal string. This seed is used to derive all of the private keys in the wallet and provides access to spend the assets in the wallet.
- Wallet ID: a string used to identify the wallet.
export method:
- Typescript
- Python
Persisting Locally
For convenience, we provide a method that stores the wallet seed to a local file that you specify.This is an insecure method of storing wallet seeds and should only be used for development purposes.
- Typescript
- Python
encrypt to true. Note that your CDP secret API key also serves as the encryption key
for the seed persisted locally. This is for development purposes only. In production, developers should use their own encryption mechanisms and not rely on CDP API keys, as they can be rotated.
To re-instantiate wallets with encrypted data, ensure that your SDK is configured with
the same API key when invoking save_seed! and load_seed.Re-instantiating a Wallet
The seed and the ID of the wallet are required to re-instantiate a wallet when a new session is started. This data is encapsulated in the export data of a wallet, which should be securely persisted by the developer. The following code demonstrates how to import the data required to re-instantiate a wallet.- Typescript
- Python
Hydrating a Wallet
Another method of re-instantiating a wallet is to “hydrate” it. Hydration consists of two parts:- Fetching the wallet from the server
- Setting the correct seed on the wallet
- Typescript
Hydrating Locally
- Typescript
- Python
If you used the If you set
saveSeed function to persist a wallet’s seed to a local file, then you can first fetch the
unhydrated wallet from the server, and then use the loadSeed method to re-instantiate the wallet.encrypt to true when calling saveSeed, ensure that your SDK is configured with the same API key
when calling loadSeed.Importing a Wallet
The CDP SDK allows you to import your own wallet via a mnemonic seed phrase, so that you can bring your existing wallets into the CDP ecosystem.- Easily import wallets from other tools: Use your BIP-39 mnemonic seed phrase to import your existing wallet (ie, from MetaMask, Coinbase Wallet app, etc.) into the CDP ecosystem, allowing you to create complex, programmatic, or agentic interactions.
- 1-of-1 (Developer-Managed) security: Your wallet’s seed and seed phrase will not leave your device.
- Typescript
- Python
- Export your wallet data (includes your
seedandwallet ID) to your desired storage medium. - Re-instantiate your wallet at any time using your exported wallet data, without needing to use your mnemonic seed phrase.
Retrieving Balances
To view the amount of assets held in a wallet, call the following:- Typescript
- Python
list method only returns balances for the top 20 assets supported by symbol. For other assets, use get as follows.
- Typescript
- Python
Creating webhook
You can create a webhook for the current wallet. The webhook allow you to receive real-time notifications of wallet activity directly to your application via a specified callback notification URL. By creating a webhook, you can monitor events related to all the addresses for a wallet. See Webhook page for more details on supported event types, event payload and supported networks.- Typescript
Exporting wallets to an external provider
API Wallets provide exportable private keys compatible with all major wallet providers, such as Coinbase Wallet and MetaMask. To export the private key for an address that can be imported into an external provider, use the following code snippet:- Typescript
- Python