Skip to content

Commit 0e74e13

Browse files
authored
Merge pull request #1773 from Lukapetro/feature/add-coinmarketcap-plugin
Feature/add coinmarketcap plugin
2 parents 235c523 + aa7ff57 commit 0e74e13

24 files changed

+728
-8
lines changed

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@elizaos/plugin-0g": "workspace:*",
3535
"@elizaos/plugin-abstract": "workspace:*",
3636
"@elizaos/plugin-aptos": "workspace:*",
37+
"@elizaos/plugin-coinmarketcap": "workspace:*",
3738
"@elizaos/plugin-binance": "workspace:*",
3839
"@elizaos/plugin-avail": "workspace:*",
3940
"@elizaos/plugin-bootstrap": "workspace:*",

agent/src/index.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
12
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
23
import { RedisClient } from "@elizaos/adapter-redis";
34
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
4-
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
55
import { AutoClientInterface } from "@elizaos/client-auto";
66
import { DiscordClientInterface } from "@elizaos/client-discord";
77
import { FarcasterAgentClient } from "@elizaos/client-farcaster";
@@ -31,14 +31,17 @@ import {
3131
validateCharacterConfig,
3232
} from "@elizaos/core";
3333
import { zgPlugin } from "@elizaos/plugin-0g";
34+
3435
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
3536
import createGoatPlugin from "@elizaos/plugin-goat";
3637
// import { intifacePlugin } from "@elizaos/plugin-intiface";
3738
import { DirectClient } from "@elizaos/client-direct";
3839
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
3940
import { abstractPlugin } from "@elizaos/plugin-abstract";
40-
import { aptosPlugin } from "@elizaos/plugin-aptos";
4141
import { alloraPlugin } from "@elizaos/plugin-allora";
42+
import { aptosPlugin } from "@elizaos/plugin-aptos";
43+
import { artheraPlugin } from "@elizaos/plugin-arthera";
44+
import { availPlugin } from "@elizaos/plugin-avail";
4245
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
4346
import { binancePlugin } from "@elizaos/plugin-binance";
4447
import {
@@ -49,12 +52,13 @@ import {
4952
tradePlugin,
5053
webhookPlugin,
5154
} from "@elizaos/plugin-coinbase";
55+
import { coinmarketcapPlugin } from "@elizaos/plugin-coinmarketcap";
5256
import { coinPricePlugin } from "@elizaos/plugin-coinprice";
5357
import { confluxPlugin } from "@elizaos/plugin-conflux";
58+
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
5459
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
5560
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
5661
import { evmPlugin } from "@elizaos/plugin-evm";
57-
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
5862
import { flowPlugin } from "@elizaos/plugin-flow";
5963
import { fuelPlugin } from "@elizaos/plugin-fuel";
6064
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
@@ -63,24 +67,25 @@ import { multiversxPlugin } from "@elizaos/plugin-multiversx";
6367
import { nearPlugin } from "@elizaos/plugin-near";
6468
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
6569
import { createNodePlugin } from "@elizaos/plugin-node";
70+
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
71+
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
6672
import { solanaPlugin } from "@elizaos/plugin-solana";
6773
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
74+
import { stargazePlugin } from "@elizaos/plugin-stargaze";
6875
import { storyPlugin } from "@elizaos/plugin-story";
6976
import { suiPlugin } from "@elizaos/plugin-sui";
7077
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
7178
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
79+
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
7280
import { tonPlugin } from "@elizaos/plugin-ton";
7381
import { webSearchPlugin } from "@elizaos/plugin-web-search";
82+
7483
import { giphyPlugin } from "@elizaos/plugin-giphy";
7584
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
7685
import { letzAIPlugin } from "@elizaos/plugin-letzai";
7786
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
87+
7888
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
79-
import { availPlugin } from "@elizaos/plugin-avail";
80-
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
81-
import { artheraPlugin } from "@elizaos/plugin-arthera";
82-
import { stargazePlugin } from "@elizaos/plugin-stargaze";
83-
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
8489
import Database from "better-sqlite3";
8590
import fs from "fs";
8691
import net from "net";
@@ -631,6 +636,9 @@ export async function createAgent(
631636
? nftGenerationPlugin
632637
: null,
633638
getSecret(character, "ZEROG_PRIVATE_KEY") ? zgPlugin : null,
639+
getSecret(character, "COINMARKETCAP_API_KEY")
640+
? coinmarketcapPlugin
641+
: null,
634642
getSecret(character, "COINBASE_COMMERCE_KEY")
635643
? coinbaseCommercePlugin
636644
: null,
+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# @elizaos/plugin-coinmarketcap
2+
3+
A plugin for Eliza that enables cryptocurrency price checking using the CoinMarketCap API.
4+
5+
## Features
6+
7+
- Real-time cryptocurrency price checking
8+
- Support for multiple cryptocurrencies (BTC, ETH, SOL, etc.)
9+
- Currency conversion (USD, EUR, etc.)
10+
- Detailed price and market data
11+
- Natural language processing for price queries
12+
13+
## Installation
14+
15+
```bash
16+
npm install @elizaos/plugin-coinmarketcap
17+
```
18+
19+
## Configuration
20+
21+
1. Get your API key from [CoinMarketCap](https://pro.coinmarketcap.com)
22+
23+
2. Set up your environment variables:
24+
25+
```bash
26+
COINMARKETCAP_API_KEY=your_api_key
27+
```
28+
29+
3. Register the plugin in your Eliza configuration:
30+
31+
```typescript
32+
import { CoinMarketCapPlugin } from "@elizaos/plugin-coinmarketcap";
33+
34+
// In your Eliza configuration
35+
plugins: [
36+
new CoinMarketCapPlugin(),
37+
// ... other plugins
38+
];
39+
```
40+
41+
## Usage
42+
43+
The plugin responds to natural language queries about cryptocurrency prices. Here are some examples:
44+
45+
```plaintext
46+
"What's the current price of Bitcoin?"
47+
"Show me ETH price in USD"
48+
"Get the price of SOL"
49+
```
50+
51+
### Supported Cryptocurrencies
52+
53+
The plugin supports major cryptocurrencies including:
54+
55+
- Bitcoin (BTC)
56+
- Ethereum (ETH)
57+
- Solana (SOL)
58+
- USD Coin (USDC)
59+
- And many more...
60+
61+
### Available Actions
62+
63+
#### GET_PRICE
64+
65+
Fetches the current price of a cryptocurrency.
66+
67+
```typescript
68+
// Example response format
69+
{
70+
symbol: "BTC",
71+
price: 50000.00,
72+
currency: "USD",
73+
marketCap: 1000000000000,
74+
volume24h: 50000000000,
75+
percentChange24h: 2.5
76+
}
77+
```
78+
79+
## API Reference
80+
81+
### Environment Variables
82+
83+
| Variable | Description | Required |
84+
| --------------------- | -------------------------- | -------- |
85+
| COINMARKETCAP_API_KEY | Your CoinMarketCap API key | Yes |
86+
87+
### Types
88+
89+
```typescript
90+
interface PriceData {
91+
price: number;
92+
marketCap: number;
93+
volume24h: number;
94+
percentChange24h: number;
95+
}
96+
97+
interface GetPriceContent {
98+
symbol: string;
99+
currency: string;
100+
}
101+
```
102+
103+
## Error Handling
104+
105+
The plugin includes comprehensive error handling for:
106+
107+
- Invalid API keys
108+
- Rate limiting
109+
- Network timeouts
110+
- Invalid cryptocurrency symbols
111+
- Unsupported currencies
112+
113+
## Rate Limits
114+
115+
CoinMarketCap API has different rate limits based on your subscription plan. Please refer to [CoinMarketCap's pricing page](https://coinmarketcap.com/api/pricing/) for detailed information.
116+
117+
## Support
118+
119+
For support, please open an issue in the repository or reach out to the maintainers:
120+
121+
- Discord: 0xspit
122+
123+
## Links
124+
125+
- [CoinMarketCap API Documentation](https://coinmarketcap.com/api/documentation/v1/)
126+
127+
- [GitHub Repository](https://github.com/elizaOS/eliza/tree/main/packages/plugin-coinmarketcap)
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@elizaos/plugin-coinmarketcap",
3+
"version": "0.1.7-alpha.2",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@elizaos/core": "workspace:*",
9+
"axios": "^1.6.7",
10+
"zod": "^3.22.4"
11+
},
12+
"devDependencies": {
13+
"tsup": "^8.3.5"
14+
},
15+
"scripts": {
16+
"build": "tsup --format esm --dts",
17+
"dev": "tsup --format esm --dts --watch"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { ActionExample } from "@elizaos/core";
2+
3+
export const priceExamples: ActionExample[][] = [
4+
[
5+
{
6+
user: "{{user1}}",
7+
content: {
8+
text: "What's the current price of Bitcoin?",
9+
},
10+
},
11+
{
12+
user: "{{agent}}",
13+
content: {
14+
text: "Let me check the current Bitcoin price for you.",
15+
action: "GET_PRICE",
16+
},
17+
},
18+
{
19+
user: "{{agent}}",
20+
content: {
21+
text: "The current price of BTC is 65,432.21 USD",
22+
},
23+
},
24+
],
25+
[
26+
{
27+
user: "{{user1}}",
28+
content: {
29+
text: "Check ETH price in EUR",
30+
},
31+
},
32+
{
33+
user: "{{agent}}",
34+
content: {
35+
text: "I'll check the current Ethereum price in EUR.",
36+
action: "GET_PRICE",
37+
},
38+
},
39+
{
40+
user: "{{agent}}",
41+
content: {
42+
text: "The current price of ETH is 2,345.67 EUR",
43+
},
44+
},
45+
],
46+
];

0 commit comments

Comments
 (0)