Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: default coinbase agentkit plugin #2505

Merged
merged 41 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1e986c8
I add files for plugin-agentkit
sweetmantech Jan 14, 2025
83f4d34
instructions added to gitignore.
sweetmantech Jan 14, 2025
116606e
I update package name.
sweetmantech Jan 14, 2025
3252d84
Merge pull request #5 from sweetmantech/sweets/agentkit
sweetmantech Jan 14, 2025
dfb7d11
I add updated files.
sweetmantech Jan 14, 2025
f2c2506
Merge branch 'main' of github.com:sweetmantech/eliza into sweets/fixes
sweetmantech Jan 14, 2025
3fd80d2
I add ENV requirements to prevent default Eliza bugs.
sweetmantech Jan 14, 2025
5ebeb11
rollback index
sweetmantech Jan 14, 2025
8aab8c0
simple agentkit import.
sweetmantech Jan 14, 2025
bf8d1cb
Merge pull request #6 from sweetmantech/sweets/fixes
sweetmantech Jan 14, 2025
e4ff9a3
I fix pnpm lockfile errors.
sweetmantech Jan 14, 2025
587c1df
Merge pull request #7 from sweetmantech/sweets/pnpm
sweetmantech Jan 14, 2025
6c6d0a4
I load existing wallet data for provider.
sweetmantech Jan 15, 2025
e3004f2
develop merge
sweetmantech Jan 15, 2025
e1b990d
remove dev logging
sweetmantech Jan 16, 2025
c93b317
Merge branch 'develop' into pr/2298
wtfsayo Jan 16, 2025
725f05f
Update pnpm-lock.yaml
wtfsayo Jan 16, 2025
cbef3d8
update .env.example and support non 'base-sepolia'
wtfsayo Jan 16, 2025
b8b6785
Update pnpm-lock.yaml
wtfsayo Jan 16, 2025
234be18
Merge branch 'develop' into main
wtfsayo Jan 16, 2025
aaa1e3c
Merge branch 'develop' into main
sweetmantech Jan 16, 2025
7cbe99f
Update package lock for smoke tests.
sweetmantech Jan 16, 2025
e95254f
Merge branch 'develop' into main
wtfsayo Jan 16, 2025
e080c83
I rollback changes to pnpm-lock file.
sweetmantech Jan 16, 2025
fe81ad4
Merge branch 'main' of github.com:sweetmantech/eliza
sweetmantech Jan 16, 2025
684a7fb
fixing smoke tests for pnpm missing
sweetmantech Jan 16, 2025
b7967b3
rollback changes to agent start file.
sweetmantech Jan 16, 2025
3b14ef3
I rollback changes to smoke test.
sweetmantech Jan 16, 2025
0715eb4
Merge branch 'develop' into main
sweetmantech Jan 16, 2025
56155d6
Merge branch 'develop' into pr/2298
wtfsayo Jan 17, 2025
57ebb77
Update pnpm-lock.yaml
wtfsayo Jan 17, 2025
ead357b
merge conflicts.
sweetmantech Jan 18, 2025
cc8b275
packages/plugin-agentkit/README.md - package name
sweetmantech Jan 18, 2025
9138676
add example network for agentkit.
sweetmantech Jan 18, 2025
9a2d163
update plugin-agentkit README package name to correct ORG prefix.
sweetmantech Jan 18, 2025
6a1b07b
agent/src/index.ts - default plugin
sweetmantech Jan 18, 2025
91f925b
stylish build logging.
sweetmantech Jan 18, 2025
37c6d8c
wallet read from ENV instead of function variable.
sweetmantech Jan 18, 2025
891caba
remove unintended changes to agent index.
sweetmantech Jan 18, 2025
05974c9
Merge pull request #10 from sweetmantech/chore/default-agentkit
sweetmantech Jan 18, 2025
f2ec357
Merge branch 'develop' into main
wtfsayo Jan 19, 2025
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ COINBASE_GENERATED_WALLET_HEX_SEED= # Not your address but the wallet hex seed f
COINBASE_NOTIFICATION_URI= # For webhook plugin the uri you want to send the webhook to for dummy ones use https://webhook.site

# Coinbase AgentKit
COINBASE_AGENT_KIT_NETWORK= # defaults to 'base-sepolia'
CDP_API_KEY_NAME=
CDP_API_KEY_PRIVATE_KEY=
CDP_AGENT_KIT_NETWORK=base-sepolia # Optional: Defaults to base-sepolia

# Coinbase Charity Configuration
IS_CHARITABLE=false # Set to true to enable charity donations
Expand Down
6 changes: 5 additions & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TelegramClientInterface } from "@elizaos/client-telegram";
import { TwitterClientInterface } from "@elizaos/client-twitter";
import { FarcasterClientInterface } from "@elizaos/client-farcaster";
import { DirectClient } from "@elizaos/client-direct";
import { agentKitPlugin } from "@elizaos/plugin-agentkit";
// import { ReclaimAdapter } from "@elizaos/plugin-reclaim";
import { PrimusAdapter } from "@elizaos/plugin-primus";
import { elizaCodeinPlugin, onchainJson } from "@elizaos/plugin-iq6900";
Expand Down Expand Up @@ -250,7 +251,6 @@ export async function loadCharacterFromOnchain(): Promise<Character[]> {
}
}


async function loadCharactersFromUrl(url: string): Promise<Character[]> {
try {
const response = await fetch(url);
Expand Down Expand Up @@ -869,6 +869,10 @@ export async function createAgent(
? elizaCodeinPlugin
: null,
bootstrapPlugin,
getSecret(character, "CDP_API_KEY_NAME") &&
getSecret(character, "CDP_API_KEY_PRIVATE_KEY")
? agentKitPlugin
: null,
getSecret(character, "DEXSCREENER_API_KEY")
? dexScreenerPlugin
: null,
Expand Down
46 changes: 23 additions & 23 deletions packages/plugin-agentkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ pnpm install
```env
CDP_API_KEY_NAME=your_key_name
CDP_API_KEY_PRIVATE_KEY=your_private_key
CDP_AGENT_KIT_NETWORK=base-sepolia # Optional: Defaults to base-sepolia
```

3. Add the plugin to your character configuration:

```json
{
"plugins": ["@ai16z/plugin-agentkit"],
"plugins": ["@elizaos/plugin-agentkit"],
"settings": {
"secrets": {
"CDP_API_KEY_NAME": "your_key_name",
"CDP_API_KEY_PRIVATE_KEY": "your_private_key",
"networkId": "base-sepolia"
"CDP_API_KEY_PRIVATE_KEY": "your_private_key"
}
}
}
Expand All @@ -36,18 +36,18 @@ CDP_API_KEY_PRIVATE_KEY=your_private_key

The plugin provides access to the following CDP AgentKit tools:

- `GET_WALLET_DETAILS`: Get wallet information
- `DEPLOY_NFT`: Deploy a new NFT collection
- `DEPLOY_TOKEN`: Deploy a new token
- `GET_BALANCE`: Check token or NFT balance
- `MINT_NFT`: Mint NFTs from a collection
- `REGISTER_BASENAME`: Register a basename for NFTs
- `REQUEST_FAUCET_FUNDS`: Request testnet funds
- `TRADE`: Execute trades
- `TRANSFER`: Transfer tokens or NFTs
- `WOW_BUY_TOKEN`: Buy WOW tokens
- `WOW_SELL_TOKEN`: Sell WOW tokens
- `WOW_CREATE_TOKEN`: Create new WOW tokens
- `GET_WALLET_DETAILS`: Get wallet information
- `DEPLOY_NFT`: Deploy a new NFT collection
- `DEPLOY_TOKEN`: Deploy a new token
- `GET_BALANCE`: Check token or NFT balance
- `MINT_NFT`: Mint NFTs from a collection
- `REGISTER_BASENAME`: Register a basename for NFTs
- `REQUEST_FAUCET_FUNDS`: Request testnet funds
- `TRADE`: Execute trades
- `TRANSFER`: Transfer tokens or NFTs
- `WOW_BUY_TOKEN`: Buy WOW tokens
- `WOW_SELL_TOKEN`: Sell WOW tokens
- `WOW_CREATE_TOKEN`: Create new WOW tokens

## Usage Examples

Expand Down Expand Up @@ -91,19 +91,19 @@ pnpm dev

## Dependencies

- @elizaos/core
- @coinbase/cdp-agentkit-core
- @coinbase/cdp-langchain
- @langchain/core
- @elizaos/core
- @coinbase/cdp-agentkit-core
- @coinbase/cdp-langchain
- @langchain/core

## Network Support

The plugin currently supports the following networks:
The plugin supports the following networks:

- Base Sepolia (default)
- Base Mainnet
- Base Sepolia (default)
- Base Mainnet

Configure the network using the `networkId` setting in your character configuration.
Configure the network using the `CDP_AGENT_KIT_NETWORK` environment variable.

## Troubleshooting

Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-agentkit/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ export async function getAgentKitActions({
const client = await getClient();
let currentState =
state ?? (await runtime.composeState(message));
currentState =
await runtime.updateRecentMessageState(currentState);
currentState = await runtime.updateRecentMessageState(
currentState
);

const parameterContext = composeParameterContext(
tool,
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-agentkit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import type { Plugin } from "@elizaos/core";
import { walletProvider, getClient } from "./provider";
import { getAgentKitActions } from "./actions";

// Initial banner
console.log("\n┌════════════════════════════════════════┐");
console.log("│ AGENTKIT PLUGIN │");
console.log("├────────────────────────────────────────┤");
console.log("│ Initializing AgentKit Plugin... │");
console.log("│ Version: 0.0.1 │");
console.log("└════════════════════════════════════════┘");

export const agentKitPlugin: Plugin = {
name: "[AgentKit] Integration",
description: "AgentKit integration plugin",
Expand Down
10 changes: 3 additions & 7 deletions packages/plugin-agentkit/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import * as fs from "fs";

const WALLET_DATA_FILE = "wallet_data.txt";

export async function getClient(
networkId = "base-sepolia"
): Promise<CdpAgentkit> {
export async function getClient(): Promise<CdpAgentkit> {
let walletDataStr: string | null = null;

// Read existing wallet data if available
Expand All @@ -22,7 +20,7 @@ export async function getClient(
// Configure CDP AgentKit
const config = {
cdpWalletData: walletDataStr || undefined,
networkId,
networkId: process.env.CDP_AGENT_KIT_NETWORK || "base-sepolia",
};

const agentkit = await CdpAgentkit.configureWithWallet(config);
Expand All @@ -36,9 +34,7 @@ export async function getClient(
export const walletProvider: Provider = {
async get(runtime: IAgentRuntime): Promise<string | null> {
try {
const client = await getClient(
runtime.getSetting("COINBASE_AGENT_KIT_NETWORK")
);
const client = await getClient();
const address = (await (client as any).wallet.addresses)[0].id;
return `AgentKit Wallet Address: ${address}`;
} catch (error) {
Expand Down
Loading