A DeFi agent built using Langchain and powered by CDP SDK, operating over the XMTP messaging protocol.
- Process blockchain payments using natural language commands
- Advanced language processing using LangChain and OpenAI
- User-specific wallet management with flexible storage options (Redis or local file)
- XMTP messaging integration for secure, decentralized chat interactions
- Powered by CDP SDK for reliable blockchain operations and Langchain for AI Agent
- Node.js (v20+)
- XMTP
node-sdk
- OpenAI API key
- Coinbase Developer Platform (CDP) API credentials
- Yarn package manager
Follow these steps to get your x agent up and running:
-
Clone the repository:
git clone https://github.com/ephemeraHQ/xmtp-agent-examples.git cd integrations/coinbase-langchain
-
Install dependencies:
yarn install
-
Set up your environment variables: Create a
.env
file like in.env.example
:WALLET_KEY= # the private key for the wallet ENCRYPTION_KEY= # the encryption key for the wallet # public key is NETWORK_ID=base-sepolia # base-mainnet or others OPENAI_API_KEY= # the OpenAI API key CDP_API_KEY_NAME= # the name of the CDP API key CDP_API_KEY_PRIVATE_KEY= # the private key for the CDP API key XMTP_ENV=local # the environment to use for XMTP REDIS_URL= # the URL for the Redis database
-
Start the agent:
yarn dev
-
Interact with your agent:
Once running, you'll see a URL in the console like:
Send a message on http://xmtp.chat/dm/YOUR_AGENT_ADDRESS?env=dev
Open this URL in your browser to start chatting with your agent!
Once the agent is running, you can interact with it using natural language commands:
- "Send 0.01 USDC to 0x1234..."
- "Check my wallet balance"
This agent combines key technologies:
- XMTP protocol: Secure decentralized messaging
- Langchain: AI processing and conversation management
- CDP SDK: Blockchain transaction handling
- Storage: Redis or local file options
- OpenAI: Natural language understanding
- Verify XMTP environment settings (
local
,dev
, orproduction
) - Check API credentials and connection strings
- Ensure sufficient wallet balance
- Verify network settings (default: base-sepolia)
- For testnets, obtain tokens from faucets
- System falls back to local storage if Redis fails
- Check permissions and connection URLs