CDP Agentkit Toolkit
The CDP Agentkit
toolkit contains tools that enable an LLM agent to interact with the Coinbase Developer Platform. The toolkit provides a wrapper around the CDP SDK, allowing agents to perform onchain operations like transfers, trades, and smart contract interactions.
Overviewโ
Integration detailsโ
Class | Package | Serializable | JS support | Package latest |
---|---|---|---|---|
CdpToolkit | cdp-langchain | โ | โ |
Tool featuresโ
The toolkit provides the following tools:
- get_wallet_details - Get details about the MPC Wallet
- get_balance - Get balance for specific assets
- request_faucet_funds - Request test tokens from faucet
- transfer - Transfer assets between addresses
- trade - Trade assets (Mainnet only)
- deploy_token - Deploy ERC-20 token contracts
- mint_nft - Mint NFTs from existing contracts
- deploy_nft - Deploy new NFT contracts
- register_basename - Register a basename for the wallet
We encourage you to add your own tools, both using CDP and web2 APIs, to create an agent that is tailored to your needs.
Setupโ
At a high-level, we will:
- Install the langchain package
- Set up your CDP API credentials
- Initialize the CDP wrapper and toolkit
- Pass the tools to your agent with
toolkit.get_tools()
If you want to get automated tracing from runs of individual tools, you can also set your LangSmith API key by uncommenting below:
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
# os.environ["LANGSMITH_TRACING"] = "true"
Installationโ
This toolkit lives in the cdp-langchain
package:
%pip install -qU cdp-langchain
Set Environment Variablesโ
To use this toolkit, you must first set the following environment variables to access the CDP APIs to create wallets and interact onchain. You can sign up for an API key for free on the CDP Portal:
import getpass
import os
for env_var in [
"CDP_API_KEY_NAME",
"CDP_API_KEY_PRIVATE_KEY",
]:
if not os.getenv(env_var):
os.environ[env_var] = getpass.getpass(f"Enter your {env_var}: ")
# Optional: Set network (defaults to base-sepolia)
os.environ["NETWORK_ID"] = "base-sepolia" # or "base-mainnet"
Instantiationโ
Now we can instantiate our toolkit:
from cdp_langchain.agent_toolkits import CdpToolkit
from cdp_langchain.utils import CdpAgentkitWrapper
# Initialize CDP wrapper
cdp = CdpAgentkitWrapper()
# Create toolkit from wrapper
toolkit = CdpToolkit.from_cdp_agentkit_wrapper(cdp)
Toolsโ
View available tools:
tools = toolkit.get_tools()
for tool in tools:
print(tool.name)