Skip to content

Tools for Langchain Agents to use to interact with Coinbase's MPC Wallet API

License

Notifications You must be signed in to change notification settings

mikeghen/coinbase-mpc-toolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coinbase MPC Wallets Toolkit for Agentic Frameworks

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.

Demonstrations: Assist with Onchain Activity while Adhering to a Policy

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
Happy Path Sad Path

Demo Policy Prompt

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.

Overview

  • Tools (./tools) - This directory contains the tools that can be used to interact with the Coinbase MPC Wallets. Tools are extensions of the Langchain BaseTool.
    • 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.

Integrations

  • 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.

Running the Demo Locally

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:

  1. 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
  1. 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
  1. In a third terminal, run the app
cd app
npm install
npm run dev
  1. Open your browser and navigate to http://localhost:8080 to see the app in action.

Future Work

  • 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).

About

Tools for Langchain Agents to use to interact with Coinbase's MPC Wallet API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published