Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions typescript/.changeset/red-goats-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/agentkit": patch
---

Updated xmtp chatbot to use CDP v2 wallets and new xmtp/agent-sdk
8 changes: 6 additions & 2 deletions typescript/examples/langchain-xmtp-chatbot/.env-local
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
OPENAI_API_KEY=
CDP_API_KEY_ID=
CDP_API_KEY_SECRET=
WALLET_KEY=
ENCRYPTION_KEY=
CDP_WALLET_SECRET=

XMTP_WALLET_KEY=
XMTP_DB_ENCRYPTION_KEY=
XMTP_ENV=dev

NETWORK_ID="base-sepolia"
56 changes: 42 additions & 14 deletions typescript/examples/langchain-xmtp-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@ This example demonstrates an agent setup on XMTP Network with access to the full

- "Transfer a portion of your ETH to a random address"
- "What is the price of BTC?"
- "Deploy an NFT that will go super viral!"
- "Deploy an ERC-20 token with total supply 1 billion"
- "Swap 1 USDC to ETH" (base-mainnet only)
- "List x402 services"

## Special Commands

### `/fund` Command - Send ETH to the agent

Send ETH from your wallet to the agent's wallet using the `/fund` command.
Review transaction details, click submit and then approve transaction in your connected browser wallet.

**Usage:**
- `/fund <amountInEth>` - Send ETH to the agent

**Example:**
- `/fund 0.01` - Send 0.01 ETH to the agent


## Prerequisites

### Checking Node Version

Before using the example, ensure that you have the correct version of Node.js installed. The example requires Node.js 18 or higher. You can check your Node version by running:
Before using the example, ensure that you have the correct version of Node.js installed. The example requires Node.js 20 or higher. You can check your Node version by running:

```bash
node --version
Expand All @@ -32,34 +46,48 @@ This will automatically install and use the latest version of Node.
You'll need the following API keys:
- [CDP API Key](https://portal.cdp.coinbase.com/access/api)
- [OpenAI API Key](https://platform.openai.com/docs/quickstart#create-and-export-an-api-key)
- [Generate Wallet Secret](https://portal.cdp.coinbase.com/products/wallet-api)

Once you have them, rename the `.env-local` file to `.env` and make sure you set the API keys to their corresponding environment variables:

- "CDP_API_KEY_ID"
- "CDP_API_KEY_SECRET"
- "OPENAI_API_KEY"
- "XMTP_ENV" # defaults to "dev"
- "WALLET_KEY" # Optional, use `npm run gen:keys` to generate a random wallet key
- "ENCRYPTION_KEY" # Optional, use `npm run gen:keys` to generate a random encryption key
**Required:**
- `OPENAI_API_KEY` - Your OpenAI API key
- `CDP_API_KEY_ID` - Your CDP API key ID
- `CDP_API_KEY_SECRET` - Your CDP API key secret
- `CDP_WALLET_SECRET` - Your CDP wallet secret (for deterministic wallet generation)
- `XMTP_WALLET_KEY` - Private key for XMTP agent (use `pnpm run gen:keys` to generate)
- `XMTP_DB_ENCRYPTION_KEY` - Database encryption key for XMTP (use `pnpm run gen:keys` to generate)

**Optional:**
- `NETWORK_ID` - Network to use (defaults to "base-sepolia")
- `XMTP_ENV` - XMTP environment: "local", "dev", or "production" (defaults to "dev")
- `RPC_URL` - Custom RPC URL for blockchain interactions

You can generate XMTP keys by running:
```bash
pnpm run gen:keys
```

## Running the example

From the root directory, run:

```bash
npm install
npm run build
pnpm install
pnpm build
```

This will install the dependencies and build the packages locally. The chatbot example uses the local `@coinbase/agentkit-langchain`, `@coinbase/agentkit`, and `@xmtp/node-sdk` packages. If you make changes to the packages, you can run `npm run build` from root again to rebuild the packages, and your changes will be reflected in the chatbot example.
This will install the dependencies and build the packages locally. The chatbot example uses the local `@coinbase/agentkit-langchain` and `@coinbase/agentkit` packages. If you make changes to the packages, you can run `pnpm build` from root again to rebuild the packages, and your changes will be reflected in the chatbot example.

Now from the `typescript/examples/langchain-xmtp-chatbot` directory, run:

```bash
npm start
pnpm start
```

Select "1. chat mode" and start telling your Agent to do things onchain!
The agent will start and listen for messages on the XMTP network. You can interact with it by:
1. Visiting the URL displayed in the console (e.g., `http://xmtp.chat/dm/0x...?env=dev`)
2. Sending messages to the agent's address via any XMTP client

## License

Expand Down
Loading
Loading