Skip to main content

Overview

The CDP SDK provides comprehensive support for managing EVM (Ethereum Virtual Machine) accounts on Ethereum-compatible blockchains. This includes both server-managed accounts and smart contract accounts.

Account Types

The SDK includes generated types for EVM accounts from the OpenAPI specification:
use cdp_sdk::types::{
    EvmAccount,
    EndUserEvmAccount,
    EndUserEvmSmartAccount,
};

Creating EVM Accounts

Create a Server-Managed Account

Create a new EVM account with optional parameters:
use cdp_sdk::{types, Client};

// Create account with a name
let body = types::CreateEvmAccountBody::builder()
    .name(Some("my-evm-account".parse()?));

let response = client
    .create_evm_account()
    .x_wallet_auth("") // Set by middleware
    .x_idempotency_key("unique-request-id")
    .body(body)
    .send()
    .await?;

let account = response.into_inner();
println!("Account address: {}", account.address);
println!("Account name: {:?}", account.name);

Create Request Parameters

name
Option<String>
Optional human-readable name for the account
x_idempotency_key
String
required
Unique key to ensure idempotent request handling (max 128 characters)
x_wallet_auth
String
required
Wallet authentication JWT (automatically added by WalletAuth middleware)

Retrieving EVM Accounts

Get Account by Address

Retrieve a specific account using its Ethereum address:
let response = client
    .get_evm_account()
    .address("0x1234567890123456789012345678901234567890")
    .send()
    .await?;

let account = response.into_inner();
println!("Account: {:?}", account);
address
String
required
The Ethereum address of the account (0x-prefixed hex string)

Get Account by Name

Retrieve an account using its assigned name:
let response = client
    .get_evm_account_by_name()
    .name("my-evm-account")
    .send()
    .await?;

let account = response.into_inner();
name
String
required
The name assigned to the account

Updating EVM Accounts

Update an existing account’s properties:
use cdp_sdk::types;

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();

Update Parameters

address
String
required
The Ethereum address of the account to update
name
Option<String>
New name for the account

Listing EVM Accounts

List all EVM accounts with pagination support:
let response = client
    .list_evm_accounts()
    .page_size(10)
    .page_token("next-page-token") // Optional
    .send()
    .await?;

let accounts_list = response.into_inner();
println!("Found {} accounts", accounts_list.accounts.len());

for account in accounts_list.accounts {
    println!("  - {} ({})", account.address, account.name.unwrap_or_default());
}

// Get next page if available
if let Some(next_token) = accounts_list.next_page_token {
    let next_response = client
        .list_evm_accounts()
        .page_size(10)
        .page_token(next_token)
        .send()
        .await?;
}

List Parameters

page_size
Option<i32>
Number of accounts to return per page (default: 50)
page_token
Option<String>
Token for retrieving the next page of results

EVM Smart Accounts

The SDK also supports EVM smart accounts (Account Abstraction):

Create Smart Account

use cdp_sdk::types;

let body = types::AddEndUserEvmSmartAccountBody::builder()
    .enable_spend_permissions(true);

let response = client
    .add_end_user_evm_smart_account()
    .user_id("user-123".parse()?)
    .x_wallet_auth("")
    .x_idempotency_key("unique-request-id")
    .body(body)
    .send()
    .await?;

let smart_account = response.into_inner().evm_smart_account;

Smart Account Parameters

enable_spend_permissions
bool
If true, enables spend permissions for the smart account (default: false)

Response Types

All EVM account responses include comprehensive account information:
address
String
The Ethereum address of the account
name
Option<String>
Optional human-readable name
created_at
DateTime
Timestamp when the account was created
updated_at
DateTime
Timestamp when the account was last updated

ABI Types

The SDK includes comprehensive ABI (Application Binary Interface) types for smart contract interactions:
use cdp_sdk::types::{
    Abi,
    AbiFunction,
    AbiParameter,
    AbiStateMutability,
};

ABI State Mutability

Pure
enum
Function doesn’t read or modify state
View
enum
Function only reads state (doesn’t modify)
Nonpayable
enum
Function modifies state but doesn’t accept Ether
Payable
enum
Function can receive Ether

Error Handling

Handle errors appropriately when working with EVM accounts:
match client.create_evm_account()
    .x_wallet_auth("")
    .x_idempotency_key("request-id")
    .body(body)
    .send()
    .await 
{
    Ok(response) => {
        let account = response.into_inner();
        println!("Success: {}", account.address);
    }
    Err(e) => {
        eprintln!("Failed to create account: {}", e);
    }
}

See Also

Build docs developers (and LLMs) love