| Crates.io | cdp-sdk |
| lib.rs | cdp-sdk |
| version | 0.2.0 |
| created_at | 2025-09-03 19:40:06.48036+00 |
| updated_at | 2025-12-23 22:36:24.341674+00 |
| description | SDK for interacting with the Coinbase Developer Platform Wallet API |
| homepage | https://docs.cdp.coinbase.com/ |
| repository | https://github.com/coinbase/cdp-sdk |
| max_upload_size | |
| id | 1823094 |
| size | 2,773,699 |
[!TIP]
If you're looking to contribute to the SDK, please see the Contributing Guide.
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.
CDP SDK has auto-generated docs for the Rust SDK.
Further documentation is also available on the CDP docs website:
[!WARNING] While this library is unpublished, if you'd like to use it, you must specify
cdp-sdkas a git dependency.
Add this to your Cargo.toml:
[dependencies]
cdp-sdk = { git = "https://github.com/coinbase/cdp-sdk" }
tokio = { version = "1.0", features = ["full"] }
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.
One option is to export your CDP API Key and Wallet Secret as environment variables:
export CDP_API_KEY_ID="YOUR_API_KEY_ID"
export CDP_API_KEY_SECRET="YOUR_API_KEY_SECRET"
export CDP_WALLET_SECRET="YOUR_WALLET_SECRET"
Then, initialize the client:
use cdp_sdk::{auth::WalletAuth, Client, CDP_BASE_URL};
use reqwest_middleware::ClientBuilder;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the CDP client using environment variables
let wallet_auth = WalletAuth::builder().build()?;
let http_client = ClientBuilder::new(reqwest::Client::new())
.with(wallet_auth)
.build();
let client = Client::new_with_client(CDP_BASE_URL, http_client);
Ok(())
}
Another option is to directly pass the API Key and Wallet Secret to the client:
use cdp_sdk::{auth::WalletAuth, Client, CDP_BASE_URL};
use reqwest_middleware::ClientBuilder;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize with explicit credentials
let wallet_auth = WalletAuth::builder()
.api_key_id("your-api-key-id".to_string())
.api_key_secret("your-api-key-secret".to_string())
.wallet_secret("your-wallet-secret".to_string())
.build()?;
let http_client = ClientBuilder::new(reqwest::Client::new())
.with(wallet_auth)
.build();
let client = Client::new_with_client(CDP_BASE_URL, http_client);
Ok(())
}
Create a new EVM account:
use cdp_sdk::types;
// Create a new EVM account with a name
let body = types::CreateEvmAccountBody::builder()
.name(Some("my-evm-account".parse()?));
let response = client
.create_evm_account()
.x_wallet_auth("") // Added by WalletAuth middleware
.x_idempotency_key("unique-request-id")
.body(body)
.send()
.await?;
let account = response.into_inner();
println!("Created account: {:?}", account);
// Get an account by its address
let response = client
.get_evm_account()
.address("0x1234567890123456789012345678901234567890")
.send()
.await?;
let account = response.into_inner();
println!("Account: {:?}", account);
// Get an account by its name
let response = client
.get_evm_account_by_name()
.name("my-evm-account")
.send()
.await?;
let account = response.into_inner();
println!("Account: {:?}", account);
Update an existing EVM account:
use cdp_sdk::types;
// Update an account's name
let update_body = types::UpdateEvmAccountBody::builder()
.name(Some("updated-account-name".parse()?));
let response = client
.update_evm_account()
.address("0x1234567890123456789012345678901234567890")
.body(update_body)
.send()
.await?;
let updated_account = response.into_inner();
println!("Updated account: {:?}", updated_account);
List all EVM accounts:
// List all EVM accounts with pagination
let response = client
.list_evm_accounts()
.page_size(10)
.send()
.await?;
let accounts_list = response.into_inner();
println!("Found {} accounts", accounts_list.accounts.len());
for account in accounts_list.accounts {
println!("Account: {} - {:?}", account.address, account.name);
}
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.
make build
Run all tests (unit + integration):
make test
Run unit tests only:
make test-unit
Run end-to-end tests:
make test-e2e
make lint
Fix linting issues:
make lint-fix
make format
Generate documentation:
make docs
Clean build artifacts:
make clean
Generate client from OpenAPI spec:
make client
For a full list of available commands:
make help
This project is licensed under the MIT License - see the LICENSE file for details.
For feature requests, feedback, or questions, please reach out to us in the #cdp-sdk channel of the Coinbase Developer Platform Discord.
If you discover a security vulnerability within this SDK, please see our Security Policy for disclosure information.