cdp package¶
Subpackages¶
- cdp.auth package
- Subpackages
- Module contents
GetAuthHeadersOptions
GetAuthHeadersOptions.api_key_id
GetAuthHeadersOptions.api_key_secret
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
JwtOptions
Urllib3AuthClient
Urllib3AuthClientOptions
WalletJwtOptions
generate_jwt()
generate_wallet_jwt()
get_auth_headers()
- cdp.openapi_client package
- Subpackages
- cdp.openapi_client.api package
- cdp.openapi_client.models package
- Submodules
- cdp.openapi_client.models.create_evm_account_request module
- cdp.openapi_client.models.create_evm_smart_account_request module
- cdp.openapi_client.models.create_solana_account_request module
- cdp.openapi_client.models.error module
- cdp.openapi_client.models.error_type module
- cdp.openapi_client.models.evm_account module
- cdp.openapi_client.models.evm_call module
- cdp.openapi_client.models.evm_smart_account module
- cdp.openapi_client.models.evm_user_operation 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_response module
- cdp.openapi_client.models.list_solana_accounts200_response 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.send_evm_transaction200_response module
- cdp.openapi_client.models.send_evm_transaction_request 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_message200_response module
- cdp.openapi_client.models.sign_evm_message_request module
- cdp.openapi_client.models.sign_evm_transaction200_response module
- cdp.openapi_client.models.sign_evm_transaction_request 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.solana_account module
- cdp.openapi_client.models.token module
- cdp.openapi_client.models.token_amount module
- cdp.openapi_client.models.token_balance module
- Module contents
- cdp.openapi_client.test package
- Submodules
- 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_solana_account_request module
- cdp.openapi_client.test.test_error module
- cdp.openapi_client.test.test_error_type module
- cdp.openapi_client.test.test_evm_account module
- cdp.openapi_client.test.test_evm_accounts_api module
- cdp.openapi_client.test.test_evm_call 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_token_balances_api module
- cdp.openapi_client.test.test_evm_user_operation module
- cdp.openapi_client.test.test_faucets_api 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_response module
- cdp.openapi_client.test.test_list_solana_accounts200_response 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_send_evm_transaction200_response module
- cdp.openapi_client.test.test_send_evm_transaction_request 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_message200_response module
- cdp.openapi_client.test.test_sign_evm_message_request module
- cdp.openapi_client.test.test_sign_evm_transaction200_response module
- cdp.openapi_client.test.test_sign_evm_transaction_request 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_solana_account module
- cdp.openapi_client.test.test_solana_accounts_api module
- cdp.openapi_client.test.test_token module
- cdp.openapi_client.test.test_token_amount module
- cdp.openapi_client.test.test_token_balance module
- Module contents
- 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
Submodules¶
cdp.analytics module¶
- class cdp.analytics.AnalyticsConfig¶
Bases:
object
AnalyticsConfig singleton class for holding the API key ID.
- api_key_id = None¶
- classmethod set(api_key_id)¶
Set the API key ID.
- Parameters:
api_key_id (
str
) – The API key ID- Return type:
None
- class cdp.analytics.ErrorEventData(**data)¶
Bases:
BaseModel
The data in an error event.
-
message:
str
¶
-
method:
str
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
name:
str
¶
-
stack:
str
|None
¶
-
message:
- cdp.analytics.EventData¶
alias of
ErrorEventData
- async cdp.analytics.send_event(event)¶
Send an analytics event to the default endpoint.
- Parameters:
event (
ErrorEventData
) – The event data containing event-specific fields- Return type:
None
- Returns:
None - resolves when the event is sent
- cdp.analytics.wrap_class_with_error_tracking(cls)¶
Wrap all methods of a class with error tracking.
- Parameters:
cls – The class to wrap.
- Returns:
The class with wrapped methods.
- cdp.analytics.wrap_with_error_tracking(func)¶
Wrap a method with error tracking.
- Parameters:
func – The function to wrap.
- Returns:
The wrapped function.
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_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_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 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¶
- class cdp.cdp_client.CdpClient(api_key_id=None, api_key_secret=None, wallet_secret=None, debugging=False, base_path='https://api.cdp.coinbase.com/platform', max_network_retries=3, source='sdk', source_version='1.2.0')¶
Bases:
object
The CdpClient class is responsible for configuring and managing the CDP API client.
- async close()¶
Close the CDP client.
- property solana: SolanaClient¶
Get the SolanaClient instance.
cdp.constants module¶
Specifies package level constants used throughout the package.
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¶
- class cdp.evm_client.EvmClient(api_clients)¶
Bases:
object
The EvmClient class is responsible for CDP API calls for the EVM.
- async create_account(name=None, idempotency_key=None)¶
Create an EVM account.
- Parameters:
name (str, optional) – The name. Defaults to None.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- Returns:
The EVM server account.
- Return type:
- async create_smart_account(owner)¶
Create an EVM smart account.
- Parameters:
owner (BaseAccount) – The owner of the smart account.
- Returns:
The EVM smart account.
- Return type:
- async get_account(address=None, name=None)¶
Get an EVM account by address.
- Parameters:
address (str, optional) – The address of the account.
name (str, optional) – The name of the account.
- Returns:
The EVM server account.
- Return type:
- async get_smart_account(address, owner=None)¶
Get an EVM smart account by address.
- Parameters:
address (str) – The address of the smart account.
owner (BaseAccount, optional) – The owner of the smart account. Defaults to None.
- Returns:
The EVM smart account.
- Return type:
- async get_user_operation(address, user_op_hash)¶
Get a user operation by address and hash.
- Parameters:
address (str) – The address of the smart account that sent the operation.
user_op_hash (str) – The hash of the user operation to get.
- Returns:
The user operation model.
- Return type:
EvmUserOperationModel
- async list_accounts(page_size=None, page_token=None)¶
List all EVM accounts.
- Parameters:
page_size (int, optional) – The number of accounts to return per page. Defaults to None.
page_token (str, optional) – The token for the next page of accounts, if any. Defaults to None.
- Returns:
The list of EVM accounts.
- Return type:
- async list_smart_accounts(page_size=None, page_token=None)¶
List all EVM smart accounts.
- Parameters:
page_size (int, optional) – The number of accounts to return per page. Defaults to None.
page_token (str, optional) – The token for the next page of accounts, if any. Defaults to None.
- Returns:
The list of EVM smart accounts. The smart accounts are not wrapped in the EvmSmartAccount class so these cannot be used to send user operations. Call get_smart_account with an owner to get an EvmSmartAccount instance that can be used to send user operations.
- Return type:
- async list_token_balances(address, network, page_size=None, page_token=None)¶
List the token balances for an address on the given network.
- Parameters:
address (str) – The address to list the token balances for.
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 address on the network.
- Return type:
- async prepare_user_operation(smart_account, calls, network, paymaster_url=None)¶
Prepare a user operation for a smart account.
- Parameters:
smart_account (EvmSmartAccount) – The smart account to prepare the user operation for.
calls (list[EncodedCall]) – The calls to prepare the user operation for.
network (str) – The network.
paymaster_url (str, optional) – The paymaster URL. Defaults to None.
- Returns:
The user operation model.
- Return type:
EvmUserOperationModel
- async request_faucet(address, network, token)¶
Request a token from the faucet in the test network.
- Parameters:
address (str) – The address to request the faucet for.
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(address, transaction, network, idempotency_key=None)¶
Send an EVM transaction.
- Parameters:
address (str) – The address of the account.
transaction (str | TransactionDictType) –
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.
Note that while the CDP API can handle nonce and gas management, this function relies on TypedTransaction from eth-account to serialize the transaction, and TypedTransaction requires you to pass in the nonce and gas parameters.
Refer to https://github.com/coinbase/cdp-sdk/blob/main/python/cdp/examples/evm/send_transaction.py for a full example.
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: (Required) The amount of gas to use for the transaction.
nonce: (Required) 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: (Required) 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: (Required) 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: 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 send_user_operation(smart_account, calls, network, paymaster_url=None)¶
Send a user operation for a smart account.
- Parameters:
smart_account (EvmSmartAccount) – The smart account to send the user operation from.
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 sign_hash(address, hash, idempotency_key=None)¶
Sign an EVM hash.
- Parameters:
address (str) – The address of the account.
hash (str) – The hash to sign.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- Returns:
The signed hash.
- Return type:
str
- async sign_message(address, message, idempotency_key=None)¶
Sign an EVM message.
- Parameters:
address (str) – The address of the account.
message (str) – The message to sign.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- Returns:
The signed message.
- Return type:
str
- async sign_transaction(address, transaction, idempotency_key=None)¶
Sign an EVM transaction.
- Parameters:
address (str) – The address of the account.
transaction (str) – The transaction to sign.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- Returns:
The signed transaction.
- Return type:
str
- async wait_for_user_operation(smart_account_address, user_op_hash, timeout_seconds=20, interval_seconds=0.2)¶
Wait for a user operation to be processed.
- Parameters:
smart_account_address (str) – The address of the smart account that sent the operation.
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
cdp.evm_server_account module¶
- class cdp.evm_server_account.EvmServerAccount(evm_server_account_model, evm_accounts_api)¶
Bases:
BaseAccount
A class representing an EVM server account.
- property address: str¶
Get the EVM Account Address.
- Returns:
The EVM account address.
- Return type:
str
- property name: str | None¶
Get the name of the EVM account.
- Returns:
The name of the EVM account.
- Return type:
str | None
- 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
- 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 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
- 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)¶
Bases:
object
A class representing an EVM smart account.
- property address: str¶
Get the Smart Account Address.
- Returns:
The Smart Account Address.
- Return type:
str
- 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]
- 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.
- 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.solana_client module¶
- class cdp.solana_client.SolanaClient(api_clients)¶
Bases:
object
The SolanaClient class is responsible for CDP API calls for Solana.
- async create_account(name=None, idempotency_key=None)¶
Create a Solana account.
- Parameters:
name (str, optional) – The name. Defaults to None.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- async get_account(address=None, name=None)¶
Get a Solana account by address.
- Parameters:
address (str, optional) – The address of the account.
name (str, optional) – The name of the account.
- async list_accounts(page_size=None, page_token=None)¶
List all Solana accounts.
- Parameters:
page_size (int, optional) – The number of accounts to return per page. Defaults to None.
page_token (str, optional) – The token for the next page of accounts, if any. Defaults to None.
- Returns:
List of Solana accounts.
- Return type:
List[SolanaAccount]
- async request_faucet(address, token)¶
Request a token from the faucet.
- Parameters:
address (str) – The address to request the faucet for.
token (str) – The token to request the faucet for.
- Returns:
The transaction signature of the faucet request.
- Return type:
str
- async sign_message(address, message, idempotency_key=None)¶
Sign a Solana message.
- Parameters:
address (str) – The address of the account.
message (str) – The message to sign.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
- async sign_transaction(address, transaction, idempotency_key=None)¶
Sign a Solana transaction.
- Parameters:
address (str) – The address of the account.
transaction (str) – The transaction to sign.
idempotency_key (str, optional) – The idempotency key. Defaults to None.
cdp.utils module¶
- 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
Module contents¶
- class cdp.CdpClient(api_key_id=None, api_key_secret=None, wallet_secret=None, debugging=False, base_path='https://api.cdp.coinbase.com/platform', max_network_retries=3, source='sdk', source_version='1.2.0')¶
Bases:
object
The CdpClient class is responsible for configuring and managing the CDP API client.
- async close()¶
Close the CDP client.
- property solana: SolanaClient¶
Get the SolanaClient instance.
- class cdp.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.EvmServerAccount(evm_server_account_model, evm_accounts_api)¶
Bases:
BaseAccount
A class representing an EVM server account.
- property address: str¶
Get the EVM Account Address.
- Returns:
The EVM account address.
- Return type:
str
- property name: str | None¶
Get the name of the EVM account.
- Returns:
The name of the EVM account.
- Return type:
str | None
- 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
- 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 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
- class cdp.EvmSmartAccount(address, owner, name=None)¶
Bases:
object
A class representing an EVM smart account.
- property address: str¶
Get the Smart Account Address.
- Returns:
The Smart Account Address.
- Return type:
str
- 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]
- 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.
- class cdp.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: