# CDP Agentkit Extension - Langchain Toolkit
CDP integration with Langchain to enable agentic workflows using the core primitives defined in `cdp-agentkit-core`.
This toolkit contains tools that enable an LLM agent to interact with the [Coinbase Developer Platform](https://docs.cdp.coinbase.com/). The toolkit provides a wrapper around the CDP SDK, allowing agents to perform onchain operations like transfers, trades, and smart contract interactions.
## Setup
### Prerequisites
#### CDP
- [CDP API Key](https://portal.cdp.coinbase.com/access/api)
#### OpenAI
- [OpenAI API Key](https://platform.openai.com/docs/quickstart#create-and-export-an-api-key)
#### Python
- Python 3.10 or higher
### Installation
```bash
pip install cdp-langchain
```
### Environment Setup
Set the following environment variables:
```bash
export CDP_API_KEY_NAME=<your-api-key-name>
export CDP_API_KEY_PRIVATE_KEY=$'<your-private-key>'
export OPENAI_API_KEY=<your-openai-api-key>
export NETWORK_ID=base-sepolia # Optional: Defaults to base-sepolia
```
## Usage
### Basic Setup
```python
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)
# Get available tools
tools = toolkit.get_tools()
for tool in tools:
print(tool.name)
```
The toolkit provides the following tools:
1. **get_wallet_details** - Get details about the MPC Wallet
2. **get_balance** - Get balance for specific assets
3. **request_faucet_funds** - Request test tokens from faucet
4. **transfer** - Transfer assets between addresses
5. **trade** - Trade assets (Mainnet only)
6. **deploy_token** - Deploy ERC-20 token contracts
7. **mint_nft** - Mint NFTs from existing contracts
8. **deploy_nft** - Deploy new NFT contracts
9. **register_basename** - Register a basename for the wallet
10. **wow_create_token** - Deploy a token using Zora's Wow Launcher (Bonding Curve)
11. **wow_buy_token** - Buy Zora Wow ERC20 memecoin with ETH
12. **wow_sell_token** - Sell Zora Wow ERC20 memecoin for ETH
13. **wrap_eth** - Wrap ETH to WETH
14. **pyth_fetch_price_feed_id** Fetch the price feed ID for a given token symbol from Pyth Network
15. **pyth_fetch_price** fetch the price of a given price feed from Pyth Network
16. **get_balance_nft** Get balance for specific NFTs (ERC-721)
17. **transfer_nft** Transfer an NFT (ERC-721)
### Using with an Agent
```python
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
# Initialize LLM
llm = ChatOpenAI(model="gpt-4o-mini")
# Get tools and create agent
tools = toolkit.get_tools()
agent_executor = create_react_agent(llm, tools)
# Example usage
events = agent_executor.stream(
{"messages": [("user", "Send 0.005 ETH to john2879.base.eth")]},
stream_mode="values"
)
for event in events:
event["messages"][-1].pretty_print()
```
Expected output:
```
Transferred 0.005 of eth to john2879.base.eth.
Transaction hash for the transfer: 0x78c7c2878659a0de216d0764fc87eff0d38b47f3315fa02ba493a83d8e782d1e
Transaction link for the transfer: https://sepolia.basescan.org/tx/0x78c7c2878659a0de216d0764fc87eff0d38b47f3315fa02ba493a83d8e782d1
```
## CDP Tookit Specific Features
### Wallet Management
The toolkit maintains an MPC wallet that persists between sessions:
```python
# Export wallet data
wallet_data = cdp.export_wallet()
# Import wallet data
values = {"cdp_wallet_data": wallet_data}
cdp = CdpAgentkitWrapper(**values)
```
### Network Support
The toolkit supports [multiple networks](https://docs.cdp.coinbase.com/cdp-sdk/docs/networks).
### Gasless Transactions
The following operations support gasless transactions on Base Mainnet:
- USDC transfers
- EURC transfers
- cbBTC transfers
## Examples
Check out [cdp-langchain/examples](../examples) for inspiration and help getting started!
- [Chatbot Python](../examples/chatbot-python/README.md): Simple example of a Python Chatbot that can perform complex onchain interactions, using OpenAI.
## Contributing
See [CONTRIBUTING.md](../../CONTRIBUTING.md) for detailed setup instructions and contribution guidelines.
Raw data
{
"_id": null,
"home_page": null,
"name": "cdp-langchain",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "coinbase, sdk, crypto, cdp, agentkit, ai, agent, langchain, toolkit",
"author": "John Peterson",
"author_email": "john.peterson@coinbase.com",
"download_url": "https://files.pythonhosted.org/packages/e3/f0/3e8f66a1bf45a995f3318a465cbf1048ce92fc763c60f84989a25b9abae4/cdp_langchain-0.0.11.tar.gz",
"platform": null,
"description": "# CDP Agentkit Extension - Langchain Toolkit\n\nCDP integration with Langchain to enable agentic workflows using the core primitives defined in `cdp-agentkit-core`.\n\nThis toolkit contains tools that enable an LLM agent to interact with the [Coinbase Developer Platform](https://docs.cdp.coinbase.com/). The toolkit provides a wrapper around the CDP SDK, allowing agents to perform onchain operations like transfers, trades, and smart contract interactions.\n\n## Setup\n\n### Prerequisites\n\n#### CDP\n\n- [CDP API Key](https://portal.cdp.coinbase.com/access/api)\n\n#### OpenAI\n\n- [OpenAI API Key](https://platform.openai.com/docs/quickstart#create-and-export-an-api-key)\n\n#### Python\n\n- Python 3.10 or higher\n\n### Installation\n\n```bash\npip install cdp-langchain\n```\n\n### Environment Setup\n\nSet the following environment variables:\n\n```bash\nexport CDP_API_KEY_NAME=<your-api-key-name>\nexport CDP_API_KEY_PRIVATE_KEY=$'<your-private-key>'\nexport OPENAI_API_KEY=<your-openai-api-key>\nexport NETWORK_ID=base-sepolia # Optional: Defaults to base-sepolia\n```\n\n## Usage\n\n### Basic Setup\n\n```python\nfrom cdp_langchain.agent_toolkits import CdpToolkit\nfrom cdp_langchain.utils import CdpAgentkitWrapper\n\n# Initialize CDP wrapper\ncdp = CdpAgentkitWrapper()\n\n# Create toolkit from wrapper\ntoolkit = CdpToolkit.from_cdp_agentkit_wrapper(cdp)\n\n# Get available tools\ntools = toolkit.get_tools()\nfor tool in tools:\n print(tool.name)\n```\n\nThe toolkit provides the following tools:\n\n1. **get_wallet_details** - Get details about the MPC Wallet\n2. **get_balance** - Get balance for specific assets\n3. **request_faucet_funds** - Request test tokens from faucet\n4. **transfer** - Transfer assets between addresses\n5. **trade** - Trade assets (Mainnet only)\n6. **deploy_token** - Deploy ERC-20 token contracts\n7. **mint_nft** - Mint NFTs from existing contracts\n8. **deploy_nft** - Deploy new NFT contracts\n9. **register_basename** - Register a basename for the wallet\n10. **wow_create_token** - Deploy a token using Zora's Wow Launcher (Bonding Curve)\n11. **wow_buy_token** - Buy Zora Wow ERC20 memecoin with ETH\n12. **wow_sell_token** - Sell Zora Wow ERC20 memecoin for ETH\n13. **wrap_eth** - Wrap ETH to WETH\n14. **pyth_fetch_price_feed_id** Fetch the price feed ID for a given token symbol from Pyth Network\n15. **pyth_fetch_price** fetch the price of a given price feed from Pyth Network\n16. **get_balance_nft** Get balance for specific NFTs (ERC-721)\n17. **transfer_nft** Transfer an NFT (ERC-721)\n\n### Using with an Agent\n\n```python\nfrom langchain_openai import ChatOpenAI\nfrom langgraph.prebuilt import create_react_agent\n\n# Initialize LLM\nllm = ChatOpenAI(model=\"gpt-4o-mini\")\n\n# Get tools and create agent\ntools = toolkit.get_tools()\nagent_executor = create_react_agent(llm, tools)\n\n# Example usage\nevents = agent_executor.stream(\n {\"messages\": [(\"user\", \"Send 0.005 ETH to john2879.base.eth\")]},\n stream_mode=\"values\"\n)\n\nfor event in events:\n event[\"messages\"][-1].pretty_print()\n```\nExpected output:\n```\nTransferred 0.005 of eth to john2879.base.eth.\nTransaction hash for the transfer: 0x78c7c2878659a0de216d0764fc87eff0d38b47f3315fa02ba493a83d8e782d1e\nTransaction link for the transfer: https://sepolia.basescan.org/tx/0x78c7c2878659a0de216d0764fc87eff0d38b47f3315fa02ba493a83d8e782d1\n```\n\n## CDP Tookit Specific Features\n\n### Wallet Management\n\nThe toolkit maintains an MPC wallet that persists between sessions:\n\n```python\n# Export wallet data\nwallet_data = cdp.export_wallet()\n\n# Import wallet data\nvalues = {\"cdp_wallet_data\": wallet_data}\ncdp = CdpAgentkitWrapper(**values)\n```\n\n### Network Support\n\nThe toolkit supports [multiple networks](https://docs.cdp.coinbase.com/cdp-sdk/docs/networks).\n\n### Gasless Transactions\n\nThe following operations support gasless transactions on Base Mainnet:\n- USDC transfers\n- EURC transfers\n- cbBTC transfers\n\n## Examples\n\nCheck out [cdp-langchain/examples](../examples) for inspiration and help getting started!\n- [Chatbot Python](../examples/chatbot-python/README.md): Simple example of a Python Chatbot that can perform complex onchain interactions, using OpenAI.\n\n## Contributing\n\nSee [CONTRIBUTING.md](../../CONTRIBUTING.md) for detailed setup instructions and contribution guidelines.\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "CDP Agentkit Langchain Extension",
"version": "0.0.11",
"project_urls": null,
"split_keywords": [
"coinbase",
" sdk",
" crypto",
" cdp",
" agentkit",
" ai",
" agent",
" langchain",
" toolkit"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3525beb7f5efff2ebf486861d3dc750905c650a8e585ae308cab7331a5a958f3",
"md5": "1834b8ba9f09615df5da2be5517f2df2",
"sha256": "37c55458299aae4e178f9b84a79ba06faf381c19e21e3c43d9c31781f5622f0c"
},
"downloads": -1,
"filename": "cdp_langchain-0.0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1834b8ba9f09615df5da2be5517f2df2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 8563,
"upload_time": "2025-01-17T21:48:02",
"upload_time_iso_8601": "2025-01-17T21:48:02.118085Z",
"url": "https://files.pythonhosted.org/packages/35/25/beb7f5efff2ebf486861d3dc750905c650a8e585ae308cab7331a5a958f3/cdp_langchain-0.0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e3f03e8f66a1bf45a995f3318a465cbf1048ce92fc763c60f84989a25b9abae4",
"md5": "dcc69eab42fc5342dae63f8505f97415",
"sha256": "73307186bfeb98b1ea7aa8229f1d5232d33e76f4171a84dbedf925a078f2e65e"
},
"downloads": -1,
"filename": "cdp_langchain-0.0.11.tar.gz",
"has_sig": false,
"md5_digest": "dcc69eab42fc5342dae63f8505f97415",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 6119,
"upload_time": "2025-01-17T21:48:04",
"upload_time_iso_8601": "2025-01-17T21:48:04.341462Z",
"url": "https://files.pythonhosted.org/packages/e3/f0/3e8f66a1bf45a995f3318a465cbf1048ce92fc763c60f84989a25b9abae4/cdp_langchain-0.0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-17 21:48:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cdp-langchain"
}