coinbase_agentkit package

Subpackages

Submodules

coinbase_agentkit.agentkit module

AgentKit - The framework for enabling AI agents to take actions onchain.

class coinbase_agentkit.agentkit.AgentKit(config=None)

Bases: object

Main AgentKit class for managing wallet and action providers.

Provides a unified interface for interacting with wallets and executing actions across different protocols and networks.

get_actions()

Get all available actions for the current wallet and network.

Returns:

List of available actions from all providers

Return type:

list[Action]

Raises:

ValueError – If no wallet provider is configured

class coinbase_agentkit.agentkit.AgentKitConfig(**data)

Bases: BaseModel

Configuration options for AgentKit.

action_providers: list[ActionProvider] | None
cdp_api_key_name: str | None
cdp_api_key_private_key: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

wallet_provider: WalletProvider | None

coinbase_agentkit.network module

class coinbase_agentkit.network.Network(**data)

Bases: BaseModel

Represents a blockchain network.

chain_id: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

network_id: str | None
protocol_family: str

Module contents

Coinbase AgentKit - Framework for enabling AI agents to take actions onchain.

class coinbase_agentkit.Action(**data)

Bases: BaseModel

Represents an action that can be performed by an agent.

args_schema: type[BaseModel] | None
description: str
invoke: Callable
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
class coinbase_agentkit.ActionProvider(name, action_providers)

Bases: Generic[TWalletProvider], ABC

Base class for all action providers.

get_actions(wallet_provider)

Get all actions from this provider and its sub-providers.

Return type:

list[Action]

abstract supports_network(network)

Check if this provider supports the given network.

Return type:

bool

class coinbase_agentkit.AgentKit(config=None)

Bases: object

Main AgentKit class for managing wallet and action providers.

Provides a unified interface for interacting with wallets and executing actions across different protocols and networks.

get_actions()

Get all available actions for the current wallet and network.

Returns:

List of available actions from all providers

Return type:

list[Action]

Raises:

ValueError – If no wallet provider is configured

class coinbase_agentkit.AgentKitConfig(**data)

Bases: BaseModel

Configuration options for AgentKit.

action_providers: list[ActionProvider] | None
cdp_api_key_name: str | None
cdp_api_key_private_key: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

wallet_provider: WalletProvider | None
class coinbase_agentkit.CdpWalletProvider(config=None)

Bases: EvmWalletProvider

A wallet provider that uses the CDP SDK.

deploy_contract(solidity_version, solidity_input_json, contract_name, constructor_args)

Deploy a smart contract.

Parameters:
  • solidity_version (str) – The version of the Solidity compiler to use

  • solidity_input_json (str) – The JSON input for the Solidity compiler

  • contract_name (str) – The name of the contract to deploy

  • constructor_args (dict[str, Any]) – Key-value map of constructor arguments

Returns:

The deployed contract instance

Return type:

Any

Raises:

Exception – If wallet is not initialized or deployment fails

deploy_nft(name, symbol, base_uri)

Deploy a new NFT (ERC-721) smart contract.

Parameters:
  • name (str) – The name of the NFT collection

  • symbol (str) – The token symbol for the collection

  • base_uri (str) – The base URI for token metadata

Returns:

The deployed NFT contract instance

Return type:

Any

Raises:

Exception – If wallet is not initialized or deployment fails

deploy_token(name, symbol, total_supply)

Deploy an ERC20 token contract.

Parameters:
  • name (str) – The name of the token

  • symbol (str) – The symbol of the token

  • total_supply (str) – The total supply of the token

Returns:

The deployed token contract instance

Return type:

Any

Raises:

Exception – If wallet is not initialized or deployment fails

export_wallet()

Export the wallet data for persistence.

Returns:

The wallet data object containing all necessary information

Return type:

WalletData

Raises:

Exception – If wallet is not initialized

get_address()

Get the wallet address.

Returns:

The wallet’s address as a hex string

Return type:

str

get_balance()

Get the wallet balance in native currency.

Returns:

The wallet’s balance in wei as a Decimal

Return type:

Decimal

Raises:

Exception – If wallet is not initialized

get_name()

Get the name of the wallet provider.

Returns:

The string ‘cdp_wallet_provider’

Return type:

str

get_network()

Get the current network.

Returns:

Network object containing protocol family, network ID, and chain ID

Return type:

Network

native_transfer(to, value)

Transfer the native asset of the network.

Parameters:
  • to (str) – The destination address to receive the transfer

  • value (Decimal) – The amount to transfer in whole units (e.g. 1.5 for 1.5 ETH)

Returns:

The transaction hash as a string

Return type:

str

Raises:

Exception – If transfer fails or wallet is not initialized

read_contract(contract_address, abi, function_name, args=None, block_identifier='latest')

Read data from a smart contract.

Parameters:
  • contract_address (ChecksumAddress) – The address of the contract to read from

  • abi (list[dict[str, Any]]) – The ABI of the contract

  • function_name (str) – The name of the function to call

  • args (list[Any] | None) – Arguments to pass to the function call, defaults to empty list

  • block_identifier (BlockIdentifier) – The block number to read from, defaults to ‘latest’

Returns:

The result of the contract function call

Return type:

Any

Raises:

Exception – If the contract call fails or wallet is not initialized

send_transaction(transaction)

Send a signed transaction to the network.

Parameters:

transaction (TxParams) – Transaction parameters including to, value, and data

Returns:

The transaction hash as a hex string

Return type:

HexStr

Raises:

Exception – If transaction preparation or sending fails

sign_message(message)

Sign a message using the wallet’s private key.

Parameters:

message (str | bytes) – The message to sign, either as a string or bytes

Returns:

The signature as a hex string

Return type:

HexStr

Raises:

Exception – If the wallet is not initialized or signing fails

sign_transaction(transaction)

Sign an EVM transaction.

Parameters:

transaction (TxParams) – Transaction parameters including to, value, and data

Returns:

The transaction signature as a hex string

Return type:

HexStr

Raises:

Exception – If wallet is not initialized or signing fails

sign_typed_data(typed_data)

Sign typed data according to EIP-712 standard.

Parameters:

typed_data (dict[str, Any]) – The typed data to sign following EIP-712 format

Returns:

The signature as a hex string

Return type:

HexStr

Raises:

Exception – If the wallet is not initialized or signing fails

trade(amount, from_asset_id, to_asset_id)

Trade a specified amount of one asset for another.

Parameters:
  • amount (str) – The amount of the from asset to trade, e.g. 15, 0.000001.

  • from_asset_id (str) – The from asset ID to trade (e.g., “eth”, “usdc”, or a valid contract address).

  • to_asset_id (str) – The to asset ID to trade (e.g., “eth”, “usdc”, or a valid contract address).

Returns:

A message containing the trade details and transaction information

Return type:

str

Raises:

Exception – If trade fails or wallet is not initialized

wait_for_transaction_receipt(tx_hash, timeout=120, poll_latency=0.1)

Wait for transaction confirmation and return receipt.

Parameters:
  • tx_hash (HexStr) – The transaction hash to wait for

  • timeout (float) – Maximum time to wait in seconds, defaults to 120

  • poll_latency (float) – Time between polling attempts in seconds, defaults to 0.1

Returns:

The transaction receipt as a dictionary

Return type:

dict[str, Any]

Raises:

TimeoutError – If transaction is not mined within timeout period

class coinbase_agentkit.CdpWalletProviderConfig(**data)

Bases: CdpProviderConfig

Configuration options for CDP wallet provider.

gas: EvmGasConfig | None
mnemonic_phrase: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

network_id: str | None
wallet_data: str | None
class coinbase_agentkit.EthAccountWalletProvider(config)

Bases: EvmWalletProvider

A wallet provider that uses eth-account and web3.py for EVM chain interactions.

estimate_fees()

Estimate gas fees for a transaction, applying the configured fee multipliers.

Returns:

Tuple of (max_priority_fee_per_gas, max_fee_per_gas) in wei

Return type:

tuple[int, int]

get_address()

Get the wallet address.

Returns:

The wallet’s address as a hex string.

Return type:

str

get_balance()

Get the wallet balance in native currency.

Returns:

The wallet’s balance in wei as a Decimal

Return type:

Decimal

get_name()

Get the name of the wallet provider.

Returns:

The string ‘eth_account_wallet_provider’

Return type:

str

get_network()

Get the current network.

Returns:

Network object containing protocol family, network ID, and chain ID.

Return type:

Network

native_transfer(to, value)

Transfer the native asset of the network.

Parameters:
  • to (str) – The destination address to receive the transfer

  • value (Decimal) – The amount to transfer in whole units (e.g. 1.5 for 1.5 ETH)

Returns:

The transaction hash as a string

Return type:

str

Raises:

Exception – If transfer fails

read_contract(contract_address, abi, function_name, args=None, block_identifier='latest')

Read data from a smart contract.

Parameters:
  • contract_address (ChecksumAddress) – The address of the contract to read from

  • abi (list[dict[str, Any]]) – The ABI of the contract

  • function_name (str) – The name of the function to call

  • args (list[Any] | None) – Arguments to pass to the function call, defaults to empty list

  • block_identifier (BlockIdentifier) – The block number to read from, defaults to ‘latest’

Returns:

The result of the contract function call

Return type:

Any

send_transaction(transaction)

Send a signed transaction to the network.

Parameters:

transaction (TxParams) – Transaction parameters including to, value, and data

Returns:

The transaction hash as a hex string

Return type:

HexStr

Raises:

Exception – If transaction preparation or sending fails

sign_message(message)

Sign a message using the wallet’s private key.

Parameters:

message (str | bytes) – The message to sign, either as a string or bytes

Returns:

The signature as a hex string

Return type:

HexStr

sign_transaction(transaction)

Sign an EVM transaction.

Parameters:

transaction (TxParams) – Transaction parameters including to, value, and data.

Returns:

The signed transaction object

Return type:

SignedTransaction

sign_typed_data(typed_data)

Sign typed data according to EIP-712 standard.

Parameters:

typed_data (dict[str, Any]) – The typed data to sign following EIP-712 format

Returns:

The signature as a hex string

Return type:

HexStr

wait_for_transaction_receipt(tx_hash, timeout=120, poll_latency=0.1)

Wait for transaction confirmation and return receipt.

Parameters:
  • tx_hash (HexStr) – The transaction hash to wait for

  • timeout (float) – Maximum time to wait in seconds, defaults to 120

  • poll_latency (float) – Time between polling attempts in seconds, defaults to 0.1

Returns:

The transaction receipt as a dictionary

Return type:

dict[str, Any]

Raises:

TimeoutError – If transaction is not mined within timeout period

class coinbase_agentkit.EthAccountWalletProviderConfig(**data)

Bases: BaseModel

Configuration for EthAccountWalletProvider.

class Config

Bases: object

Configuration for EthAccountWalletProvider.

arbitrary_types_allowed = True
account: LocalAccount
chain_id: str
gas: EvmGasConfig | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rpc_url: str | None
class coinbase_agentkit.EvmWalletProvider(*args, **kwargs)

Bases: WalletProvider, ABC

Abstract base class for all EVM wallet providers.

abstract read_contract(contract_address, abi, function_name, args=None, block_identifier='latest')

Read data from a smart contract.

Return type:

Any

abstract send_transaction(transaction)

Send a signed transaction to the network.

Return type:

NewType(HexStr, str)

abstract sign_message(message)

Sign a message using the wallet’s private key.

Return type:

NewType(HexStr, str)

abstract sign_transaction(transaction)

Sign an EVM transaction.

Return type:

SignedTransaction

abstract sign_typed_data(typed_data)

Sign typed data according to EIP-712 standard.

Return type:

NewType(HexStr, str)

abstract wait_for_transaction_receipt(tx_hash, timeout=120, poll_latency=0.1)

Wait for transaction confirmation and return receipt.

Return type:

dict[str, Any]

class coinbase_agentkit.SmartWalletProvider(config)

Bases: EvmWalletProvider

A wallet provider that uses the Coinbase Smart Wallet SDK.

get_address()

Get the smart wallet address.

Return type:

str

get_balance()

Get the balance of the smart wallet.

Return type:

Decimal

get_name()

Get the name of the wallet provider.

Return type:

str

get_network()

Get the network information.

Return type:

Network

native_transfer(to, value)

Transfer native assets using the smart wallet.

Return type:

NewType(HexStr, str)

read_contract(contract_address, abi, function_name, args=None, block_identifier='latest')

Read data from a smart contract.

Return type:

Any

send_transaction(transaction)

Send a transaction using the smart wallet.

Unlike traditional Ethereum transactions, this method submits a User Operation instead of directly broadcasting a transaction. The smart wallet handles execution, but a standard transaction hash is still returned upon completion.

Return type:

NewType(HexStr, str)

send_user_operation(calls)

Send a user operation directly.

This method directly exposes the sendUserOperation functionality, allowing SmartWallet-aware tools to fully leverage its capabilities, including batching multiple calls. Unlike send_transaction, which wraps calls in a single operation, this method allows direct execution of arbitrary operations within a User Operation.

Return type:

NewType(HexStr, str)

sign_message(message)

Smart wallets cannot sign raw messages.

Raises:

NotImplementedError – Always, since smart wallets do not support signing raw messages.

Return type:

NewType(HexStr, str)

sign_transaction(transaction)

Smart wallets cannot sign transactions.

Raises:

NotImplementedError – Always, since smart wallets do not support signing transactions.

Return type:

SignedTransaction

sign_typed_data(typed_data)

Smart wallets cannot sign typed data.

Raises:

NotImplementedError – Always, since smart wallets do not support signing typed data.

Return type:

NewType(HexStr, str)

wait_for_transaction_receipt(tx_hash, timeout=120, poll_latency=0.1)

Wait for a transaction receipt.

Return type:

dict[str, Any]

class coinbase_agentkit.SmartWalletProviderConfig(**data)

Bases: BaseModel

Configuration for SmartWalletProvider.

class Config

Bases: object

Configuration for SmartWalletProvider.

arbitrary_types_allowed = True
cdp_api_key_name: str | None
cdp_api_key_private_key: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

network_id: str
paymaster_url: str | None
signer: LocalAccount
smart_wallet_address: str | None
class coinbase_agentkit.WalletProvider(*args, **kwargs)

Bases: ABC

Base class for all wallet providers.

abstract get_address()

Get the wallet address.

Return type:

str

abstract get_balance()

Get the wallet balance in native currency.

Return type:

Decimal

abstract get_name()

Get the name of the wallet provider.

Return type:

str

abstract get_network()

Get the current network.

Return type:

Network

abstract native_transfer(to, value)

Transfer the native asset of the network.

Return type:

str

abstract sign_message(message)

Sign a message with the wallet.

Return type:

str

track_initialization()

Track the initialization of the wallet provider.

Return type:

None

coinbase_agentkit.allora_action_provider(api_key=None, chain_slug=None)

Create a new Allora action provider.

Returns:

A new Allora action provider instance.

Return type:

AlloraActionProvider

coinbase_agentkit.basename_action_provider()

Create a new Basename action provider.

Returns:

A new Basename action provider instance.

Return type:

BasenameActionProvider

coinbase_agentkit.cdp_api_action_provider(config=None)

Create a new CDP API action provider.

Parameters:

config (CdpProviderConfig | None) – Configuration for the CDP API provider.

Returns:

A new CDP API action provider instance.

Return type:

CdpApiActionProvider

coinbase_agentkit.cdp_wallet_action_provider(config=None)

Create a new CDP wallet action provider.

Parameters:

config (CdpProviderConfig | None) – Configuration for the CDP wallet provider.

Returns:

A new CDP wallet action provider instance.

Return type:

CdpWalletActionProvider

coinbase_agentkit.compound_action_provider()

Create a new CompoundActionProvider instance.

Return type:

CompoundActionProvider

coinbase_agentkit.create_action(name, description, schema=None)

Decorate an action with a name, description, and schema.

coinbase_agentkit.erc20_action_provider()

Create a new instance of the ERC20 action provider.

Return type:

ERC20ActionProvider

Returns:

A new ERC20 action provider instance.

coinbase_agentkit.hyperbolic_action_provider(api_key=None)

Create a new instance of the HyperbolicActionProvider.

Parameters:

api_key (Optional[str]) – Optional API key for authentication. If not provided, will attempt to read from HYPERBOLIC_API_KEY environment variable.

Return type:

HyperbolicActionProvider

Returns:

A new Hyperbolic action provider instance.

coinbase_agentkit.morpho_action_provider()

Create a new Morpho action provider.

Returns:

A new Morpho action provider instance.

Return type:

MorphoActionProvider

coinbase_agentkit.pyth_action_provider()

Create a new Pyth action provider.

Returns:

A new Pyth action provider instance.

Return type:

PythActionProvider

coinbase_agentkit.ssh_action_provider(max_connections=10)

Create a new instance of the SshActionProvider.

Parameters:

max_connections (int) – Maximum number of concurrent SSH connections (default: 10)

Return type:

SshActionProvider

Returns:

An initialized SshActionProvider

coinbase_agentkit.superfluid_action_provider()

Create a new Superfluid action provider.

Returns:

A new Superfluid action provider instance.

Return type:

SuperfluidActionProvider

coinbase_agentkit.twitter_action_provider(api_key=None, api_secret=None, access_token=None, access_token_secret=None, bearer_token=None)

Create and return a new TwitterActionProvider instance.

Return type:

TwitterActionProvider

coinbase_agentkit.wallet_action_provider()

Create a new WalletActionProvider instance.

Returns:

A new wallet action provider instance.

Return type:

WalletActionProvider

coinbase_agentkit.weth_action_provider()

Create a new WethActionProvider instance.

Returns:

A new instance of the WETH action provider.

Return type:

WethActionProvider

coinbase_agentkit.wow_action_provider()

Create a new WowActionProvider instance.

Return type:

WowActionProvider