cdp package¶
Subpackages¶
- cdp.auth package
- Subpackages
- Module contents
GetAuthHeadersOptions
GetAuthHeadersOptions.api_key_id
GetAuthHeadersOptions.api_key_secret
GetAuthHeadersOptions.audience
GetAuthHeadersOptions.expires_in
GetAuthHeadersOptions.model_config
GetAuthHeadersOptions.request_body
GetAuthHeadersOptions.request_host
GetAuthHeadersOptions.request_method
GetAuthHeadersOptions.request_path
GetAuthHeadersOptions.source
GetAuthHeadersOptions.source_version
GetAuthHeadersOptions.wallet_secret
GetWebSocketAuthHeadersOptions
JwtOptions
Urllib3AuthClient
Urllib3AuthClientOptions
WalletJwtOptions
generate_jwt()
generate_wallet_jwt()
get_auth_headers()
get_websocket_auth_headers()
- cdp.openapi_client package
- Subpackages
- cdp.openapi_client.api package
- Submodules
- cdp.openapi_client.api.evm_accounts_api module
- cdp.openapi_client.api.evm_smart_accounts_api module
- cdp.openapi_client.api.evm_swaps_api module
- cdp.openapi_client.api.evm_token_balances_api module
- cdp.openapi_client.api.faucets_api module
- cdp.openapi_client.api.payments_alpha_api module
- cdp.openapi_client.api.policy_engine_api module
- cdp.openapi_client.api.solana_accounts_api module
- Module contents
- cdp.openapi_client.models package
- Submodules
- cdp.openapi_client.models.abi_function module
- cdp.openapi_client.models.abi_inner module
- cdp.openapi_client.models.abi_input module
- cdp.openapi_client.models.abi_parameter module
- cdp.openapi_client.models.abi_state_mutability module
- cdp.openapi_client.models.common_swap_response module
- cdp.openapi_client.models.common_swap_response_fees module
- cdp.openapi_client.models.common_swap_response_issues module
- cdp.openapi_client.models.common_swap_response_issues_allowance module
- cdp.openapi_client.models.common_swap_response_issues_balance module
- cdp.openapi_client.models.create_evm_account_request module
- cdp.openapi_client.models.create_evm_smart_account_request module
- cdp.openapi_client.models.create_evm_swap_quote_request module
- cdp.openapi_client.models.create_payment_transfer_quote201_response module
- cdp.openapi_client.models.create_payment_transfer_quote_request module
- cdp.openapi_client.models.create_policy_request module
- cdp.openapi_client.models.create_solana_account_request module
- cdp.openapi_client.models.create_swap_quote_response module
- cdp.openapi_client.models.create_swap_quote_response_all_of_permit2 module
- cdp.openapi_client.models.create_swap_quote_response_all_of_transaction module
- cdp.openapi_client.models.create_swap_quote_response_wrapper module
- cdp.openapi_client.models.crypto_rail module
- cdp.openapi_client.models.crypto_rail_address module
- cdp.openapi_client.models.crypto_rail_networks_inner module
- cdp.openapi_client.models.eip712_domain module
- cdp.openapi_client.models.eip712_message module
- cdp.openapi_client.models.error module
- cdp.openapi_client.models.error_type module
- cdp.openapi_client.models.eth_value_criterion module
- cdp.openapi_client.models.evm_account module
- cdp.openapi_client.models.evm_address_criterion module
- cdp.openapi_client.models.evm_call module
- cdp.openapi_client.models.evm_data_condition module
- cdp.openapi_client.models.evm_data_condition_params_inner module
- cdp.openapi_client.models.evm_data_criterion module
- cdp.openapi_client.models.evm_data_criterion_abi module
- cdp.openapi_client.models.evm_data_parameter_condition module
- cdp.openapi_client.models.evm_data_parameter_condition_list module
- cdp.openapi_client.models.evm_message_criterion module
- cdp.openapi_client.models.evm_network_criterion module
- cdp.openapi_client.models.evm_smart_account module
- cdp.openapi_client.models.evm_swaps_network module
- cdp.openapi_client.models.evm_user_operation module
- cdp.openapi_client.models.export_evm_account200_response module
- cdp.openapi_client.models.export_evm_account_request module
- cdp.openapi_client.models.export_solana_account200_response module
- cdp.openapi_client.models.fee module
- cdp.openapi_client.models.get_swap_price_response module
- cdp.openapi_client.models.get_swap_price_response_wrapper module
- cdp.openapi_client.models.import_evm_account_request module
- cdp.openapi_client.models.known_abi_type module
- cdp.openapi_client.models.list_evm_accounts200_response module
- cdp.openapi_client.models.list_evm_smart_accounts200_response module
- cdp.openapi_client.models.list_evm_token_balances200_response module
- cdp.openapi_client.models.list_evm_token_balances_network module
- cdp.openapi_client.models.list_policies200_response module
- cdp.openapi_client.models.list_response module
- cdp.openapi_client.models.list_solana_accounts200_response module
- cdp.openapi_client.models.payment_method module
- cdp.openapi_client.models.payment_method_limits module
- cdp.openapi_client.models.payment_method_limits_source_limit module
- cdp.openapi_client.models.payment_method_limits_target_limit module
- cdp.openapi_client.models.payment_method_request module
- cdp.openapi_client.models.payment_rail_action module
- cdp.openapi_client.models.policy module
- cdp.openapi_client.models.prepare_user_operation_request module
- cdp.openapi_client.models.request_evm_faucet200_response module
- cdp.openapi_client.models.request_evm_faucet_request module
- cdp.openapi_client.models.request_solana_faucet200_response module
- cdp.openapi_client.models.request_solana_faucet_request module
- cdp.openapi_client.models.rule module
- cdp.openapi_client.models.send_evm_transaction200_response module
- cdp.openapi_client.models.send_evm_transaction_criteria_inner module
- cdp.openapi_client.models.send_evm_transaction_request module
- cdp.openapi_client.models.send_evm_transaction_rule module
- cdp.openapi_client.models.send_user_operation_request module
- cdp.openapi_client.models.sign_evm_hash200_response module
- cdp.openapi_client.models.sign_evm_hash_request module
- cdp.openapi_client.models.sign_evm_hash_rule module
- cdp.openapi_client.models.sign_evm_message200_response module
- cdp.openapi_client.models.sign_evm_message_criteria_inner module
- cdp.openapi_client.models.sign_evm_message_request module
- cdp.openapi_client.models.sign_evm_message_rule module
- cdp.openapi_client.models.sign_evm_transaction200_response module
- cdp.openapi_client.models.sign_evm_transaction_criteria_inner module
- cdp.openapi_client.models.sign_evm_transaction_request module
- cdp.openapi_client.models.sign_evm_transaction_rule module
- cdp.openapi_client.models.sign_evm_typed_data200_response module
- cdp.openapi_client.models.sign_sol_transaction_criteria_inner module
- cdp.openapi_client.models.sign_sol_transaction_rule module
- cdp.openapi_client.models.sign_solana_message200_response module
- cdp.openapi_client.models.sign_solana_message_request module
- cdp.openapi_client.models.sign_solana_transaction200_response module
- cdp.openapi_client.models.sign_solana_transaction_request module
- cdp.openapi_client.models.sol_address_criterion module
- cdp.openapi_client.models.solana_account module
- cdp.openapi_client.models.swap_unavailable_response module
- cdp.openapi_client.models.token module
- cdp.openapi_client.models.token_amount module
- cdp.openapi_client.models.token_balance module
- cdp.openapi_client.models.token_fee module
- cdp.openapi_client.models.transfer module
- cdp.openapi_client.models.transfer_source module
- cdp.openapi_client.models.transfer_target module
- cdp.openapi_client.models.update_evm_account_request module
- cdp.openapi_client.models.update_policy_request module
- cdp.openapi_client.models.update_solana_account_request module
- Module contents
- cdp.openapi_client.test package
- Submodules
- cdp.openapi_client.test.test_abi_function module
- cdp.openapi_client.test.test_abi_inner module
- cdp.openapi_client.test.test_abi_input module
- cdp.openapi_client.test.test_abi_parameter module
- cdp.openapi_client.test.test_abi_state_mutability module
- cdp.openapi_client.test.test_common_swap_response module
- cdp.openapi_client.test.test_common_swap_response_fees module
- cdp.openapi_client.test.test_common_swap_response_issues module
- cdp.openapi_client.test.test_common_swap_response_issues_allowance module
- cdp.openapi_client.test.test_common_swap_response_issues_balance module
- cdp.openapi_client.test.test_create_evm_account_request module
- cdp.openapi_client.test.test_create_evm_smart_account_request module
- cdp.openapi_client.test.test_create_evm_swap_quote_request module
- cdp.openapi_client.test.test_create_payment_transfer_quote201_response module
- cdp.openapi_client.test.test_create_payment_transfer_quote_request module
- cdp.openapi_client.test.test_create_policy_request module
- cdp.openapi_client.test.test_create_solana_account_request module
- cdp.openapi_client.test.test_create_swap_quote_response module
- cdp.openapi_client.test.test_create_swap_quote_response_all_of_permit2 module
- cdp.openapi_client.test.test_create_swap_quote_response_all_of_transaction module
- cdp.openapi_client.test.test_create_swap_quote_response_wrapper module
- cdp.openapi_client.test.test_crypto_rail module
- cdp.openapi_client.test.test_crypto_rail_address module
- cdp.openapi_client.test.test_crypto_rail_networks_inner module
- cdp.openapi_client.test.test_eip712_domain module
- cdp.openapi_client.test.test_eip712_message module
- cdp.openapi_client.test.test_error module
- cdp.openapi_client.test.test_error_type module
- cdp.openapi_client.test.test_eth_value_criterion module
- cdp.openapi_client.test.test_evm_account module
- cdp.openapi_client.test.test_evm_accounts_api module
- cdp.openapi_client.test.test_evm_address_criterion module
- cdp.openapi_client.test.test_evm_call module
- cdp.openapi_client.test.test_evm_data_condition module
- cdp.openapi_client.test.test_evm_data_condition_params_inner module
- cdp.openapi_client.test.test_evm_data_criterion module
- cdp.openapi_client.test.test_evm_data_criterion_abi module
- cdp.openapi_client.test.test_evm_data_parameter_condition module
- cdp.openapi_client.test.test_evm_data_parameter_condition_list module
- cdp.openapi_client.test.test_evm_message_criterion module
- cdp.openapi_client.test.test_evm_network_criterion module
- cdp.openapi_client.test.test_evm_smart_account module
- cdp.openapi_client.test.test_evm_smart_accounts_api module
- cdp.openapi_client.test.test_evm_swaps_api module
- cdp.openapi_client.test.test_evm_swaps_network module
- cdp.openapi_client.test.test_evm_token_balances_api module
- cdp.openapi_client.test.test_evm_user_operation module
- cdp.openapi_client.test.test_export_evm_account200_response module
- cdp.openapi_client.test.test_export_evm_account_request module
- cdp.openapi_client.test.test_export_solana_account200_response module
- cdp.openapi_client.test.test_faucets_api module
- cdp.openapi_client.test.test_fee module
- cdp.openapi_client.test.test_get_swap_price_response module
- cdp.openapi_client.test.test_get_swap_price_response_wrapper module
- cdp.openapi_client.test.test_import_evm_account_request module
- cdp.openapi_client.test.test_known_abi_type module
- cdp.openapi_client.test.test_list_evm_accounts200_response module
- cdp.openapi_client.test.test_list_evm_smart_accounts200_response module
- cdp.openapi_client.test.test_list_evm_token_balances200_response module
- cdp.openapi_client.test.test_list_evm_token_balances_network module
- cdp.openapi_client.test.test_list_policies200_response module
- cdp.openapi_client.test.test_list_response module
- cdp.openapi_client.test.test_list_solana_accounts200_response module
- cdp.openapi_client.test.test_payment_method module
- cdp.openapi_client.test.test_payment_method_limits module
- cdp.openapi_client.test.test_payment_method_limits_source_limit module
- cdp.openapi_client.test.test_payment_method_limits_target_limit module
- cdp.openapi_client.test.test_payment_method_request module
- cdp.openapi_client.test.test_payment_rail_action module
- cdp.openapi_client.test.test_payments_alpha_api module
- cdp.openapi_client.test.test_policy module
- cdp.openapi_client.test.test_policy_engine_api module
- cdp.openapi_client.test.test_prepare_user_operation_request module
- cdp.openapi_client.test.test_request_evm_faucet200_response module
- cdp.openapi_client.test.test_request_evm_faucet_request module
- cdp.openapi_client.test.test_request_solana_faucet200_response module
- cdp.openapi_client.test.test_request_solana_faucet_request module
- cdp.openapi_client.test.test_rule module
- cdp.openapi_client.test.test_send_evm_transaction200_response module
- cdp.openapi_client.test.test_send_evm_transaction_criteria_inner module
- cdp.openapi_client.test.test_send_evm_transaction_request module
- cdp.openapi_client.test.test_send_evm_transaction_rule module
- cdp.openapi_client.test.test_send_user_operation_request module
- cdp.openapi_client.test.test_sign_evm_hash200_response module
- cdp.openapi_client.test.test_sign_evm_hash_request module
- cdp.openapi_client.test.test_sign_evm_hash_rule module
- cdp.openapi_client.test.test_sign_evm_message200_response module
- cdp.openapi_client.test.test_sign_evm_message_criteria_inner module
- cdp.openapi_client.test.test_sign_evm_message_request module
- cdp.openapi_client.test.test_sign_evm_message_rule module
- cdp.openapi_client.test.test_sign_evm_transaction200_response module
- cdp.openapi_client.test.test_sign_evm_transaction_criteria_inner module
- cdp.openapi_client.test.test_sign_evm_transaction_request module
- cdp.openapi_client.test.test_sign_evm_transaction_rule module
- cdp.openapi_client.test.test_sign_evm_typed_data200_response module
- cdp.openapi_client.test.test_sign_sol_transaction_criteria_inner module
- cdp.openapi_client.test.test_sign_sol_transaction_rule module
- cdp.openapi_client.test.test_sign_solana_message200_response module
- cdp.openapi_client.test.test_sign_solana_message_request module
- cdp.openapi_client.test.test_sign_solana_transaction200_response module
- cdp.openapi_client.test.test_sign_solana_transaction_request module
- cdp.openapi_client.test.test_sol_address_criterion module
- cdp.openapi_client.test.test_solana_account module
- cdp.openapi_client.test.test_solana_accounts_api module
- cdp.openapi_client.test.test_swap_unavailable_response module
- cdp.openapi_client.test.test_token module
- cdp.openapi_client.test.test_token_amount module
- cdp.openapi_client.test.test_token_balance module
- cdp.openapi_client.test.test_token_fee module
- cdp.openapi_client.test.test_transfer module
- cdp.openapi_client.test.test_transfer_source module
- cdp.openapi_client.test.test_transfer_target module
- cdp.openapi_client.test.test_update_evm_account_request module
- cdp.openapi_client.test.test_update_policy_request module
- cdp.openapi_client.test.test_update_solana_account_request module
- Module contents
- cdp.openapi_client.api package
- Submodules
- cdp.openapi_client.api_client module
ApiClient
ApiClient.NATIVE_TYPES_MAPPING
ApiClient.PRIMITIVE_TYPES
ApiClient.call_api()
ApiClient.close()
ApiClient.deserialize()
ApiClient.files_parameters()
ApiClient.get_default()
ApiClient.param_serialize()
ApiClient.parameters_to_tuples()
ApiClient.parameters_to_url_query()
ApiClient.response_deserialize()
ApiClient.sanitize_for_serialization()
ApiClient.select_header_accept()
ApiClient.select_header_content_type()
ApiClient.set_default()
ApiClient.set_default_header()
ApiClient.update_params_for_auth()
ApiClient.user_agent
- cdp.openapi_client.api_response module
- cdp.openapi_client.cdp_api_client module
- cdp.openapi_client.configuration module
APIKeyAuthSetting
AuthSettings
BasicAuthSetting
BearerAuthSetting
BearerFormatAuthSetting
Configuration
Configuration.access_token
Configuration.assert_hostname
Configuration.auth_settings()
Configuration.cert_file
Configuration.connection_pool_maxsize
Configuration.date_format
Configuration.datetime_format
Configuration.debug
Configuration.get_api_key_with_prefix()
Configuration.get_basic_auth_token()
Configuration.get_default()
Configuration.get_default_copy()
Configuration.get_host_from_settings()
Configuration.get_host_settings()
Configuration.host
Configuration.ignore_operation_servers
Configuration.key_file
Configuration.logger
Configuration.logger_file
Configuration.logger_file_handler
Configuration.logger_format
Configuration.logger_stream_handler
Configuration.password
Configuration.proxy
Configuration.proxy_headers
Configuration.refresh_api_key_hook
Configuration.retries
Configuration.safe_chars_for_path_param
Configuration.server_operation_index
Configuration.server_operation_variables
Configuration.set_default()
Configuration.socket_options
Configuration.ssl_ca_cert
Configuration.temp_folder_path
Configuration.tls_server_name
Configuration.to_debug_report()
Configuration.username
Configuration.verify_ssl
GenericAuthSetting
HTTPSignatureAuthSetting
HostSetting
HostSettingVariable
OAuth2AuthSetting
- cdp.openapi_client.constants module
- cdp.openapi_client.errors module
- cdp.openapi_client.exceptions module
- cdp.openapi_client.rest module
- Module contents
- Subpackages
- cdp.x402 package
Submodules¶
cdp.analytics module¶
cdp.api_clients module¶
- class cdp.api_clients.ApiClients(cdp_client)¶
Bases:
object
A container class for all API clients used in the CDP SDK.
This class provides lazy-loaded access to various API clients, ensuring that each client is only instantiated when it’s first accessed.
- _cdp_client¶
The CDP API client used to initialize individual API clients.
- Type:
- _evm_accounts¶
The EVMAccountsApi client instance.
- Type:
Optional[EVMAccountsApi]
- _evm_smart_accounts¶
The EVMSmartAccountsApi client instance.
- Type:
Optional[EVMSmartAccountsApi]
- _evm_swaps¶
The EVMSwapsApi client instance.
- Type:
Optional[EVMSwapsApi]
- _evm_token_balances¶
The EVMTokenBalancesApi client instance.
- Type:
Optional[EVMTokenBalancesApi]
- _faucets¶
The FaucetsApi client instance.
- Type:
Optional[FaucetsApi]
- _solana_accounts¶
The SolanaAccountsApi client instance.
- Type:
Optional[SolanaAccountsApi]
- async close()¶
Close the CDP client asynchronously.
- property evm_accounts: EVMAccountsApi¶
Get the EVMAccountsApi client instance.
- Returns:
The EVMAccountsApi client instance.
- Return type:
Note
This property lazily initializes the EVMAccountsApi client on first access.
- property evm_smart_accounts: EVMSmartAccountsApi¶
Get the EVMSmartAccountsApi client instance.
- Returns:
The EVMSmartAccountsApi client instance.
- Return type:
Note
This property lazily initializes the EVMSmartAccountsApi client on first access.
- property evm_swaps: EVMSwapsApi¶
Get the EVMSwapsApi client instance.
- Returns:
The EVMSwapsApi client instance.
- Return type:
Note
This property lazily initializes the EVMSwapsApi client on first access.
- property evm_token_balances: EVMTokenBalancesApi¶
Get the EVMTokenBalancesApi client instance.
- Returns:
The EVMTokenBalancesApi client instance.
- Return type:
Note
This property lazily initializes the EVMTokenBalancesApi client on first access.
- property faucets: FaucetsApi¶
Get the FaucetsApi client instance.
- Returns:
The FaucetsApi client instance.
- Return type:
Note
This property lazily initializes the FaucetsApi client on first access.
- property payments: PaymentsAlphaApi¶
Get the PaymentsAlphaApi client instance.
- Returns:
The PaymentsAlphaApi client instance.
- Return type:
Note
This property lazily initializes the PaymentsAlphaApi client on first access.
- property policies: PolicyEngineApi¶
Get the PolicyEngineApi client instance.
- Returns:
The PolicyEngineApi client instance.
- Return type:
Note
This property lazily initializes the PolicyEngineApi client on first access.
- property solana_accounts: SolanaAccountsApi¶
Get the SolanaAccountsApi client instance.
- Returns:
The SolanaAccountsApi client instance.
- Return type:
Note
This property lazily initializes the SolanaAccountsApi client on first access.
cdp.cdp_client module¶
cdp.constants module¶
Specifies package level constants used throughout the package.
- cdp.constants.SDK_DEFAULT_SOURCE = 'sdk'¶
The public RSA key used to encrypt the private key when importing an EVM account.
cdp.evm_call_types module¶
- class cdp.evm_call_types.EncodedCall(**data)¶
Bases:
BaseModel
Represents an encoded call to a smart contract.
-
data:
Optional
[NewType
(HexStr
,str
)]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
to:
NewType
(HexAddress
,NewType
(HexStr
,str
))¶
-
value:
Optional
[NewType
(Wei
,int
)]¶
-
data:
- class cdp.evm_call_types.FunctionCall(**data)¶
Bases:
BaseModel
Represents a call to a smart contract that needs to be encoded using the ABI.
-
abi:
list
[dict
[str
,Any
]]¶
-
args:
list
[Any
]¶
-
function_name:
str
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
to:
NewType
(HexAddress
,NewType
(HexStr
,str
))¶
-
value:
Optional
[NewType
(Wei
,int
)]¶
-
abi:
cdp.evm_client module¶
cdp.evm_local_account module¶
cdp.evm_message_types module¶
cdp.evm_server_account module¶
- class cdp.evm_server_account.EvmServerAccount(evm_server_account_model, evm_accounts_api, api_clients)¶
Bases:
BaseAccount
,BaseModel
A class representing an EVM server account.
- property address: str¶
Get the EVM Account Address.
- Returns:
The EVM account address.
- Return type:
str
- async fund(network, amount, token)¶
Fund an EVM account.
- Parameters:
network (
Literal
['base'
]) – The network to fund the account on.amount (
int
) – The amount of the token to fund in atomic units (e.g. 1000000 for 1 USDC).token (
Literal
['eth'
,'usdc'
]) – The token to fund.
- Returns:
- The result of the fund operation containing:
- transfer: A Transfer object with details about the transfer including:
id: The transfer ID
status: The status of the transfer (e.g. “pending”, “completed”, “failed”)
source_amount: The amount in source currency
source_currency: The source currency
target_amount: The amount in target currency
target_currency: The target currency
fees: List of fees associated with the transfer
- Return type:
FundOperationResult
- async list_token_balances(network, page_size=None, page_token=None)¶
List the token balances for the account on the given network.
- Parameters:
network (str) – The network to list the token balances for.
page_size (int, optional) – The number of token balances to return per page. Defaults to None.
page_token (str, optional) – The token for the next page of token balances, if any. Defaults to None.
- Returns:
The token balances for the account on the network.
- Return type:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property name: str | None¶
Get the name of the EVM account.
- Returns:
The name of the EVM account.
- Return type:
str | None
- property policies: list[str]¶
Gets the list of policies the apply to this account.
- Returns:
The list of Policy IDs.
- Return type:
str
- async quote_fund(network, amount, token)¶
Quote a fund operation.
- Parameters:
network (
Literal
['base'
]) – The network to fund the account on.amount (
int
) – The amount of the token to fund in atomic units (e.g. 1000000 for 1 USDC).token (
Literal
['eth'
,'usdc'
]) – The token to fund.
- Returns:
- A quote object containing:
quote_id: The ID of the quote
network: The network the quote is for
fiat_amount: The amount in fiat currency
fiat_currency: The fiat currency (e.g. “usd”)
token_amount: The amount of tokens to receive
token: The token to receive
fees: List of fees associated with the quote
- Return type:
Quote
- async quote_swap(from_token, to_token, from_amount, network, slippage_bps=None, signer_address=None, idempotency_key=None)¶
Get a quote for swapping tokens.
This is a convenience method that calls the underlying create_swap_quote with the account’s address as the taker.
- Parameters:
from_token (
str
) – The contract address of the token to swap fromto_token (
str
) – The contract address of the token to swap tofrom_amount (
str
|int
) – The amount to swap from (in smallest unit)network (
str
) – The network to execute the swap onslippage_bps (
Optional
[int
]) – Maximum slippage in basis points (100 = 1%). Defaults to 100.signer_address (
Optional
[str
]) – The address that will sign the transaction (for smart accounts). Currently unused.idempotency_key (
Optional
[str
]) – Optional idempotency key for safe retryable requests.
- Returns:
The swap quote with transaction data
- Return type:
QuoteSwapResult
Examples
>>> # Get a quote for swapping USDC to WETH (account as taker) >>> quote = await account.quote_swap( ... from_token="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", # USDC ... to_token="0x4200000000000000000000000000000000000006", # WETH ... from_amount="100000000", # 100 USDC ... network="base", ... idempotency_key="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ... ) >>> print(f"Expected output: {quote.to_amount}") >>> >>> # Execute the quote if satisfied >>> result = await account.swap(AccountSwapOptions(swap_quote=quote))
- async request_faucet(network, token)¶
Request a token from the faucet.
- Parameters:
network (str) – The network to request the faucet for.
token (str) – The token to request the faucet for.
- Returns:
The transaction hash of the faucet request.
- Return type:
str
- async send_transaction(transaction, network, idempotency_key=None)¶
Send an EVM transaction.
- Parameters:
transaction (str | TransactionDictType | DynamicFeeTransaction) –
The transaction to send.
This can be either an RLP-encoded transaction to sign and send, as a 0x-prefixed hex string, or an EIP-1559 transaction request object.
Use TransactionRequestEIP1559 if you would like Coinbase to manage the nonce and gas parameters.
You can also use DynamicFeeTransaction from eth-account, but you will have to set the nonce and gas parameters manually.
These are the fields that can be contained in the transaction object:
to: (Required) The address of the contract or account to send the transaction to.
value: (Optional) The amount of ETH, in wei, to send with the transaction.
data: (Optional) The data to send with the transaction; only used for contract calls.
gas: (Optional) The amount of gas to use for the transaction.
nonce: (Optional) The nonce to use for the transaction. If not provided, the API will assign a nonce to the transaction based on the current state of the account.
maxFeePerGas: (Optional) The maximum fee per gas to use for the transaction. If not provided, the API will estimate a value based on current network conditions.
maxPriorityFeePerGas: (Optional) The maximum priority fee per gas to use for the transaction. If not provided, the API will estimate a value based on current network conditions.
accessList: (Optional) The access list to use for the transaction.
chainId: (Ignored) The value of the chainId field in the transaction is ignored.
from: (Ignored) Ignored in favor of the account address that is sending the transaction.
type: (Ignored) The transaction type must always be 0x2 (EIP-1559).
network (str) – The network.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- Returns:
The transaction hash.
- Return type:
str
- async sign_message(signable_message, idempotency_key=None)¶
Sign the EIP-191 message.
- Parameters:
signable_message (
SignableMessage
) – The encoded message, ready for signingidempotency_key (
Optional
[str
]) – Optional idempotency key
- Return type:
SignedMessage
- Returns:
The signed message
- Raises:
AttributeError – If the signature response is missing required fields
- async sign_transaction(transaction_dict, idempotency_key=None)¶
Sign a transaction dict.
- Parameters:
transaction_dict (
Dict
[str
,Union
[Sequence
[Dict
[str
,Union
[NewType
(HexStr
,str
),Sequence
[NewType
(HexStr
,str
)]]]],bytes
,NewType
(HexStr
,str
),int
]]) – transaction with all fields specifiedidempotency_key (
Optional
[str
]) – Optional idempotency key
- Return type:
SignedTransaction
- Returns:
The signed transaction
- Raises:
ValueError – If the signature response is missing required fields
- async sign_typed_data(domain, types, primary_type, message, idempotency_key=None)¶
Sign an EVM typed data.
- Parameters:
domain (EIP712Domain) – The domain of the message.
types (Dict[str, Any]) – The types of the message.
primary_type (str) – The primary type of the message.
message (Dict[str, Any]) – The message to sign.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- Returns:
The signature.
- Return type:
str
- async swap(swap_options)¶
Execute a token swap.
- Parameters:
swap_options (
AccountSwapOptions
) – The swap options- Returns:
The result containing the transaction hash
- Return type:
AccountSwapResult
- classmethod to_evm_account(address, name=None)¶
Construct an existing EvmAccount by its address and the name.
- Parameters:
address (str) – The address of the EvmAccount to retrieve.
name (str | None) – The name of the EvmAccount.
- Returns:
The retrieved EvmAccount object.
- Return type:
- Raises:
Exception – If there’s an error retrieving the EvmAccount.
- async transfer(to, amount, token, network)¶
Transfer an amount of a token from an account to another account.
- Parameters:
to (
str
|BaseAccount
) – The account or 0x-prefixed address to transfer the token to.amount (
int
) – The amount of the token to transfer, represented as an atomic unit (e.g. 10000 for 0.01 USDC).units. (The cdp module exports a parse_units util to convert to atomic)
Otherwise
below. (you can pass atomic units directly. See examples)
token (
str
) – The token to transfer.network (
str
) – The network to transfer the token on.
- Returns:
The result of the transfer.
Examples
>>> transfer = await sender.transfer( ... to="0x9F663335Cd6Ad02a37B633602E98866CF944124d", ... amount=10000, # equivalent to 0.01 USDC ... token="usdc", ... network="base-sepolia", ... )
Using parse_units to specify USDC amount >>> from cdp import parse_units >>> transfer = await sender.transfer( … to=”0x9F663335Cd6Ad02a37B633602E98866CF944124d”, … amount=parse_units(“0.01”, 6), # USDC uses 6 decimal places … token=”usdc”, … network=”base-sepolia”, … )
Transfer to another account >>> sender = await cdp.evm.create_account(name=”Sender”) >>> receiver = await cdp.evm.create_account(name=”Receiver”) >>> >>> transfer = await sender.transfer({ … “to”: receiver, … “amount”: 10000, # equivalent to 0.01 USDC … “token”: “usdc”, … “network”: “base-sepolia”, … })
- async unsafe_sign_hash(message_hash, idempotency_key=None)¶
Sign the hash of a message.
WARNING: Never sign a hash that you didn’t generate, it can be an arbitrary transaction.
- Parameters:
message_hash (
NewType
(Hash32
,bytes
)) – 32 byte hash of the message to signidempotency_key (
Optional
[str
]) – Optional idempotency key
- Return type:
SignedMessage
- Returns:
The signed message
- Raises:
ValueError – If the signature response is missing required fields
- async wait_for_fund_operation_receipt(transfer_id, timeout_seconds=900, interval_seconds=1)¶
Wait for a fund operation to complete.
- Parameters:
transfer_id (
str
) – The ID of the transfer to wait for.timeout_seconds (
float
) – The maximum time to wait for completion in seconds. Defaults to 900 (15 minutes).interval_seconds (
float
) – The time between status checks in seconds. Defaults to 1.
- Returns:
- The completed transfer object containing:
id: The transfer ID
status: The final status of the transfer (“completed” or “failed”)
source_amount: The amount in source currency
source_currency: The source currency
target_amount: The amount in target currency
target_currency: The target currency
fees: List of fees associated with the transfer
- Return type:
- Raises:
TimeoutError – If the transfer does not complete within the timeout period.
- class cdp.evm_server_account.ListEvmAccountsResponse(**data)¶
Bases:
BaseModel
Response model for listing EVM accounts.
-
accounts:
list
[EvmServerAccount
]¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
next_page_token:
str
|None
¶
-
accounts:
cdp.evm_smart_account module¶
- class cdp.evm_smart_account.EvmSmartAccount(address, owner, name=None, api_clients=None)¶
Bases:
BaseModel
A class representing an EVM smart account.
- property address: str¶
Get the Smart Account Address.
- Returns:
The Smart Account Address.
- Return type:
str
- async fund(network, amount, token)¶
Fund an EVM account.
- Parameters:
network (
Literal
['base'
]) – The network to fund the account on.amount (
int
) – The amount of the token to fund in atomic units (e.g. 1000000 for 1 USDC).token (
Literal
['eth'
,'usdc'
]) – The token to fund.
- Returns:
- The result of the fund operation containing:
- transfer: A Transfer object with details about the transfer including:
id: The transfer ID
status: The status of the transfer (e.g. “pending”, “completed”, “failed”)
source_amount: The amount in source currency
source_currency: The source currency
target_amount: The amount in target currency
target_currency: The target currency
fees: List of fees associated with the transfer
- Return type:
FundOperationResult
- async get_user_operation(user_op_hash)¶
Get a user operation for the smart account by hash.
- Parameters:
user_op_hash (str) – The hash of the user operation to get.
- Returns:
The user operation model.
- Return type:
EvmUserOperationModel
- async list_token_balances(network, page_size=None, page_token=None)¶
List the token balances for the smart account on the given network.
- Parameters:
network (str) – The network to list the token balances for.
page_size (int, optional) – The number of token balances to return per page. Defaults to None.
page_token (str, optional) – The token for the next page of token balances, if any. Defaults to None.
- Returns:
The token balances for the smart account on the network.
- Return type:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property name: str | None¶
Get the name of the smart account.
- Returns:
The name of the smart account.
- Return type:
str | None
- property owners: list[BaseAccount]¶
Get the account owners.
- Returns:
List of owner accounts
- Return type:
List[BaseAccount]
- async quote_fund(network, amount, token)¶
Quote a fund operation.
- Parameters:
network (
Literal
['base'
]) – The network to fund the account on.amount (
int
) – The amount of the token to fund in atomic units (e.g. 1000000 for 1 USDC).token (
Literal
['eth'
,'usdc'
]) – The token to fund.
- Returns:
- A quote object containing:
quote_id: The ID of the quote
network: The network the quote is for
fiat_amount: The amount in fiat currency
fiat_currency: The fiat currency (e.g. “usd”)
token_amount: The amount of tokens to receive
token: The token to receive
fees: List of fees associated with the quote
- Return type:
Quote
- async quote_swap(from_token, to_token, from_amount, network, slippage_bps=None, paymaster_url=None, idempotency_key=None)¶
Get a quote for swapping tokens with a smart account.
This is a convenience method that calls the underlying create_swap_quote with the smart account’s address as the taker and the owner’s address as the signer.
- Parameters:
from_token (
str
) – The contract address of the token to swap fromto_token (
str
) – The contract address of the token to swap tofrom_amount (
str
|int
) – The amount to swap from (in smallest unit)network (
str
) – The network to execute the swap onslippage_bps (
Optional
[int
]) – Maximum slippage in basis points (100 = 1%). Defaults to 100.paymaster_url (
Optional
[str
]) – Optional paymaster URL for gas sponsorship.idempotency_key (
Optional
[str
]) – Optional idempotency key for safe retryable requests.
- Returns:
The swap quote with transaction data
- Return type:
QuoteSwapResult
- Raises:
ValueError – If parameters are invalid or liquidity is unavailable
Exception – If the API request fails
Examples
```python # Get a quote for swapping USDC to WETH (smart account as taker, owner as signer) quote = await smart_account.quote_swap(
from_token=”0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913”, # USDC to_token=”0x4200000000000000000000000000000000000006”, # WETH from_amount=”100000000”, # 100 USDC network=”base”, paymaster_url=”https://paymaster.example.com”, # Optional idempotency_key=”xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”
) print(f”Expected output: {quote.to_amount}”)
# Execute the quote if satisfied result = await smart_account.swap(network=”base”, swap_quote=quote) ```
- async request_faucet(network, token)¶
Request a token from the faucet.
- Parameters:
network (str) – The network to request the faucet for.
token (str) – The token to request the faucet for.
- Returns:
The transaction hash of the faucet request.
- Return type:
str
- async send_user_operation(calls, network, paymaster_url=None)¶
Send a user operation for the smart account.
- Parameters:
calls (List[ContractCall]) – The calls to send.
network (str) – The network.
paymaster_url (str) – The paymaster URL.
- Returns:
The user operation model.
- Return type:
EvmUserOperationModel
- async swap(options)¶
Execute a token swap via user operation.
- Parameters:
options (
SmartAccountSwapOptions
) – SmartAccountSwapOptions with either swap_quote OR inline parameters- Returns:
- The user operation result containing:
user_op_hash: The user operation hash
smart_account_address: The smart account address
status: The operation status
- Return type:
SmartAccountSwapResult
- Raises:
ValueError – If liquidity is not available for the swap
Exception – If the swap operation fails
Examples
Using pre-created swap quote (recommended for inspecting details first): ```python from cdp.actions.evm.swap.types import SmartAccountSwapOptions
# First create a quote quote = await smart_account.quote_swap(
from_token=”0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913”, # USDC to_token=”0x4200000000000000000000000000000000000006”, # WETH from_amount=”100000000”, # 100 USDC network=”base”, idempotency_key=”…”
)
# Then execute the swap result = await smart_account.swap(
- SmartAccountSwapOptions(
swap_quote=quote, idempotency_key=”…”
)
)¶
Using inline parameters (all-in-one pattern): ```python from cdp.actions.evm.swap.types import SmartAccountSwapOptions
- result = await smart_account.swap(
- SmartAccountSwapOptions(
network=”base”, from_token=”0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913”, # USDC to_token=”0x4200000000000000000000000000000000000006”, # WETH from_amount=”100000000”, # 100 USDC slippage_bps=100, # 1% slippage idempotency_key=”…”
)
)¶
- classmethod to_evm_smart_account(address, owner, name=None)¶
Construct an existing smart account by its address and the owner.
- Parameters:
address (str) – The address of the evm smart account to retrieve.
owner (BaseAccount) – The owner of the evm smart account.
name (str | None) – The name of the evm smart account.
- Returns:
The retrieved EvmSmartAccount object.
- Return type:
- Raises:
Exception – If there’s an error retrieving the EvmSmartAccount.
- async transfer(to, amount, token, network, paymaster_url=None)¶
Transfer an amount of a token from an account to another account.
- Parameters:
to (
str
|BaseAccount
) – The account or 0x-prefixed address to transfer the token to.amount (
int
) – The amount of the token to transfer, represented as an atomic unit (e.g. 10000 for 0.01 USDC).units. (The cdp module exports a parse_units util to convert to atomic)
Otherwise
below. (you can pass atomic units directly. See examples)
token (
str
) – The token to transfer.network (
str
) – The network to transfer the token on.paymaster_url (
Optional
[str
]) – The paymaster URL to use for the transfer.
- Returns:
The result of the transfer.
Examples
>>> transfer = await sender.transfer( ... to="0x9F663335Cd6Ad02a37B633602E98866CF944124d", ... amount=10000, # equivalent to 0.01 USDC ... token="usdc", ... network="base-sepolia", ... )
Using parse_units to specify USDC amount >>> from cdp import parse_units >>> transfer = await sender.transfer( … to=”0x9F663335Cd6Ad02a37B633602E98866CF944124d”, … amount=parse_units(“0.01”, 6), # USDC uses 6 decimal places … token=”usdc”, … network=”base-sepolia”, … )
Transfer to another account >>> sender = await cdp.evm.create_smart_account( … owner=await cdp.evm.create_account(name=”Owner”), … ) >>> receiver = await cdp.evm.create_account(name=”Receiver”) >>> >>> transfer = await sender.transfer({ … “to”: receiver, … “amount”: 10000, # equivalent to 0.01 USDC … “token”: “usdc”, … “network”: “base-sepolia”, … })
- async wait_for_fund_operation_receipt(transfer_id, timeout_seconds=900, interval_seconds=1)¶
Wait for a fund operation to complete.
- Parameters:
transfer_id (
str
) – The ID of the transfer to wait for.timeout_seconds (
float
) – The maximum time to wait for completion in seconds. Defaults to 900 (15 minutes).interval_seconds (
float
) – The time between status checks in seconds. Defaults to 1.
- Returns:
- The completed transfer object containing:
id: The transfer ID
status: The final status of the transfer (“completed” or “failed”)
source_amount: The amount in source currency
source_currency: The source currency
target_amount: The amount in target currency
target_currency: The target currency
fees: List of fees associated with the transfer
- Return type:
- Raises:
TimeoutError – If the transfer does not complete within the timeout period.
- async wait_for_user_operation(user_op_hash, timeout_seconds=20, interval_seconds=0.2)¶
Wait for a user operation to be processed.
- Parameters:
user_op_hash (str) – The hash of the user operation to wait for.
timeout_seconds (float, optional) – Maximum time to wait in seconds. Defaults to 20.
interval_seconds (float, optional) – Time between checks in seconds. Defaults to 0.2.
- Returns:
The user operation model.
- Return type:
EvmUserOperationModel
- class cdp.evm_smart_account.ListEvmSmartAccountsResponse(**data)¶
Bases:
BaseModel
Response model for listing EVM smart accounts.
-
accounts:
list
[EvmSmartAccount
]¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
next_page_token:
str
|None
¶
-
accounts:
cdp.evm_token_balances module¶
- class cdp.evm_token_balances.EvmToken(**data)¶
Bases:
BaseModel
A token on an EVM network, which is either an ERC-20 or a native token (i.e. ETH).
-
contract_address:
str
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
name:
str
|None
¶
-
network:
ListEvmTokenBalancesNetwork
¶
-
symbol:
str
|None
¶
-
contract_address:
- class cdp.evm_token_balances.EvmTokenAmount(**data)¶
Bases:
BaseModel
A token amount on an EVM network.
-
amount:
int
¶
-
decimals:
int
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
amount:
- class cdp.evm_token_balances.EvmTokenBalance(**data)¶
Bases:
BaseModel
An EVM token balance.
-
amount:
EvmTokenAmount
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
amount:
- class cdp.evm_token_balances.ListTokenBalancesResult(**data)¶
Bases:
BaseModel
The result of listing EVM token balances.
-
balances:
list
[EvmTokenBalance
]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
next_page_token:
str
|None
¶
-
balances:
cdp.evm_transaction_types module¶
- class cdp.evm_transaction_types.TransactionRequestEIP1559(**data)¶
Bases:
BaseModel
Represents a transaction request using EIP-1559. Used with EthAccount’s DynamicFeeTransaction.
-
accessList:
list
[dict
[str
,Any
]] |None
¶
- as_dict()¶
Serialize the TransactionRequestEIP1559 object to a dictionary.
- Return type:
dict
[str
,Any
]
-
chainId:
int
|None
¶
-
data:
Optional
[NewType
(HexStr
,str
)]¶
-
gas:
int
|None
¶
-
maxFeePerGas:
int
|None
¶
-
maxPriorityFeePerGas:
int
|None
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
nonce:
int
|None
¶
-
to:
NewType
(HexAddress
,NewType
(HexStr
,str
))¶
-
type:
str
|None
¶
-
value:
int
|None
¶
-
accessList:
cdp.export module¶
cdp.policies_client module¶
cdp.solana_account module¶
cdp.solana_client module¶
cdp.update_account_types module¶
cdp.utils module¶
- exception cdp.utils.InvalidDecimalNumberError(value)¶
Bases:
Exception
Exception raised for invalid decimal number strings.
- Parameters:
value – The invalid decimal number string
- cdp.utils.create_deterministic_uuid_v4(base_key, suffix='')¶
Create a deterministic UUID v4 from a base key and optional suffix.
This function generates a deterministic UUID by hashing the input components. Used for creating consistent idempotency keys across operations.
- Parameters:
base_key (
str
) – The base key to generate the UUID fromsuffix (
str
) – An optional suffix to append to the base key
- Returns:
A deterministic UUID v4 string
- Return type:
str
Examples
>>> create_deterministic_uuid_v4("my-base-key", "permit2") "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6"
>>> create_deterministic_uuid_v4("my-base-key") "f1e2d3c4-b5a6-4798-8765-432109abcdef"
- async cdp.utils.ensure_awaitable(func, *args, **kwargs)¶
Ensure a function call returns an awaitable result.
Works with both synchronous and asynchronous functions.
- Parameters:
func – The function to call
*args – Arguments to pass to the function
**kwargs – Arguments to pass to the function
- Returns:
The awaited result of the function
- cdp.utils.parse_units(value, decimals)¶
Parse a decimal number string into an integer.
- Parameters:
value (
str
) – The decimal number string to parsedecimals (
int
) – The number of decimal places
- Return type:
int
Returns: The parsed integer
- Raises:
InvalidDecimalNumberError – If the value is not a valid decimal number
- cdp.utils.serialize_unsigned_transaction(transaction)¶
Serialize an unsigned transaction.
- Parameters:
transaction (
DynamicFeeTransaction
) – The transaction to serialize- Return type:
str
Returns: The serialized transaction
- cdp.utils.sort_keys(obj)¶
Recursively sorts object keys to ensure consistent JSON stringification.
- Parameters:
obj (
dict
) – The object to sort- Return type:
dict
- Returns:
A new object with sorted keys
Examples
>>> sort_keys({"b": 1, "a": 2}) {'a': 2, 'b': 1}
>>> sort_keys({"b": {"d": 1, "c": 2}, "a": 3}) {'a': 3, 'b': {'c': 2, 'd': 1}}