This project contains code for a Langchain Toolkit that integrates with Coinbase's Developer Platform API MPC Wallets to allow agents to interact onchain as part of their workflow.
This is a demonstration of the tools built in action. Alice, a AI Assistant, has access to transfer funds from a wallet. However, she must adhere to a policy that limits the amount of ETH that can be transferred at a time.
Enforce Limits | Really Enforces Limits |
---|---|
Find the current policy prompt here: src/prompts/agent_prompt.txt
Your name is Alice and your job is to assit customers with funding their wallet or transferring ETH to other wallets.
Always begin the conversation by introducing yourself and sharing your capabilities.
You MUST follow these rules:
* The customer is allowed to transfer up to 0.0001 ETH at a time. Do not exceed this limit.
- Tools (
./tools
) - This directory contains the tools that can be used to interact with the Coinbase MPC Wallets. Tools are extensions of the LangchainBaseTool
.FundWallet
: This tool is used to fund a wallet with a specified amount of ETH.TransferFunds
: This tool is used to transfer funds from one wallet to another.TradeAssets
: This tool is used to trade assets on the wallet.
- Coinbase Developer Platform API (
./cdp
) - This is a simple API I made that exposes the@coinbase/mpc-wallet-sdk
as API endpoints since there is no Python SDK yet.
- Coinbase MPC Wallets API - This toolkit integrates with the Coinbase MPC Wallets API to allow agents to interact with the blockchain. The API is exposed through the
cdp
API. - Langchain - This toolkit and the demo is built using the Langchain SDK. The tools are extensions of the
BaseTool
class. - OpenAI - The demo uses OpenAI's GPT-4o-mini to generate responses for the agent.
The Coinbase MPC SDK is not available for Python. So, I created a simple API that exposes the SDK as API endpoints. You can run the demo locally by following these steps:
- Start the
cdp
API:
cd cdp
npm install
node index.js
This will start the server and you'll see:
Server is running on port 3000
Coinbase SDK initialized successfully
- In another terminal, enter the
src
directory and run commands to install and run the application
cd src
pip install -r requirements.txt
python server.py
- In a third terminal, run the app
cd app
npm install
npm run dev
- Open your browser and navigate to
http://localhost:8080
to see the app in action.
- Honey Pot Demo: Create a demo where users try to convince the agent to transfer more than the allowed limit.
- Integration with Slack: Integrate the toolkit with Slack to allow users to interact with the agent through Slack. Avoid having to make/maintain a frontend.
- Save and Reference Chat History: Save the chat history and reference it in the demo conversations.
- Add more tools: Add more tools to interact with the blockchain for read purposes (e.g. balance, balanceOf, etc).