Skip to content

Commit 01a6157

Browse files
karanpargalgane5h
andauthored
feat: Add Onchain workflow template (#66)
* feat: Add Onchain workflow template * polish --------- Co-authored-by: Ganesh Swami <[email protected]>
1 parent dc35bba commit 01a6157

File tree

10 files changed

+1053
-6
lines changed

10 files changed

+1053
-6
lines changed

packages/create-zee-app/src/index.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ async function main() {
9090
value: "001-zee-barebones",
9191
label: "Just a barebones template",
9292
},
93+
{
94+
value: "002-onchain-workflow",
95+
label: "Analyze blockchain data to get a wallet's token balances, etc.",
96+
},
9397
],
9498
});
9599

@@ -102,19 +106,15 @@ async function main() {
102106
const templateDir = path.resolve(TEMPLATES_DIR, template);
103107

104108
try {
105-
// Create project directory
106109
await fs.mkdir(targetDir, { recursive: true });
107110

108-
// Copy template files
109111
await copyTemplateFiles(templateDir, targetDir);
110112

111-
// Create .env file with OpenAI API key
112113
const envPath = path.join(targetDir, ".env");
113114
await fs.writeFile(envPath, `OPENAI_API_KEY=${openaiApiKey}\n`, {
114115
flag: "a",
115116
});
116117

117-
// Update package.json with project name
118118
const packageJsonPath = path.join(targetDir, "package.json");
119119
const packageJson = JSON.parse(
120120
await fs.readFile(packageJsonPath, "utf-8")
@@ -125,7 +125,6 @@ async function main() {
125125
JSON.stringify(packageJson, null, 2)
126126
);
127127

128-
// Update agent name in index.ts
129128
const indexTsPath = path.join(targetDir, "src/index.ts");
130129
const indexTsContent = await fs.readFile(indexTsPath, "utf-8");
131130
const updatedContent = indexTsContent.replace(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GOLDRUSH_API_KEY!
2+
OPENAI_API_KEY!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Covalent
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Your AI Agent - Onchain Workflow
2+
3+
This template demonstrates how to create AI agents that can analyze blockchain data using the GoldRush API tools. It showcases various capabilities like analyzing token balances, NFT holdings, and transaction history across multiple blockchains.
4+
5+
## Features
6+
7+
- Token balance analysis across supported blockchains
8+
- NFT holdings tracking with metadata
9+
- Transaction history monitoring
10+
- Historical token price analysis
11+
- Multi-agent workflow coordination
12+
13+
## Getting Started
14+
15+
1. Install dependencies:
16+
17+
```bash
18+
npm install
19+
```
20+
21+
2. Create a `.env` file in the root directory with your API keys:
22+
23+
```bash
24+
OPENAI_API_KEY=your_openai_api_key
25+
GOLDRUSH_API_KEY=your_goldrush_api_key
26+
```
27+
28+
3. Run the development server:
29+
30+
```bash
31+
npm run dev
32+
```
33+
34+
35+
## Available Tools
36+
37+
### 1. Token Balances Tool
38+
Fetches token balances for any wallet address with:
39+
- Token amounts and USD values
40+
- Token metadata (symbol, decimals, contract address)
41+
42+
### 2. NFT Holdings Tool
43+
Retrieves NFT holdings with:
44+
- Collection information
45+
- Token IDs and ownership details
46+
- Media URLs and metadata
47+
48+
### 3. Transaction History Tool
49+
Analyzes transaction history including:
50+
- Transaction types (transfers, swaps, mints)
51+
- Token movements and values
52+
- Timestamps and block information
53+
54+
### 4. Historical Token Price Tool
55+
Provides historical price data with:
56+
- Price history over customizable timeframes (1h, 24h, 7d, 30d)
57+
- Token prices in USD
58+
- Detailed price data points
59+
60+
## Example Usage
61+
62+
```typescript
63+
import {
64+
Agent,
65+
ZeeWorkflow,
66+
TokenBalancesTool,
67+
NFTBalancesTool,
68+
TransactionsTool,
69+
} from "@covalenthq/ai-agent-sdk";
70+
71+
const tools = {
72+
tokenBalances: new TokenBalancesTool(process.env.GOLDRUSH_API_KEY),
73+
nftBalances: new NFTBalancesTool(process.env.GOLDRUSH_API_KEY),
74+
transactions: new TransactionsTool(process.env.GOLDRUSH_API_KEY),
75+
};
76+
77+
const walletAnalyzer = new Agent({
78+
name: "WalletAnalyzer",
79+
model: {
80+
provider: "OPEN_AI",
81+
name: "gpt-4o-mini",
82+
},
83+
description: "An AI assistant that analyzes wallet activities and provides insights about holdings and transactions.",
84+
instructions: [
85+
"Analyze wallet token balances and provide insights about holdings",
86+
"Check NFT collections owned by the wallet",
87+
"Review recent transactions and identify patterns",
88+
"Provide comprehensive analysis of the wallet's activity",
89+
],
90+
tools,
91+
});
92+
```
93+
94+
95+
## License
96+
97+
MIT - See [LICENSE](./LICENSE) file for details.
98+
99+
## Support
100+
101+
For support and discussions, join our [Telegram community](https://t.me/CXT_Agent_SDK).

0 commit comments

Comments
 (0)