# AgentKit
AgentKit is a framework for easily enabling AI agents to take actions onchain. It is designed to be framework-agnostic, so you can use it with any AI framework, and wallet-agnostic, so you can use it with any wallet.
## Table of Contents
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Create an AgentKit instance](#create-an-agentkit-instance)
- [Create an AgentKit instance with a specified wallet provider](#create-an-agentkit-instance-with-a-specified-wallet-provider)
- [Create an AgentKit instance with specified action providers](#create-an-agentkit-instance-with-specified-action-providers)
- [Use with a framework extension (e.g., LangChain + OpenAI)](#use-with-a-framework-extension)
- [Creating an Action Provider](#creating-an-action-provider)
- [Adding Actions to your Action Provider](#adding-actions-to-your-action-provider)
- [Adding Actions that use a Wallet Provider](#adding-actions-that-use-a-wallet-provider)
- [Adding an Action Provider to your AgentKit instance](#adding-an-action-provider-to-your-agentkit-instance)
- [Action Providers](#action-providers)
- [Wallet Providers](#wallet-providers)
- [CdpEvmWalletProvider](#cdpevmwalletprovider)
- [Network Configuration](#network-configuration)
- [Configuring from an existing CDP API Wallet](#configuring-from-an-existing-cdp-api-wallet)
- [Creating a new wallet](#creating-a-new-wallet)
- [Example Usage with AgentKit](#example-usage-with-agentkit)
- [CdpSmartWalletProvider](#cdpsmartwalletprovider)
- [Network Configuration](#network-configuration)
- [Configuring with a Private Key Owner](#configuring-with-a-private-key-owner)
- [Configuring with a Server Wallet Owner](#configuring-with-a-server-wallet-owner)
- [Creating a New Smart Wallet](#creating-a-new-smart-wallet)
- [Gasless Transactions with Paymaster](#gasless-transactions-with-paymaster)
- [Example Usage with AgentKit](#example-usage-with-agentkit)
- [EthAccountWalletProvider](#ethaccountwalletprovider)
- [Configuring gas parameters](#configuring-ethaccountwalletprovider-gas-parameters)
- [Configuring `EthAccountWalletProvider` rpc url](#configuring-ethaccountwalletprovider-rpc-url)
- [SmartWalletProvider](#smartwalletprovider)
- [CdpSolanaWalletProvider](#cdpsolanawalletprovider)
- [Configuring with API credentials](#configuring-with-api-credentials)
- [Using environment variables](#using-environment-variables)
- [Example Usage with AgentKit](#example-usage-with-agentkit)
- [Contributing](#contributing)
## Getting Started
_Prerequisites_:
- [Python 3.10+](https://www.python.org/downloads/)
- [CDP Secret API Key](https://docs.cdp.coinbase.com/get-started/docs/cdp-api-keys#creating-secret-api-keys)
## Installation
```bash
pip install coinbase-agentkit
```
## Usage
### Create an AgentKit instance
If no wallet or action providers are specified, the agent will use the `CdpWalletProvider` and `WalletActionProvider` action provider by default.
```python
from coinbase_agentkit import AgentKit, AgentKitConfig
agent_kit = AgentKit()
```
### Create an AgentKit instance with a specified wallet provider
```python
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
CdpWalletProvider,
CdpWalletProviderConfig
)
wallet_provider = CdpWalletProvider(CdpWalletProviderConfig(
api_key_id="CDP API KEY NAME",
api_key_secret="CDP API KEY SECRET",
network_id="base-mainnet"
))
agent_kit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider
))
```
### Create an AgentKit instance with specified action providers
```python
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
cdp_api_action_provider,
pyth_action_provider
)
agent_kit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider,
action_providers=[
cdp_api_action_provider(
api_key_id="CDP API KEY NAME",
api_key_secret="CDP API KEY SECRET"
),
pyth_action_provider()
]
))
```
### Use with a framework extension
Example using LangChain + OpenAI:
_Prerequisites_:
- [OpenAI API Key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)
- Set `OPENAI_API_KEY` environment variable
```bash
pip install coinbase-agentkit-langchain langchain-openai langgraph
```
```python
from coinbase_agentkit_langchain import get_langchain_tools
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
tools = get_langchain_tools(agent_kit)
llm = ChatOpenAI(model="gpt-4")
agent = create_react_agent(
llm=llm,
tools=tools
)
```
## Creating an Action Provider
Action providers define the actions that an agent can take. They are created by subclassing the `ActionProvider` abstract class.
```python
from coinbase_agentkit import ActionProvider, WalletProvider
from coinbase_agentkit.network import Network
class MyActionProvider(ActionProvider[WalletProvider]):
def __init__(self):
super().__init__("my-action-provider", [])
# Define if the action provider supports the given network
def supports_network(self, network: Network) -> bool:
return True
```
### Adding Actions to your Action Provider
Actions are defined using the `@create_action` decorator. They can optionally use a wallet provider and must return a string.
1. Define the action schema using Pydantic:
```python
from pydantic import BaseModel
class MyActionSchema(BaseModel):
my_field: str
```
2. Define the action:
```python
from coinbase_agentkit import ActionProvider, WalletProvider, create_action
from coinbase_agentkit.network import Network
class MyActionProvider(ActionProvider[WalletProvider]):
def __init__(self):
super().__init__("my-action-provider", [])
@create_action(
name="my-action",
description="My action description",
schema=MyActionSchema
)
def my_action(self, args: dict[str, Any]) -> str:
return args["my_field"]
def supports_network(self, network: Network) -> bool:
return True
def my_action_provider():
return MyActionProvider()
```
### Adding Actions that use a Wallet Provider
Actions that need access to a wallet provider can include it as their first parameter:
```python
from coinbase_agentkit import ActionProvider, WalletProvider, create_action
class MyActionProvider(ActionProvider[WalletProvider]):
@create_action(
name="my-action",
description="My action description",
schema=MyActionSchema
)
def my_action(self, wallet_provider: WalletProvider, args: dict[str, Any]) -> str:
return wallet_provider.sign_message(args["my_field"])
```
### Adding an Action Provider to your AgentKit instance
```python
agent_kit = AgentKit(AgentKitConfig(
cdp_api_key_id="CDP API KEY ID",
cdp_api_key_secret="CDP API KEY SECRET",
action_providers=[my_action_provider()]
))
```
## Action Providers
This section provides a detailed list of all available action providers and their actions.
<details>
<summary><strong>Basename</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>register_basename</code></td>
<td width="768">Registers a custom .base.eth or .basetest.eth domain name for the wallet address.</td>
</tr>
</table>
</details>
<details>
<summary><strong>CDP API</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>request_faucet_funds</code></td>
<td width="768">Requests testnet ETH, USDC, EURC or CBBTC.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Compound</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>supply</code></td>
<td width="768">Supplies collateral assets (WETH, CBETH, CBBTC, WSTETH, or USDC) to Compound.</td>
</tr>
<tr>
<td width="200"><code>withdraw</code></td>
<td width="768">Withdraws previously supplied collateral assets from Compound.</td>
</tr>
<tr>
<td width="200"><code>borrow</code></td>
<td width="768">Borrows base assets (WETH or USDC) from Compound using supplied collateral.</td>
</tr>
<tr>
<td width="200"><code>repay</code></td>
<td width="768">Repays borrowed assets back to Compound.</td>
</tr>
<tr>
<td width="200"><code>get_portfolio</code></td>
<td width="768">Retrieves portfolio details including collateral balances and borrowed amounts.</td>
</tr>
</table>
</details>
<details>
<summary><strong>ERC20</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>get_balance</code></td>
<td width="768">Retrieves the token balance for a specified address and ERC-20 contract.</td>
</tr>
<tr>
<td width="200"><code>transfer</code></td>
<td width="768">Transfers a specified amount of ERC-20 tokens to a destination address.</td>
</tr>
</table>
</details>
<details>
<summary><strong>ERC721</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>get_balance</code></td>
<td width="768">Retrieves the NFT balance for a specified address and ERC-721 contract.</td>
</tr>
<tr>
<td width="200"><code>transfer</code></td>
<td width="768">Transfers ownership of a specific NFT token to a destination address.</td>
</tr>
<tr>
<td width="200"><code>mint</code></td>
<td width="768">Creates a new NFT token and assigns it to a specified destination address.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Hyperbolic</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>generate_text</code></td>
<td width="768">Generate text using AI models.</td>
</tr>
<tr>
<td width="200"><code>generate_image</code></td>
<td width="768">Generate images using AI models.</td>
</tr>
<tr>
<td width="200"><code>generate_audio</code></td>
<td width="768">Generate text-to-speech audio.</td>
</tr>
<tr>
<td width="200"><code>get_available_gpus</code></td>
<td width="768">Get available GPU resources.</td>
</tr>
<tr>
<td width="200"><code>get_available_gpus_by_type</code></td>
<td width="768">Get GPUs filtered by model type.</td>
</tr>
<tr>
<td width="200"><code>get_available_gpus_types</code></td>
<td width="768">Get list of available GPU types.</td>
</tr>
<tr>
<td width="200"><code>get_gpu_status</code></td>
<td width="768">Check status of GPU resources.</td>
</tr>
<tr>
<td width="200"><code>rent_compute</code></td>
<td width="768">Rent GPU compute resources.</td>
</tr>
<tr>
<td width="200"><code>terminate_compute</code></td>
<td width="768">Terminate a rented GPU compute instance.</td>
</tr>
<tr>
<td width="200"><code>get_current_balance</code></td>
<td width="768">Get current account balance.</td>
</tr>
<tr>
<td width="200"><code>get_purchase_history</code></td>
<td width="768">Get purchase history.</td>
</tr>
<tr>
<td width="200"><code>get_spend_history</code></td>
<td width="768">Get spending history.</td>
</tr>
<tr>
<td width="200"><code>link_wallet_address</code></td>
<td width="768">Link a wallet address to your account.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Morpho</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>deposit</code></td>
<td width="768">Deposits a specified amount of assets into a designated Morpho Vault.</td>
</tr>
<tr>
<td width="200"><code>withdraw</code></td>
<td width="768">Withdraws a specified amount of assets from a designated Morpho Vault.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Nillion</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>lookup_schema</code></td>
<td width="768">Looks up a schema by description and returns both the schema UUID and corresponding JSON schema.</td>
</tr>
<tr>
<td width="200"><code>create_schema</code></td>
<td width="768">Creates a new schema in the Nillion SecretVault based on a natural language description.</td>
</tr>
<tr>
<td width="200"><code>data_upload</code></td>
<td width="768">Uploads data into the Nillion SecretVault using a specified schema UUID.</td>
</tr>
<tr>
<td width="200"><code>data_download</code></td>
<td width="768">Downloads all data from the Nillion SecretVault for a specified schema UUID.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Onramp</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>get_onramp_buy_url</code></td>
<td width="768">Gets a URL to purchase cryptocurrency from Coinbase via Debit card or other payment methods.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Pyth</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>fetch_price</code></td>
<td width="768">Retrieves current price data from a specified Pyth price feed.</td>
</tr>
<tr>
<td width="200"><code>fetch_price_feed_id</code></td>
<td width="768">Retrieves the unique price feed identifier for a given token symbol.</td>
</tr>
</table>
</details>
<details>
<summary><strong>SSH</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>ssh_connect</code></td>
<td width="768">Establishes an SSH connection to a remote server.</td>
</tr>
<tr>
<td width="200"><code>remote_shell</code></td>
<td width="768">Executes shell commands on a remote server via SSH.</td>
</tr>
<tr>
<td width="200"><code>ssh_status</code></td>
<td width="768">Checks status of SSH connections.</td>
</tr>
<tr>
<td width="200"><code>ssh_list_connections</code></td>
<td width="768">Lists active SSH connections.</td>
</tr>
<tr>
<td width="200"><code>ssh_disconnect</code></td>
<td width="768">Disconnects from an SSH server.</td>
</tr>
<tr>
<td width="200"><code>ssh_add_host_key</code></td>
<td width="768">Adds an SSH host key to known_hosts.</td>
</tr>
<tr>
<td width="200"><code>sftp_upload</code></td>
<td width="768">Uploads files to a remote server via SFTP.</td>
</tr>
<tr>
<td width="200"><code>sftp_download</code></td>
<td width="768">Downloads files from a remote server via SFTP.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Superfluid</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>create_flow</code></td>
<td width="768">Creates a new token streaming flow to a recipient address.</td>
</tr>
<tr>
<td width="200"><code>delete_flow</code></td>
<td width="768">Deletes an existing token streaming flow.</td>
</tr>
<tr>
<td width="200"><code>get_flow</code></td>
<td width="768">Gets details of an existing token streaming flow.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Twitter</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>account_details</code></td>
<td width="768">Fetches profile information and metadata for the authenticated Twitter account.</td>
</tr>
<tr>
<td width="200"><code>account_mentions</code></td>
<td width="768">Retrieves recent mentions and interactions for the authenticated account.</td>
</tr>
<tr>
<td width="200"><code>post_tweet</code></td>
<td width="768">Creates a new tweet on the authenticated Twitter account.</td>
</tr>
<tr>
<td width="200"><code>post_tweet_reply</code></td>
<td width="768">Creates a reply to an existing tweet using the tweet's unique identifier.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Wallet</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>get_wallet_details</code></td>
<td width="768">Retrieves wallet address, network info, balances, and provider details.</td>
</tr>
<tr>
<td width="200"><code>get_balance</code></td>
<td width="768">Gets the native currency balance of the connected wallet.</td>
</tr>
<tr>
<td width="200"><code>native_transfer</code></td>
<td width="768">Transfers native blockchain tokens (e.g., ETH) to a destination address.</td>
</tr>
</table>
</details>
<details>
<summary><strong>WETH</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>wrap_eth</code></td>
<td width="768">Converts native ETH to Wrapped ETH (WETH) on supported networks.</td>
</tr>
</table>
</details>
<details>
<summary><strong>WOW</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>buy_token</code></td>
<td width="768">Purchases WOW tokens from a contract using ETH based on bonding curve pricing.</td>
</tr>
<tr>
<td width="200"><code>create_token</code></td>
<td width="768">Creates a new WOW memecoin with bonding curve functionality via Zora factory.</td>
</tr>
<tr>
<td width="200"><code>sell_token</code></td>
<td width="768">Sells WOW tokens back to the contract for ETH based on bonding curve pricing.</td>
</tr>
</table>
</details>
<details>
<summary><strong>x402</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>make_http_request</code></td>
<td width="768">Makes a basic HTTP request to an API endpoint. If the endpoint requires payment (returns 402), it will return payment details that can be used with retry_http_request_with_x402.</td>
</tr>
<tr>
<td width="200"><code>retry_http_request_with_x402</code></td>
<td width="768">Retries an HTTP request with x402 payment after receiving a 402 Payment Required response. This should be used after make_http_request returns a 402 response.</td>
</tr>
<tr>
<td width="200"><code>make_http_request_with_x402</code></td>
<td width="768">Makes an HTTP request with automatic x402 payment handling. Only use when explicitly told to skip the confirmation flow.</td>
</tr>
</table>
</details>
## Wallet Providers
AgentKit supports the following wallet providers:
EVM:
- [CdpEvmWalletProvider](https://github.com/coinbase/agentkit/blob/master/python/coinbase-agentkit/coinbase_agentkit/wallet_providers/cdp_evm_wallet_provider.py) - Uses the Coinbase Developer Platform (CDP) API Server Wallet
- [CdpSmartWalletProvider](https://github.com/coinbase/agentkit/blob/master/python/coinbase-agentkit/coinbase_agentkit/wallet_providers/cdp_smart_wallet_provider.py) - Uses the Coinbase Developer Platform (CDP) API Smart Wallet
- [EthAccountWalletProvider](https://github.com/coinbase/agentkit/blob/master/python/coinbase-agentkit/coinbase_agentkit/wallet_providers/eth_account_wallet_provider.py) - Uses a local private key for any EVM-compatible chain
### CdpEvmWalletProvider
The `CdpEvmWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [API Server Wallet](https://docs.cdp.coinbase.com/wallet-api/docs/welcome).
#### Network Configuration
The `CdpEvmWalletProvider` can be configured to use a specific network by passing the `network_id` parameter to the `CdpEvmWalletProviderConfig`. The `network_id` is the ID of the network you want to use. You can find a list of [supported networks on the CDP API docs](https://docs.cdp.coinbase.com/cdp-apis/docs/networks).
```python
from coinbase_agentkit import CdpEvmWalletProvider, CdpEvmWalletProviderConfig
wallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
network_id="base-mainnet",
))
```
#### Configuring from an existing CDP API Wallet
If you already have a CDP API Wallet, you can configure the `CdpEvmWalletProvider` by passing the `address` parameter to the config.
```python
from coinbase_agentkit import CdpEvmWalletProvider, CdpEvmWalletProviderConfig
wallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
address="YOUR_WALLET_ADDRESS",
))
```
#### Creating a new wallet
The `CdpEvmWalletProvider` can create a new wallet by providing an `idempotency_key`. If no `address` is provided, a new wallet will be created.
```python
from coinbase_agentkit import CdpEvmWalletProvider, CdpEvmWalletProviderConfig
wallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
idempotency_key="UNIQUE_IDEMPOTENCY_KEY",
))
```
#### Example Usage with AgentKit
Here's a complete example of using `CdpEvmWalletProvider` with AgentKit:
```python
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
CdpEvmWalletProvider,
CdpEvmWalletProviderConfig,
cdp_api_action_provider,
erc20_action_provider,
pyth_action_provider,
wallet_action_provider,
weth_action_provider,
)
# Initialize the wallet provider
wallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
network_id="base-sepolia",
))
# Create AgentKit instance with wallet and action providers
agentkit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider,
action_providers=[
cdp_api_action_provider(),
erc20_action_provider(),
pyth_action_provider(),
wallet_action_provider(),
weth_action_provider(),
],
))
```
### CdpSmartWalletProvider
The `CdpSmartWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [Smart Wallets](https://docs.cdp.coinbase.com/wallet-api/docs/smart-wallets). Smart wallets are controlled by an owner, which can be either an EVM private key or a CDP server wallet address.
#### Network Configuration
The `CdpSmartWalletProvider` can be configured to use a specific network by passing the `network_id` parameter to the `CdpSmartWalletProviderConfig`. The `network_id` is the ID of the network you want to use. You can find a list of [supported networks on the CDP API docs](https://docs.cdp.coinbase.com/cdp-apis/docs/networks).
```python
from coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig
wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
network_id="base-mainnet",
owner="OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS",
))
```
#### Configuring with a Private Key Owner
You can configure the `CdpSmartWalletProvider` with a private key owner:
```python
from coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig
wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
owner="0x123...", # Private key
network_id="base-sepolia",
))
```
#### Configuring with a Server Wallet Owner
You can also configure the `CdpSmartWalletProvider` with a CDP server wallet address as the owner:
```python
from coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig
wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
owner="0x456...", # Server wallet address
network_id="base-sepolia",
))
```
#### Creating a New Smart Wallet
If no `address` is provided, a new smart wallet will be created for the owner. You can optionally provide an `idempotency_key` to ensure idempotent wallet creation:
```python
from coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig
wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
owner="OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS",
idempotency_key="UNIQUE_IDEMPOTENCY_KEY",
))
```
#### Gasless Transactions with Paymaster
You can enable gasless transactions by providing a paymaster URL:
```python
from coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig
wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProvideronfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
owner="OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS",
paymaster_url="https://your-paymaster-url.com", # Optional paymaster URL for gasless transactions
))
```
#### Example Usage with AgentKit
Here's a complete example of using `CdpSmartWalletProvider` with AgentKit:
```python
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
CdpSmartWalletProvider,
CdpSmartWalletProviderConfig,
cdp_api_action_provider,
erc20_action_provider,
pyth_action_provider,
wallet_action_provider,
weth_action_provider,
)
# Initialize the wallet provider
wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
owner="OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS",
network_id="base-sepolia",
))
# Create AgentKit instance with wallet and action providers
agentkit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider,
action_providers=[
cdp_api_action_provider(),
erc20_action_provider(),
pyth_action_provider(),
wallet_action_provider(),
weth_action_provider(),
],
))
```
### EthAccountWalletProvider
Example usage with a private key:
```python
import os
from eth_account import Account
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
EthAccountWalletProvider,
EthAccountWalletProviderConfig
)
# See here for creating a private key:
# https://web3py.readthedocs.io/en/stable/web3.eth.account.html#creating-a-private-key
private_key = os.environ.get("PRIVATE_KEY")
assert private_key is not None, "You must set PRIVATE_KEY environment variable"
assert private_key.startswith("0x"), "Private key must start with 0x hex prefix"
account = Account.from_key(private_key)
wallet_provider = EthAccountWalletProvider(
config=EthAccountWalletProviderConfig(
account=account,
chain_id="84532",
)
)
agent_kit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider
))
```
#### Configuring `EthAccountWalletProvider` gas parameters
The `EthAccountWalletProvider` also exposes parameters for effecting the gas calculations.
```python
import os
from eth_account import Account
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
EthAccountWalletProvider,
EthAccountWalletProviderConfig
)
private_key = os.environ.get("PRIVATE_KEY")
assert private_key is not None, "You must set PRIVATE_KEY environment variable"
assert private_key.startswith("0x"), "Private key must start with 0x hex prefix"
account = Account.from_key(private_key)
wallet_provider = EthAccountWalletProvider(
config=EthAccountWalletProviderConfig(
account=account,
chain_id="84532",
gas={
"gas_limit_multiplier": 2,
"fee_per_gas_multiplier": 2
}
)
)
agent_kit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider
))
```
#### Configuring `EthAccountWalletProvider` rpc url
The `EthAccountWalletProvider` also exposes parameters for defining the rpc url manually.
```python
import os
from eth_account import Account
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
EthAccountWalletProvider,
EthAccountWalletProviderConfig
)
private_key = os.environ.get("PRIVATE_KEY")
assert private_key is not None, "You must set PRIVATE_KEY environment variable"
assert private_key.startswith("0x"), "Private key must start with 0x hex prefix"
account = Account.from_key(private_key)
wallet_provider = EthAccountWalletProvider(
config=EthAccountWalletProviderConfig(
account=account,
rpc_url="https://sepolia.base.org",
)
)
agent_kit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider
))
```
### CDPSmartWalletProvider
The `CDPSmartWalletProvider` is a wallet provider that uses [CDP Smart Wallets](https://docs.cdp.coinbase.com/wallet-api/docs/smart-wallets).
```python
import os
from eth_account import Account
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
SmartWalletProvider,
SmartWalletProviderConfig
)
# See here for creating a private key:
# https://web3py.readthedocs.io/en/stable/web3.eth.account.html#creating-a-private-key
private_key = os.environ.get("PRIVATE_KEY")
assert private_key is not None, "You must set PRIVATE_KEY environment variable"
assert private_key.startswith("0x"), "Private key must start with 0x hex prefix"
signer = Account.from_key(private_key)
network_id = os.getenv("NETWORK_ID", "base-sepolia")
wallet_provider = SmartWalletProvider(SmartWalletProviderConfig(
network_id=network_id,
signer=signer,
smart_wallet_address=None, # If not provided, a new smart wallet will be created
paymaster_url=None, # Sponsor transactions: https://docs.cdp.coinbase.com/paymaster/docs/welcome
))
agent_kit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider
))
```
### CdpSolanaWalletProvider
The `CdpSolanaWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) API for Solana networks. It supports SOL transfers and message signing on Solana mainnet, devnet, and testnet.
#### Network Configuration
The `CdpSolanaWalletProvider` can be configured to use different Solana networks by setting the `network_id` parameter:
- `solana-mainnet` - Solana Mainnet
- `solana-devnet` - Solana Devnet (default)
- `solana-testnet` - Solana Testnet
```python
from coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig
wallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
network_id="solana-devnet",
))
```
#### Configuring with API credentials
You can configure the provider by passing CDP API credentials directly:
```python
from coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig
wallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
network_id="solana-mainnet",
))
```
#### Using environment variables
The provider can also read configuration from environment variables:
```python
from coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig
# Set environment variables:
# CDP_API_KEY_ID="your-api-key-id"
# CDP_API_KEY_SECRET="your-api-key-secret"
# CDP_WALLET_SECRET="your-wallet-secret"
# NETWORK_ID="solana-devnet"
wallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig())
```
#### Using an existing wallet
If you have an existing CDP Solana wallet, you can specify its address:
```python
from coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig
wallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
address="YOUR_EXISTING_SOLANA_ADDRESS",
network_id="solana-mainnet",
))
```
#### Example Usage with AgentKit
Here's a complete example of using `CdpSolanaWalletProvider` with AgentKit:
```python
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
CdpSolanaWalletProvider,
CdpSolanaWalletProviderConfig,
wallet_action_provider,
)
# Initialize the wallet provider
wallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(
api_key_id="CDP API KEY ID",
api_key_secret="CDP API KEY SECRET",
wallet_secret="CDP WALLET SECRET",
network_id="solana-devnet",
))
# Create AgentKit instance with wallet and action providers
agentkit = AgentKit(AgentKitConfig(
wallet_provider=wallet_provider,
action_providers=[
wallet_action_provider(), # Provides basic wallet operations for Solana
],
))
# The wallet provider supports:
# - Getting wallet address: wallet_provider.get_address()
# - Getting SOL balance: wallet_provider.get_balance()
# - Transferring SOL: wallet_provider.native_transfer(to, amount)
# - Signing messages: wallet_provider.sign_message(message)
```
## Contributing
See [CONTRIBUTING.md](https://github.com/coinbase/agentkit/blob/main/CONTRIBUTING.md) for more information.
Raw data
{
"_id": null,
"home_page": null,
"name": "coinbase-agentkit",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.10",
"maintainer_email": null,
"keywords": "agent, agentkit, ai, cdp, coinbase, crypto, sdk",
"author": null,
"author_email": "John Peterson <john.peterson@coinbase.com>",
"download_url": "https://files.pythonhosted.org/packages/6b/c4/bf1c392b48eafbd84b2ef56c46d79f1e1466e56dc6e01d2a5823e9c6351e/coinbase_agentkit-0.7.0.tar.gz",
"platform": null,
"description": "# AgentKit\n\nAgentKit is a framework for easily enabling AI agents to take actions onchain. It is designed to be framework-agnostic, so you can use it with any AI framework, and wallet-agnostic, so you can use it with any wallet.\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n- [Installation](#installation)\n- [Usage](#usage)\n - [Create an AgentKit instance](#create-an-agentkit-instance)\n - [Create an AgentKit instance with a specified wallet provider](#create-an-agentkit-instance-with-a-specified-wallet-provider)\n - [Create an AgentKit instance with specified action providers](#create-an-agentkit-instance-with-specified-action-providers)\n - [Use with a framework extension (e.g., LangChain + OpenAI)](#use-with-a-framework-extension)\n- [Creating an Action Provider](#creating-an-action-provider)\n - [Adding Actions to your Action Provider](#adding-actions-to-your-action-provider)\n - [Adding Actions that use a Wallet Provider](#adding-actions-that-use-a-wallet-provider)\n - [Adding an Action Provider to your AgentKit instance](#adding-an-action-provider-to-your-agentkit-instance)\n- [Action Providers](#action-providers)\n- [Wallet Providers](#wallet-providers)\n - [CdpEvmWalletProvider](#cdpevmwalletprovider)\n - [Network Configuration](#network-configuration)\n - [Configuring from an existing CDP API Wallet](#configuring-from-an-existing-cdp-api-wallet)\n - [Creating a new wallet](#creating-a-new-wallet)\n - [Example Usage with AgentKit](#example-usage-with-agentkit)\n - [CdpSmartWalletProvider](#cdpsmartwalletprovider)\n - [Network Configuration](#network-configuration)\n - [Configuring with a Private Key Owner](#configuring-with-a-private-key-owner)\n - [Configuring with a Server Wallet Owner](#configuring-with-a-server-wallet-owner)\n - [Creating a New Smart Wallet](#creating-a-new-smart-wallet)\n - [Gasless Transactions with Paymaster](#gasless-transactions-with-paymaster)\n - [Example Usage with AgentKit](#example-usage-with-agentkit)\n - [EthAccountWalletProvider](#ethaccountwalletprovider)\n - [Configuring gas parameters](#configuring-ethaccountwalletprovider-gas-parameters)\n - [Configuring `EthAccountWalletProvider` rpc url](#configuring-ethaccountwalletprovider-rpc-url)\n - [SmartWalletProvider](#smartwalletprovider)\n - [CdpSolanaWalletProvider](#cdpsolanawalletprovider)\n - [Configuring with API credentials](#configuring-with-api-credentials)\n - [Using environment variables](#using-environment-variables)\n - [Example Usage with AgentKit](#example-usage-with-agentkit)\n- [Contributing](#contributing)\n\n## Getting Started\n\n_Prerequisites_:\n\n- [Python 3.10+](https://www.python.org/downloads/)\n- [CDP Secret API Key](https://docs.cdp.coinbase.com/get-started/docs/cdp-api-keys#creating-secret-api-keys)\n\n## Installation\n\n```bash\npip install coinbase-agentkit\n```\n\n## Usage\n\n### Create an AgentKit instance\n\nIf no wallet or action providers are specified, the agent will use the `CdpWalletProvider` and `WalletActionProvider` action provider by default.\n\n```python\nfrom coinbase_agentkit import AgentKit, AgentKitConfig\n\nagent_kit = AgentKit()\n```\n\n### Create an AgentKit instance with a specified wallet provider\n\n```python\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n CdpWalletProvider,\n CdpWalletProviderConfig\n)\n\nwallet_provider = CdpWalletProvider(CdpWalletProviderConfig(\n api_key_id=\"CDP API KEY NAME\",\n api_key_secret=\"CDP API KEY SECRET\",\n network_id=\"base-mainnet\"\n))\n\nagent_kit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider\n))\n```\n\n### Create an AgentKit instance with specified action providers\n\n```python\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n cdp_api_action_provider,\n pyth_action_provider\n)\n\nagent_kit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider,\n action_providers=[\n cdp_api_action_provider(\n api_key_id=\"CDP API KEY NAME\",\n api_key_secret=\"CDP API KEY SECRET\"\n ),\n pyth_action_provider()\n ]\n))\n```\n\n### Use with a framework extension\n\nExample using LangChain + OpenAI:\n\n_Prerequisites_:\n\n- [OpenAI API Key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)\n- Set `OPENAI_API_KEY` environment variable\n\n```bash\npip install coinbase-agentkit-langchain langchain-openai langgraph\n```\n\n```python\nfrom coinbase_agentkit_langchain import get_langchain_tools\nfrom langgraph.prebuilt import create_react_agent\nfrom langchain_openai import ChatOpenAI\n\ntools = get_langchain_tools(agent_kit)\n\nllm = ChatOpenAI(model=\"gpt-4\")\n\nagent = create_react_agent(\n llm=llm,\n tools=tools\n)\n```\n\n## Creating an Action Provider\n\nAction providers define the actions that an agent can take. They are created by subclassing the `ActionProvider` abstract class.\n\n```python\nfrom coinbase_agentkit import ActionProvider, WalletProvider\nfrom coinbase_agentkit.network import Network\n\nclass MyActionProvider(ActionProvider[WalletProvider]):\n def __init__(self):\n super().__init__(\"my-action-provider\", [])\n\n # Define if the action provider supports the given network\n def supports_network(self, network: Network) -> bool:\n return True\n```\n\n### Adding Actions to your Action Provider\n\nActions are defined using the `@create_action` decorator. They can optionally use a wallet provider and must return a string.\n\n1. Define the action schema using Pydantic:\n\n```python\nfrom pydantic import BaseModel\n\nclass MyActionSchema(BaseModel):\n my_field: str\n```\n\n2. Define the action:\n\n```python\nfrom coinbase_agentkit import ActionProvider, WalletProvider, create_action\nfrom coinbase_agentkit.network import Network\n\nclass MyActionProvider(ActionProvider[WalletProvider]):\n def __init__(self):\n super().__init__(\"my-action-provider\", [])\n\n @create_action(\n name=\"my-action\",\n description=\"My action description\",\n schema=MyActionSchema\n )\n def my_action(self, args: dict[str, Any]) -> str:\n return args[\"my_field\"]\n\n def supports_network(self, network: Network) -> bool:\n return True\n\ndef my_action_provider():\n return MyActionProvider()\n```\n\n### Adding Actions that use a Wallet Provider\n\nActions that need access to a wallet provider can include it as their first parameter:\n\n```python\nfrom coinbase_agentkit import ActionProvider, WalletProvider, create_action\n\nclass MyActionProvider(ActionProvider[WalletProvider]):\n @create_action(\n name=\"my-action\",\n description=\"My action description\",\n schema=MyActionSchema\n )\n def my_action(self, wallet_provider: WalletProvider, args: dict[str, Any]) -> str:\n return wallet_provider.sign_message(args[\"my_field\"])\n```\n\n### Adding an Action Provider to your AgentKit instance\n\n```python\nagent_kit = AgentKit(AgentKitConfig(\n cdp_api_key_id=\"CDP API KEY ID\",\n cdp_api_key_secret=\"CDP API KEY SECRET\",\n action_providers=[my_action_provider()]\n))\n```\n\n## Action Providers\n\nThis section provides a detailed list of all available action providers and their actions.\n\n<details>\n<summary><strong>Basename</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>register_basename</code></td>\n <td width=\"768\">Registers a custom .base.eth or .basetest.eth domain name for the wallet address.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>CDP API</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>request_faucet_funds</code></td>\n <td width=\"768\">Requests testnet ETH, USDC, EURC or CBBTC.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Compound</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>supply</code></td>\n <td width=\"768\">Supplies collateral assets (WETH, CBETH, CBBTC, WSTETH, or USDC) to Compound.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>withdraw</code></td>\n <td width=\"768\">Withdraws previously supplied collateral assets from Compound.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>borrow</code></td>\n <td width=\"768\">Borrows base assets (WETH or USDC) from Compound using supplied collateral.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>repay</code></td>\n <td width=\"768\">Repays borrowed assets back to Compound.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_portfolio</code></td>\n <td width=\"768\">Retrieves portfolio details including collateral balances and borrowed amounts.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>ERC20</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>get_balance</code></td>\n <td width=\"768\">Retrieves the token balance for a specified address and ERC-20 contract.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>transfer</code></td>\n <td width=\"768\">Transfers a specified amount of ERC-20 tokens to a destination address.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>ERC721</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>get_balance</code></td>\n <td width=\"768\">Retrieves the NFT balance for a specified address and ERC-721 contract.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>transfer</code></td>\n <td width=\"768\">Transfers ownership of a specific NFT token to a destination address.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>mint</code></td>\n <td width=\"768\">Creates a new NFT token and assigns it to a specified destination address.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Hyperbolic</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>generate_text</code></td>\n <td width=\"768\">Generate text using AI models.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>generate_image</code></td>\n <td width=\"768\">Generate images using AI models.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>generate_audio</code></td>\n <td width=\"768\">Generate text-to-speech audio.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_available_gpus</code></td>\n <td width=\"768\">Get available GPU resources.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_available_gpus_by_type</code></td>\n <td width=\"768\">Get GPUs filtered by model type.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_available_gpus_types</code></td>\n <td width=\"768\">Get list of available GPU types.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_gpu_status</code></td>\n <td width=\"768\">Check status of GPU resources.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>rent_compute</code></td>\n <td width=\"768\">Rent GPU compute resources.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>terminate_compute</code></td>\n <td width=\"768\">Terminate a rented GPU compute instance.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_current_balance</code></td>\n <td width=\"768\">Get current account balance.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_purchase_history</code></td>\n <td width=\"768\">Get purchase history.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_spend_history</code></td>\n <td width=\"768\">Get spending history.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>link_wallet_address</code></td>\n <td width=\"768\">Link a wallet address to your account.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Morpho</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>deposit</code></td>\n <td width=\"768\">Deposits a specified amount of assets into a designated Morpho Vault.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>withdraw</code></td>\n <td width=\"768\">Withdraws a specified amount of assets from a designated Morpho Vault.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Nillion</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>lookup_schema</code></td>\n <td width=\"768\">Looks up a schema by description and returns both the schema UUID and corresponding JSON schema.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>create_schema</code></td>\n <td width=\"768\">Creates a new schema in the Nillion SecretVault based on a natural language description.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>data_upload</code></td>\n <td width=\"768\">Uploads data into the Nillion SecretVault using a specified schema UUID.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>data_download</code></td>\n <td width=\"768\">Downloads all data from the Nillion SecretVault for a specified schema UUID.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Onramp</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>get_onramp_buy_url</code></td>\n <td width=\"768\">Gets a URL to purchase cryptocurrency from Coinbase via Debit card or other payment methods.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Pyth</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>fetch_price</code></td>\n <td width=\"768\">Retrieves current price data from a specified Pyth price feed.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>fetch_price_feed_id</code></td>\n <td width=\"768\">Retrieves the unique price feed identifier for a given token symbol.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>SSH</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>ssh_connect</code></td>\n <td width=\"768\">Establishes an SSH connection to a remote server.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>remote_shell</code></td>\n <td width=\"768\">Executes shell commands on a remote server via SSH.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>ssh_status</code></td>\n <td width=\"768\">Checks status of SSH connections.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>ssh_list_connections</code></td>\n <td width=\"768\">Lists active SSH connections.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>ssh_disconnect</code></td>\n <td width=\"768\">Disconnects from an SSH server.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>ssh_add_host_key</code></td>\n <td width=\"768\">Adds an SSH host key to known_hosts.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>sftp_upload</code></td>\n <td width=\"768\">Uploads files to a remote server via SFTP.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>sftp_download</code></td>\n <td width=\"768\">Downloads files from a remote server via SFTP.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Superfluid</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>create_flow</code></td>\n <td width=\"768\">Creates a new token streaming flow to a recipient address.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>delete_flow</code></td>\n <td width=\"768\">Deletes an existing token streaming flow.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_flow</code></td>\n <td width=\"768\">Gets details of an existing token streaming flow.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Twitter</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>account_details</code></td>\n <td width=\"768\">Fetches profile information and metadata for the authenticated Twitter account.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>account_mentions</code></td>\n <td width=\"768\">Retrieves recent mentions and interactions for the authenticated account.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>post_tweet</code></td>\n <td width=\"768\">Creates a new tweet on the authenticated Twitter account.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>post_tweet_reply</code></td>\n <td width=\"768\">Creates a reply to an existing tweet using the tweet's unique identifier.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>Wallet</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>get_wallet_details</code></td>\n <td width=\"768\">Retrieves wallet address, network info, balances, and provider details.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>get_balance</code></td>\n <td width=\"768\">Gets the native currency balance of the connected wallet.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>native_transfer</code></td>\n <td width=\"768\">Transfers native blockchain tokens (e.g., ETH) to a destination address.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>WETH</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>wrap_eth</code></td>\n <td width=\"768\">Converts native ETH to Wrapped ETH (WETH) on supported networks.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>WOW</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>buy_token</code></td>\n <td width=\"768\">Purchases WOW tokens from a contract using ETH based on bonding curve pricing.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>create_token</code></td>\n <td width=\"768\">Creates a new WOW memecoin with bonding curve functionality via Zora factory.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>sell_token</code></td>\n <td width=\"768\">Sells WOW tokens back to the contract for ETH based on bonding curve pricing.</td>\n</tr>\n</table>\n</details>\n\n<details>\n<summary><strong>x402</strong></summary>\n<table width=\"100%\">\n<tr>\n <td width=\"200\"><code>make_http_request</code></td>\n <td width=\"768\">Makes a basic HTTP request to an API endpoint. If the endpoint requires payment (returns 402), it will return payment details that can be used with retry_http_request_with_x402.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>retry_http_request_with_x402</code></td>\n <td width=\"768\">Retries an HTTP request with x402 payment after receiving a 402 Payment Required response. This should be used after make_http_request returns a 402 response.</td>\n</tr>\n<tr>\n <td width=\"200\"><code>make_http_request_with_x402</code></td>\n <td width=\"768\">Makes an HTTP request with automatic x402 payment handling. Only use when explicitly told to skip the confirmation flow.</td>\n</tr>\n</table>\n</details>\n\n## Wallet Providers\n\nAgentKit supports the following wallet providers:\n\nEVM:\n\n- [CdpEvmWalletProvider](https://github.com/coinbase/agentkit/blob/master/python/coinbase-agentkit/coinbase_agentkit/wallet_providers/cdp_evm_wallet_provider.py) - Uses the Coinbase Developer Platform (CDP) API Server Wallet\n- [CdpSmartWalletProvider](https://github.com/coinbase/agentkit/blob/master/python/coinbase-agentkit/coinbase_agentkit/wallet_providers/cdp_smart_wallet_provider.py) - Uses the Coinbase Developer Platform (CDP) API Smart Wallet\n- [EthAccountWalletProvider](https://github.com/coinbase/agentkit/blob/master/python/coinbase-agentkit/coinbase_agentkit/wallet_providers/eth_account_wallet_provider.py) - Uses a local private key for any EVM-compatible chain\n\n### CdpEvmWalletProvider\n\nThe `CdpEvmWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [API Server Wallet](https://docs.cdp.coinbase.com/wallet-api/docs/welcome).\n\n#### Network Configuration\n\nThe `CdpEvmWalletProvider` can be configured to use a specific network by passing the `network_id` parameter to the `CdpEvmWalletProviderConfig`. The `network_id` is the ID of the network you want to use. You can find a list of [supported networks on the CDP API docs](https://docs.cdp.coinbase.com/cdp-apis/docs/networks).\n\n```python\nfrom coinbase_agentkit import CdpEvmWalletProvider, CdpEvmWalletProviderConfig\n\nwallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n network_id=\"base-mainnet\",\n))\n```\n\n#### Configuring from an existing CDP API Wallet\n\nIf you already have a CDP API Wallet, you can configure the `CdpEvmWalletProvider` by passing the `address` parameter to the config.\n\n```python\nfrom coinbase_agentkit import CdpEvmWalletProvider, CdpEvmWalletProviderConfig\n\nwallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n address=\"YOUR_WALLET_ADDRESS\",\n))\n```\n\n#### Creating a new wallet\n\nThe `CdpEvmWalletProvider` can create a new wallet by providing an `idempotency_key`. If no `address` is provided, a new wallet will be created.\n\n```python\nfrom coinbase_agentkit import CdpEvmWalletProvider, CdpEvmWalletProviderConfig\n\nwallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n idempotency_key=\"UNIQUE_IDEMPOTENCY_KEY\",\n))\n```\n\n#### Example Usage with AgentKit\n\nHere's a complete example of using `CdpEvmWalletProvider` with AgentKit:\n\n```python\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n CdpEvmWalletProvider,\n CdpEvmWalletProviderConfig,\n cdp_api_action_provider,\n erc20_action_provider,\n pyth_action_provider,\n wallet_action_provider,\n weth_action_provider,\n)\n\n# Initialize the wallet provider\nwallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n network_id=\"base-sepolia\",\n))\n\n# Create AgentKit instance with wallet and action providers\nagentkit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider,\n action_providers=[\n cdp_api_action_provider(),\n erc20_action_provider(),\n pyth_action_provider(),\n wallet_action_provider(),\n weth_action_provider(),\n ],\n))\n```\n\n### CdpSmartWalletProvider\n\nThe `CdpSmartWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [Smart Wallets](https://docs.cdp.coinbase.com/wallet-api/docs/smart-wallets). Smart wallets are controlled by an owner, which can be either an EVM private key or a CDP server wallet address.\n\n#### Network Configuration\n\nThe `CdpSmartWalletProvider` can be configured to use a specific network by passing the `network_id` parameter to the `CdpSmartWalletProviderConfig`. The `network_id` is the ID of the network you want to use. You can find a list of [supported networks on the CDP API docs](https://docs.cdp.coinbase.com/cdp-apis/docs/networks).\n\n```python\nfrom coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig\n\nwallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n network_id=\"base-mainnet\",\n owner=\"OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS\",\n))\n```\n\n#### Configuring with a Private Key Owner\n\nYou can configure the `CdpSmartWalletProvider` with a private key owner:\n\n```python\nfrom coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig\n\nwallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n owner=\"0x123...\", # Private key\n network_id=\"base-sepolia\",\n))\n```\n\n#### Configuring with a Server Wallet Owner\n\nYou can also configure the `CdpSmartWalletProvider` with a CDP server wallet address as the owner:\n\n```python\nfrom coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig\n\nwallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n owner=\"0x456...\", # Server wallet address\n network_id=\"base-sepolia\",\n))\n```\n\n#### Creating a New Smart Wallet\n\nIf no `address` is provided, a new smart wallet will be created for the owner. You can optionally provide an `idempotency_key` to ensure idempotent wallet creation:\n\n```python\nfrom coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig\n\nwallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n owner=\"OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS\",\n idempotency_key=\"UNIQUE_IDEMPOTENCY_KEY\",\n))\n```\n\n#### Gasless Transactions with Paymaster\n\nYou can enable gasless transactions by providing a paymaster URL:\n\n```python\nfrom coinbase_agentkit import CdpSmartWalletProvider, CdpSmartWalletProviderConfig\n\nwallet_provider = CdpSmartWalletProvider(CdpSmartWalletProvideronfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n owner=\"OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS\",\n paymaster_url=\"https://your-paymaster-url.com\", # Optional paymaster URL for gasless transactions\n))\n```\n\n#### Example Usage with AgentKit\n\nHere's a complete example of using `CdpSmartWalletProvider` with AgentKit:\n\n```python\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n CdpSmartWalletProvider,\n CdpSmartWalletProviderConfig,\n cdp_api_action_provider,\n erc20_action_provider,\n pyth_action_provider,\n wallet_action_provider,\n weth_action_provider,\n)\n\n# Initialize the wallet provider\nwallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n owner=\"OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS\",\n network_id=\"base-sepolia\",\n))\n\n# Create AgentKit instance with wallet and action providers\nagentkit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider,\n action_providers=[\n cdp_api_action_provider(),\n erc20_action_provider(),\n pyth_action_provider(),\n wallet_action_provider(),\n weth_action_provider(),\n ],\n))\n```\n\n### EthAccountWalletProvider\n\nExample usage with a private key:\n\n```python\nimport os\nfrom eth_account import Account\n\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n EthAccountWalletProvider,\n EthAccountWalletProviderConfig\n)\n\n# See here for creating a private key:\n# https://web3py.readthedocs.io/en/stable/web3.eth.account.html#creating-a-private-key\nprivate_key = os.environ.get(\"PRIVATE_KEY\")\nassert private_key is not None, \"You must set PRIVATE_KEY environment variable\"\nassert private_key.startswith(\"0x\"), \"Private key must start with 0x hex prefix\"\n\naccount = Account.from_key(private_key)\n\nwallet_provider = EthAccountWalletProvider(\n config=EthAccountWalletProviderConfig(\n account=account,\n chain_id=\"84532\",\n )\n)\n\nagent_kit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider\n))\n```\n\n#### Configuring `EthAccountWalletProvider` gas parameters\n\nThe `EthAccountWalletProvider` also exposes parameters for effecting the gas calculations.\n\n```python\nimport os\nfrom eth_account import Account\n\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n EthAccountWalletProvider,\n EthAccountWalletProviderConfig\n)\n\nprivate_key = os.environ.get(\"PRIVATE_KEY\")\nassert private_key is not None, \"You must set PRIVATE_KEY environment variable\"\nassert private_key.startswith(\"0x\"), \"Private key must start with 0x hex prefix\"\n\naccount = Account.from_key(private_key)\n\nwallet_provider = EthAccountWalletProvider(\n config=EthAccountWalletProviderConfig(\n account=account,\n chain_id=\"84532\",\n gas={\n \"gas_limit_multiplier\": 2,\n \"fee_per_gas_multiplier\": 2\n }\n )\n)\n\nagent_kit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider\n))\n```\n\n#### Configuring `EthAccountWalletProvider` rpc url\n\nThe `EthAccountWalletProvider` also exposes parameters for defining the rpc url manually.\n\n```python\nimport os\nfrom eth_account import Account\n\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n EthAccountWalletProvider,\n EthAccountWalletProviderConfig\n)\n\nprivate_key = os.environ.get(\"PRIVATE_KEY\")\nassert private_key is not None, \"You must set PRIVATE_KEY environment variable\"\nassert private_key.startswith(\"0x\"), \"Private key must start with 0x hex prefix\"\n\naccount = Account.from_key(private_key)\n\nwallet_provider = EthAccountWalletProvider(\n config=EthAccountWalletProviderConfig(\n account=account,\n rpc_url=\"https://sepolia.base.org\",\n )\n)\n\nagent_kit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider\n))\n```\n\n### CDPSmartWalletProvider\n\nThe `CDPSmartWalletProvider` is a wallet provider that uses [CDP Smart Wallets](https://docs.cdp.coinbase.com/wallet-api/docs/smart-wallets).\n\n```python\nimport os\nfrom eth_account import Account\n\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n SmartWalletProvider,\n SmartWalletProviderConfig\n)\n\n# See here for creating a private key:\n# https://web3py.readthedocs.io/en/stable/web3.eth.account.html#creating-a-private-key\nprivate_key = os.environ.get(\"PRIVATE_KEY\")\nassert private_key is not None, \"You must set PRIVATE_KEY environment variable\"\nassert private_key.startswith(\"0x\"), \"Private key must start with 0x hex prefix\"\n\nsigner = Account.from_key(private_key)\n\nnetwork_id = os.getenv(\"NETWORK_ID\", \"base-sepolia\")\n\nwallet_provider = SmartWalletProvider(SmartWalletProviderConfig(\n network_id=network_id,\n signer=signer,\n smart_wallet_address=None, # If not provided, a new smart wallet will be created\n paymaster_url=None, # Sponsor transactions: https://docs.cdp.coinbase.com/paymaster/docs/welcome\n))\n\nagent_kit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider\n))\n```\n\n### CdpSolanaWalletProvider\n\nThe `CdpSolanaWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) API for Solana networks. It supports SOL transfers and message signing on Solana mainnet, devnet, and testnet.\n\n#### Network Configuration\n\nThe `CdpSolanaWalletProvider` can be configured to use different Solana networks by setting the `network_id` parameter:\n\n- `solana-mainnet` - Solana Mainnet\n- `solana-devnet` - Solana Devnet (default)\n- `solana-testnet` - Solana Testnet\n\n```python\nfrom coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig\n\nwallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n network_id=\"solana-devnet\",\n))\n```\n\n#### Configuring with API credentials\n\nYou can configure the provider by passing CDP API credentials directly:\n\n```python\nfrom coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig\n\nwallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n network_id=\"solana-mainnet\",\n))\n```\n\n#### Using environment variables\n\nThe provider can also read configuration from environment variables:\n\n```python\nfrom coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig\n\n# Set environment variables:\n# CDP_API_KEY_ID=\"your-api-key-id\"\n# CDP_API_KEY_SECRET=\"your-api-key-secret\"\n# CDP_WALLET_SECRET=\"your-wallet-secret\"\n# NETWORK_ID=\"solana-devnet\"\n\nwallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig())\n```\n\n#### Using an existing wallet\n\nIf you have an existing CDP Solana wallet, you can specify its address:\n\n```python\nfrom coinbase_agentkit import CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig\n\nwallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n address=\"YOUR_EXISTING_SOLANA_ADDRESS\",\n network_id=\"solana-mainnet\",\n))\n```\n\n#### Example Usage with AgentKit\n\nHere's a complete example of using `CdpSolanaWalletProvider` with AgentKit:\n\n```python\nfrom coinbase_agentkit import (\n AgentKit,\n AgentKitConfig,\n CdpSolanaWalletProvider,\n CdpSolanaWalletProviderConfig,\n wallet_action_provider,\n)\n\n# Initialize the wallet provider\nwallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig(\n api_key_id=\"CDP API KEY ID\",\n api_key_secret=\"CDP API KEY SECRET\",\n wallet_secret=\"CDP WALLET SECRET\",\n network_id=\"solana-devnet\",\n))\n\n# Create AgentKit instance with wallet and action providers\nagentkit = AgentKit(AgentKitConfig(\n wallet_provider=wallet_provider,\n action_providers=[\n wallet_action_provider(), # Provides basic wallet operations for Solana\n ],\n))\n\n# The wallet provider supports:\n# - Getting wallet address: wallet_provider.get_address()\n# - Getting SOL balance: wallet_provider.get_balance()\n# - Transferring SOL: wallet_provider.native_transfer(to, amount)\n# - Signing messages: wallet_provider.sign_message(message)\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/coinbase/agentkit/blob/main/CONTRIBUTING.md) for more information.\n",
"bugtrack_url": null,
"license": null,
"summary": "Coinbase AgentKit",
"version": "0.7.0",
"project_urls": null,
"split_keywords": [
"agent",
" agentkit",
" ai",
" cdp",
" coinbase",
" crypto",
" sdk"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e49d386654c76fc47cc58e5e6225996f19741be92a1bc91885c0aad9d512394d",
"md5": "f7a69d96ad782c2cc6760d7a0198a8db",
"sha256": "240f1d45fbcb52a09e3231a15d172256e3c164ff6bef5058b9b0ef5c029375e6"
},
"downloads": -1,
"filename": "coinbase_agentkit-0.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f7a69d96ad782c2cc6760d7a0198a8db",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.10",
"size": 175982,
"upload_time": "2025-07-18T19:36:46",
"upload_time_iso_8601": "2025-07-18T19:36:46.606632Z",
"url": "https://files.pythonhosted.org/packages/e4/9d/386654c76fc47cc58e5e6225996f19741be92a1bc91885c0aad9d512394d/coinbase_agentkit-0.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6bc4bf1c392b48eafbd84b2ef56c46d79f1e1466e56dc6e01d2a5823e9c6351e",
"md5": "6de8681ae22d03c8fab15cb653156d42",
"sha256": "3a2c925528f23ef0020f470279c739f5d0e92629686af240a523c94722f59b1a"
},
"downloads": -1,
"filename": "coinbase_agentkit-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "6de8681ae22d03c8fab15cb653156d42",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.10",
"size": 113504,
"upload_time": "2025-07-18T19:36:48",
"upload_time_iso_8601": "2025-07-18T19:36:48.335812Z",
"url": "https://files.pythonhosted.org/packages/6b/c4/bf1c392b48eafbd84b2ef56c46d79f1e1466e56dc6e01d2a5823e9c6351e/coinbase_agentkit-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-18 19:36:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "coinbase-agentkit"
}