Coinbase Developer Platform (CDP) Rust SDK
[!WARNING] This library is currently in alpha and unpublished, if you'd like to use it, you may specify
cdp-sdk
as a git dependency like so:[] = { = "https://github.com/coinbase/cdp-sdk" } = { = "1.0", = ["full"] }
Table of Contents
- CDP SDK
- Documentation
- Features
- Installation
- API Keys
- Usage
- Authentication Tools
- Development
- License
- Support
- Security
[!TIP]
If you're looking to contribute to the SDK, please see the Contributing Guide.
CDP SDK
This module contains the Rust CDP SDK, which is a library that provides a client for interacting with the Coinbase Developer Platform (CDP). It includes a CDP Client for interacting with EVM and Solana APIs to create accounts and send transactions, policy APIs to govern transaction permissions, as well as authentication tools for interacting directly with the CDP APIs.
Documentation
CDP SDK has auto-generated docs for the Rust SDK.
Further documentation is also available on the CDP docs website:
Features
- ๐ Automatic Authentication: Built-in JWT-based authentication with support for both API keys and wallet secrets
- ๐ Async/Await Support: Fully async API with Tokio runtime
- ๐ฆ Type-Safe: Generated OpenAPI client with full type safety
- ๐ Multi-Chain Support: EVM and Solana blockchain support
- ๐งช Trait-Based Architecture: Easy testing and mocking with comprehensive trait interfaces
Installation
[!WARNING] While this library is unpublished, if you'd like to use it, you must specify
cdp-sdk
as a git dependency.
Add this to your Cargo.toml
:
[]
= { = "https://github.com/coinbase/cdp-sdk" }
= { = "1.0", = ["full"] }
API Keys
To start, create a CDP API Key. Save the API Key ID
and API Key Secret
for use in the SDK. You will also need to create a wallet secret in the Portal to sign transactions.
Usage
Initialization
Load client config from shell
One option is to export your CDP API Key and Wallet Secret as environment variables:
Then, initialize the client:
use ;
use ClientBuilder;
async
Pass the API Key and Wallet Secret to the client
Another option is to directly pass the API Key and Wallet Secret to the client:
use ;
use ClientBuilder;
async
Creating EVM Accounts
Create a new EVM account:
use types;
// Create a new EVM account with a name
let body = builder
.name;
let response = client
.create_evm_account
.x_wallet_auth // Added by WalletAuth middleware
.x_idempotency_key
.body
.send
.await?;
let account = response.into_inner;
println!;
Retrieving EVM Accounts
Get account by address:
// Get an account by its address
let response = client
.get_evm_account
.address
.send
.await?;
let account = response.into_inner;
println!;
Get account by name:
// Get an account by its name
let response = client
.get_evm_account_by_name
.name
.send
.await?;
let account = response.into_inner;
println!;
Updating EVM Accounts
Update an existing EVM account:
use types;
// Update an account's name
let update_body = builder
.name;
let response = client
.update_evm_account
.address
.body
.send
.await?;
let updated_account = response.into_inner;
println!;
Listing EVM Accounts
List all EVM accounts:
// List all EVM accounts with pagination
let response = client
.list_evm_accounts
.page_size
.send
.await?;
let accounts_list = response.into_inner;
println!;
for account in accounts_list.accounts
Authentication Tools
This SDK also contains simple tools for authenticating REST API requests to the Coinbase Developer Platform (CDP). The authentication is handled automatically when using the high-level client, but you can access the underlying authentication mechanisms if needed.
Development
Building
Testing
Run all tests (unit + integration):
Run unit tests only:
Run end-to-end tests:
Linting
Fix linting issues:
Code Formatting
Documentation
Generate documentation:
Other Commands
Clean build artifacts:
Generate client from OpenAPI spec:
For a full list of available commands:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For feature requests, feedback, or questions, please reach out to us in the #cdp-sdk channel of the Coinbase Developer Platform Discord.
Security
If you discover a security vulnerability within this SDK, please see our Security Policy for disclosure information.