hedera_agent_js_v01 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +18 -0
- package/index.js +59 -0
- package/package.json +25 -0
- package/readme.md +75 -0
package/.env
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Required: Hedera credentials (get free testnet account at https://portal.hedera.com/dashboard)
|
|
2
|
+
ACCOUNT_ID=0.0.6215264
|
|
3
|
+
PRIVATE_KEY=0x524e632ff110900c9523decf4a004a91aba9c3ade35380b7911a072c105d4272 # ECDSA encoded private key
|
|
4
|
+
|
|
5
|
+
# Optional: Add the API key for your chosen AI provider
|
|
6
|
+
# OPENAI_API_KEY="sk-proj-..." # For OpenAI (https://platform.openai.com/api-keys)
|
|
7
|
+
# con este funciona ok!
|
|
8
|
+
ANTHROPIC_API_KEY=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 # For Claude (https://console.anthropic.com)
|
|
9
|
+
# GROQ_API_KEY=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
|
|
10
|
+
|
|
11
|
+
# Gemini
|
|
12
|
+
# Laika default key created 24 dec 2025
|
|
13
|
+
# GOOGLE_API_KEY=AIzaSyD38pvzgYWserieVlXS1C8jvJZH0Kmdl5I
|
|
14
|
+
|
|
15
|
+
# Ollama doesn't need an API key (runs locally)
|
|
16
|
+
|
|
17
|
+
# Coincap API needed by coincap-hedera-plugin
|
|
18
|
+
COINCAP_BEARER_TOKEN=98a4708b24e4dd6fb2d28247ba52ff37ed08f10d0d121aafddb7c39f9ca90f6a
|
package/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// index.js
|
|
2
|
+
import { Client, PrivateKey } from '@hashgraph/sdk';
|
|
3
|
+
import { HederaLangchainToolkit, AgentMode } from 'hedera-agent-kit';
|
|
4
|
+
import { coreAccountQueryPlugin } from 'hedera-agent-kit';
|
|
5
|
+
import { createAgent } from 'langchain';
|
|
6
|
+
import { MemorySaver } from '@langchain/langgraph';
|
|
7
|
+
|
|
8
|
+
import dotenv from 'dotenv';
|
|
9
|
+
import { ChatAnthropic } from '@langchain/anthropic';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// my plugin
|
|
13
|
+
import { CoinCapHederaPlugin } from 'coincap-hedera-plugin/plugin.js';
|
|
14
|
+
|
|
15
|
+
dotenv.config();
|
|
16
|
+
|
|
17
|
+
async function main() {
|
|
18
|
+
// Hedera client setup (Testnet by default)
|
|
19
|
+
const client = Client.forTestnet().setOperator(
|
|
20
|
+
process.env.ACCOUNT_ID,
|
|
21
|
+
PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Prepare Hedera toolkit
|
|
25
|
+
const hederaAgentToolkit = new HederaLangchainToolkit({
|
|
26
|
+
client,
|
|
27
|
+
configuration: {
|
|
28
|
+
tools: [], // Add specific tools here if needed, or leave empty for defaults/plugins
|
|
29
|
+
plugins: [coreAccountQueryPlugin, CoinCapHederaPlugin], // Add plugins here
|
|
30
|
+
context: {
|
|
31
|
+
mode: AgentMode.AUTONOMOUS,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Fetch tools from a toolkit
|
|
37
|
+
const tools = hederaAgentToolkit.getTools();
|
|
38
|
+
|
|
39
|
+
const llm = new ChatAnthropic({ model: 'claude-3-haiku-20240307' });
|
|
40
|
+
|
|
41
|
+
const agent = createAgent({
|
|
42
|
+
model: llm,
|
|
43
|
+
tools: tools,
|
|
44
|
+
systemPrompt: 'You are a helpful assistant with access to Hedera blockchain tools',
|
|
45
|
+
checkpointer: new MemorySaver(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
console.log('Sending a message to the agent...');
|
|
49
|
+
|
|
50
|
+
// original "what's my balance?"
|
|
51
|
+
const response = await agent.invoke(
|
|
52
|
+
{ messages: [{ role: 'user', content: "Get my balance in HBAR and give it to me converted to USD currency" }] },
|
|
53
|
+
{ configurable: { thread_id: '1' } }
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
console.log(response.messages[response.messages.length - 1].content);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
main().catch(console.error);
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hedera_agent_js_v01",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "https://github.com/hashgraph/hedera-agent-kit-js",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@hashgraph/sdk": "^2.78.0",
|
|
14
|
+
"@langchain/anthropic": "^1.3.3",
|
|
15
|
+
"@langchain/core": "^1.1.8",
|
|
16
|
+
"@langchain/google-genai": "^2.1.3",
|
|
17
|
+
"@langchain/langgraph": "^1.0.7",
|
|
18
|
+
"@langchain/ollama": "^1.1.0",
|
|
19
|
+
"@langchain/openai": "^1.2.0",
|
|
20
|
+
"coincap-hedera-plugin": "^1.0.4",
|
|
21
|
+
"dotenv": "^17.2.3",
|
|
22
|
+
"hedera-agent-kit": "^3.6.0",
|
|
23
|
+
"langchain": "^1.2.3"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# probar instalar mi plugin
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
npm install coincap-hedera-plugin
|
|
5
|
+
|
|
6
|
+
agregar .env
|
|
7
|
+
|
|
8
|
+
agregar el import en index.js
|
|
9
|
+
|
|
10
|
+
agregar los tools (los core plugins y además el nuevo)
|
|
11
|
+
|
|
12
|
+
cambiar el prompt para que pida balance en USD
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
https://github.com/hashgraph/hedera-agent-kit-js
|
|
35
|
+
|
|
36
|
+
npm init -y
|
|
37
|
+
|
|
38
|
+
npm install hedera-agent-kit @langchain/core langchain @langchain/langgraph @langchain/openai @hashgraph/sdk dotenv
|
|
39
|
+
|
|
40
|
+
create your .env
|
|
41
|
+
|
|
42
|
+
# agregando athropic
|
|
43
|
+
npm install @langchain/anthropic
|
|
44
|
+
|
|
45
|
+
agrega esto en .env
|
|
46
|
+
ANTHROPIC_API_KEY=sk-.......
|
|
47
|
+
|
|
48
|
+
agregar esto en la sección imports
|
|
49
|
+
import { ChatAnthropic } from '@langchain/anthropic';
|
|
50
|
+
|
|
51
|
+
reemplazar
|
|
52
|
+
|
|
53
|
+
const llm = new ChatOpenAI({
|
|
54
|
+
model: 'gpt-4o-mini',
|
|
55
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
por
|
|
59
|
+
make dure the claude model and version are active, by looking at https://platform.claude.com/docs/en/about-claude/model-deprecations
|
|
60
|
+
|
|
61
|
+
const llm = new ChatAnthropic({ model: 'claude-3-haiku-20240307' });
|
|
62
|
+
|
|
63
|
+
# agregando ollama
|
|
64
|
+
npm install @langchain/ollama
|
|
65
|
+
|
|
66
|
+
# agregando gemini ----> no funciona
|
|
67
|
+
npm install @langchain/google-genai
|
|
68
|
+
|
|
69
|
+
poner en .env
|
|
70
|
+
GOOGLE_API_KEY=....
|
|
71
|
+
|
|
72
|
+
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
|
|
73
|
+
|
|
74
|
+
const llm = new ChatGoogleGenerativeAI({ model: 'models/gemini-flash-latest' });
|
|
75
|
+
|