@hashgraph/hedera-agent-kit 3.8.2-rc.1
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/LICENCE +190 -0
- package/README.md +310 -0
- package/dist/cjs/elizaos/index.d.ts +354 -0
- package/dist/cjs/elizaos/index.js +48415 -0
- package/dist/cjs/elizaos/index.js.map +1 -0
- package/dist/cjs/index.d.ts +1775 -0
- package/dist/cjs/index.js +5719 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/elizaos/index.d.mts +354 -0
- package/dist/esm/elizaos/index.mjs +4999 -0
- package/dist/esm/elizaos/index.mjs.map +1 -0
- package/dist/esm/index.d.mts +1775 -0
- package/dist/esm/index.mjs +5652 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +93 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
SPDX-License-Identifier: Apache-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Hedera Agent Kit
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
> Build Hedera-powered AI agents **in under a minute**.
|
|
8
|
+
|
|
9
|
+
## 📋 Contents
|
|
10
|
+
|
|
11
|
+
- [Key Features](#key-features)
|
|
12
|
+
- [About the Agent Kit Functionality](#agent-kit-functionality)
|
|
13
|
+
- [Third Party Plugins](#third-party-plugins)
|
|
14
|
+
- [Developer Examples](#developer-examples)
|
|
15
|
+
- [🚀 60-Second Quick-Start](#-60-second-quick-start)
|
|
16
|
+
- [Agent Execution Modes](#agent-execution-modes)
|
|
17
|
+
- [Hedera Plugins & Tools](#hedera-plugins--tools)
|
|
18
|
+
- [Creating Plugins & Contributing](#creating-plugins--contributing)
|
|
19
|
+
- [License](#license)
|
|
20
|
+
- [Credits](#credits)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Key Features
|
|
25
|
+
|
|
26
|
+
The Hedera Agent Kit is an open-source toolkit that brings intelligent agent workflows to the Hedera network. It’s designed for developers who want to integrate Hedera account management and Hedera native functionality into agent applications. With the Hedera Agent Kit, developers can build agents that interact on-chain through a conversational interface. This means Hedera agents can do more than process information; they can also send tokens, manage accounts, store data on Hedera Consensus Service, and coordinate workflows directly on a public ledger.
|
|
27
|
+
|
|
28
|
+
This version of the Hedera Agent Kit, known as v3, is a complete rewrite of the original version. It is designed to be more flexible and easier to use, with a focus on developer experience. It enables direct API execution through a simple HederaAgentAPI class, with an individual LangChain tools call for each example. [Learn more about Hedera Agent Kit V3](https://hedera.com/blog/whats-new-in-ai-studio/)
|
|
29
|
+
|
|
30
|
+
The Hedera Agent Kit is extensible with third party plugins by other projects.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Agent Kit Functionality
|
|
35
|
+
|
|
36
|
+
The list of currently available Hedera plugins and functionality can be found in the [Plugins & Tools section](#hedera-plugins-tools) of this page
|
|
37
|
+
|
|
38
|
+
👉 See [docs/HEDERAPLUGINS.md](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/HEDERAPLUGINS.md) for the full catalogue & usage examples for Hedera Tools.
|
|
39
|
+
|
|
40
|
+
Want to add more functionality from Hedera Services? [Open an issue](https://github.com/hedera-dev/hedera-agent-kit/issues/new?template=toolkit_feature_request.yml&labels=feature-request)!
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### Third Party Plugins
|
|
45
|
+
The Hedera Agent Kit is extensible with third party plugins by other projects. See how you can build and submit your own plugin to listed as a Hedera Agent Kit plugin in [Hedera Docs](https://docs.hedera.com/hedera/open-source-solutions/ai-studio-on-hedera/hedera-ai-agent-kit/hedera-agent-kit-js/plugins) and README in [docs/PLUGINS.md](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/PLUGINS.md)
|
|
46
|
+
|
|
47
|
+
- [Memejob Plugin](https://www.npmjs.com/package/@buidlerlabs/hak-memejob-plugin) provides a streamlined interface to the [**memejob**](https://memejob.fun/) protocol, exposing the core actions (`create`, `buy`, `sell`) for interacting with meme tokens on Hedera:
|
|
48
|
+
|
|
49
|
+
Github repository: https://github.com/buidler-labs/hak-memejob-plugin
|
|
50
|
+
|
|
51
|
+
- [Bonzo Plugin](https://www.npmjs.com/package/@bonzofinancelabs/hak-bonzo-plugin) is a unified SDK to the [**Bonzo**](https://bonzo.finance) protocol, exposing the core actions (`deposit`, `withdraw`, `repay`, `borrow`) for decentralised lending and borrowing on Hedera:
|
|
52
|
+
|
|
53
|
+
Github repository: [https://github.com/Bonzo-Labs/bonzoPlugin](https://github.com/Bonzo-Labs/bonzoPlugin)
|
|
54
|
+
|
|
55
|
+
- [SaucerSwap Plugin](https://www.npmjs.com/package/hak-saucerswap-plugin) provides a streamlined interface to the [**SaucerSwap**](https://saucerswap.finance) DEX, exposing the core actions (`saucerswap_get_swap_quote`, `saucerswap_swap_tokens`, `saucerswap_get_pools`, `saucerswap_add_liquidity`, `saucerswap_remove_liquidity`, `saucerswap_get_farms`) for swaps, liquidity, and farming insights:
|
|
56
|
+
|
|
57
|
+
NPM: https://www.npmjs.com/package/hak-saucerswap-plugin
|
|
58
|
+
Source: https://github.com/jmgomezl/hak-saucerswap-plugin
|
|
59
|
+
Tested/endorsed version: hak-saucerswap-plugin@1.0.1
|
|
60
|
+
|
|
61
|
+
- [Pyth Plugin](https://www.npmjs.com/package/hak-pyth-plugin) provides access to the [**Pyth Network**](https://www.pyth.network/) price feeds via the Hermes API, exposing tools to list feeds and fetch latest prices:
|
|
62
|
+
|
|
63
|
+
Github repository: [https://github.com/jmgomezl/hak-pyth-plugin](https://github.com/jmgomezl/hak-pyth-plugin).
|
|
64
|
+
Tested/endorsed version of plugin: hak-pyth-plugin@0.1.1
|
|
65
|
+
|
|
66
|
+
- [CoinCap Plugin](https://www.npmjs.com/package/coincap-hedera-plugin) provides access to the [**CoinCap API service**](https://www.coincap.io) to access cryptocurrency market data. It exposes the action (`get HBAR price in USD`) to get the current price of HBAR in USD currency, by using it you can ask your agent to get your current HBAR balance expressed in USD.
|
|
67
|
+
|
|
68
|
+
Github repository: [https://github.com/henrytongv/coincap-hedera-plugin](https://github.com/henrytongv/coincap-hedera-plugin). Tested/endorsed version of plugin: coincap-hedera-plugin@1.0.4
|
|
69
|
+
|
|
70
|
+
- [Chainlink price feed Plugin](https://www.npmjs.com/package/chainlink-pricefeed-plugin) provides access to the [**Chainlink price feeds**](https://docs.chain.link/data-feeds/price-feeds) to get data aggregated from many data sources. It exposes the action (`get price feed`) that allows you to get the current price for ETH, BTC, HBAR, LINK, USDC, UST or DAI.
|
|
71
|
+
|
|
72
|
+
Github repository: [https://github.com/henrytongv/chainlink-price-plugin-js](https://github.com/henrytongv/chainlink-price-plugin-js). Tested/endorsed version of plugin: chainlink-pricefeed-plugin@1.0.4
|
|
73
|
+
|
|
74
|
+
_[Contribute your own plugin](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/PLUGINS.md)_
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Developer Examples
|
|
78
|
+
|
|
79
|
+
You can try out examples of the different types of agents you can build by followin the instructions in the [Developer Examples](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md) doc in this repo.
|
|
80
|
+
|
|
81
|
+
First follow instructions in the [Developer Examples to clone and configure the example](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md), then choose from one of the examples to run:
|
|
82
|
+
|
|
83
|
+
- **Option A -** [Example Tool Calling Agent](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-a-run-the-example-tool-calling-agent)
|
|
84
|
+
- **Option B -** [Example Structured Chat Agent](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-b-run-the-structured-chat-agent)
|
|
85
|
+
- **Option C -** [Example Return Bytes Agent](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-c-try-the-human-in-the-loop-chat-agent)
|
|
86
|
+
- **Option D -** [Example MCP Server](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-d-try-out-the-mcp-server)
|
|
87
|
+
- **Option E -** [Example ElizaOS Agent](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-e-try-out-the-hedera-agent-kit-with-elizaos)
|
|
88
|
+
- **Option F -** [Example Preconfigured MCP Client Agent](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-g-try-out-the-preconfigured-mcp-client-agent)
|
|
89
|
+
- **Option G -** [Example Google ADK Agent](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/DEVEXAMPLES.md#option-h-try-out-the-google-adk-agent)
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🚀 60-Second Quick-Start
|
|
94
|
+
|
|
95
|
+
See more info at [https://www.npmjs.com/package/@hashgraph/hedera-agent-kit](https://www.npmjs.com/package/@hashgraph/hedera-agent-kit)
|
|
96
|
+
|
|
97
|
+
### 🆓 Free AI Options Available!
|
|
98
|
+
|
|
99
|
+
- **Ollama**: 100% free, runs on your computer, no API key needed
|
|
100
|
+
- **[Groq](https://console.groq.com/keys)**: Offers generous free tier with API key
|
|
101
|
+
- **[Claude](https://console.anthropic.com/settings/keys) & [OpenAI](https://platform.openai.com/api-keys)**: Paid options for production use
|
|
102
|
+
|
|
103
|
+
### 1 – Project Setup
|
|
104
|
+
Create a directory for your project and install dependencies:
|
|
105
|
+
```bash
|
|
106
|
+
mkdir hello-hedera-agent-kit
|
|
107
|
+
cd hello-hedera-agent-kit
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Init and install with npm
|
|
111
|
+
```bash
|
|
112
|
+
npm init -y
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Open `package.json` and add `"type": "module"` to enable ES modules.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm install @hashgraph/hedera-agent-kit @langchain/core langchain @langchain/langgraph @langchain/openai @hashgraph/sdk dotenv
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 2 – Configure: Add Environment Variables
|
|
122
|
+
|
|
123
|
+
Create an `.env` file in the root directory of your project:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
touch .env
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
If you already have a **testnet** account, you can use it. Otherwise, you can create a new one at [https://portal.hedera.com/dashboard](https://portal.hedera.com/dashboard)
|
|
130
|
+
|
|
131
|
+
Add the following to the .env file:
|
|
132
|
+
|
|
133
|
+
```env
|
|
134
|
+
# Required: Hedera credentials (get free testnet account at https://portal.hedera.com/dashboard)
|
|
135
|
+
ACCOUNT_ID="0.0.xxxxx"
|
|
136
|
+
PRIVATE_KEY="0x..." # ECDSA encoded private key
|
|
137
|
+
|
|
138
|
+
# Optional: Add the API key for your chosen AI provider
|
|
139
|
+
OPENAI_API_KEY="sk-proj-..." # For OpenAI (https://platform.openai.com/api-keys)
|
|
140
|
+
ANTHROPIC_API_KEY="sk-ant-..." # For Claude (https://console.anthropic.com)
|
|
141
|
+
GROQ_API_KEY="gsk_..." # For Groq free tier (https://console.groq.com/keys)
|
|
142
|
+
# Ollama doesn't need an API key (runs locally)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 3 – Simple "Hello Hedera Agent Kit" Example
|
|
146
|
+
|
|
147
|
+
Create a new file called `index.js` in the `hello-hedera-agent-kit` folder.
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
touch index.js
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Once you have created a new file `index.js` and added the environment variables, you can run the following code:
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
// index.js
|
|
157
|
+
import { Client, PrivateKey } from '@hashgraph/sdk';
|
|
158
|
+
import { HederaLangchainToolkit, AgentMode } from '@hashgraph/hedera-agent-kit';
|
|
159
|
+
import { createAgent } from 'langchain';
|
|
160
|
+
import { MemorySaver } from '@langchain/langgraph';
|
|
161
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
162
|
+
import dotenv from 'dotenv';
|
|
163
|
+
|
|
164
|
+
dotenv.config();
|
|
165
|
+
|
|
166
|
+
async function main() {
|
|
167
|
+
// Hedera client setup (Testnet by default)
|
|
168
|
+
const client = Client.forTestnet().setOperator(
|
|
169
|
+
process.env.ACCOUNT_ID,
|
|
170
|
+
PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY)
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// Prepare Hedera toolkit
|
|
174
|
+
const hederaAgentToolkit = new HederaLangchainToolkit({
|
|
175
|
+
client,
|
|
176
|
+
configuration: {
|
|
177
|
+
tools: [], // Add specific tools here if needed, or leave empty for defaults/plugins
|
|
178
|
+
plugins: [], // Add plugins here
|
|
179
|
+
context: {
|
|
180
|
+
mode: AgentMode.AUTONOMOUS,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Fetch tools from a toolkit
|
|
186
|
+
const tools = hederaAgentToolkit.getTools();
|
|
187
|
+
|
|
188
|
+
const llm = new ChatOpenAI({
|
|
189
|
+
model: 'gpt-4o-mini',
|
|
190
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const agent = createAgent({
|
|
194
|
+
model: llm,
|
|
195
|
+
tools: tools,
|
|
196
|
+
systemPrompt: 'You are a helpful assistant with access to Hedera blockchain tools',
|
|
197
|
+
checkpointer: new MemorySaver(),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
console.log('Sending a message to the agent...');
|
|
201
|
+
|
|
202
|
+
const response = await agent.invoke(
|
|
203
|
+
{ messages: [{ role: 'user', content: "what's my balance?" }] },
|
|
204
|
+
{ configurable: { thread_id: '1' } }
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
console.log(response.messages[response.messages.length - 1].content);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
main().catch(console.error);
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### 4 – Run Your "Hello Hedera Agent Kit" Example
|
|
214
|
+
|
|
215
|
+
From the root directory, run your example agent, and prompt it to give your hbar balance:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
node index.js
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
If you would like, try adding in other prompts to the agent to see what it can do.
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
// ...
|
|
225
|
+
//original
|
|
226
|
+
const response = await agent.invoke(
|
|
227
|
+
{ messages: [{ role: 'user', content: "what's my balance?" }] },
|
|
228
|
+
{ configurable: { thread_id: '1' } }
|
|
229
|
+
);
|
|
230
|
+
// or
|
|
231
|
+
const response = await agent.invoke(
|
|
232
|
+
{ messages: [{ role: 'user', content: "create a new token called 'TestToken' with symbol 'TEST'" }] },
|
|
233
|
+
{ configurable: { thread_id: '1' } }
|
|
234
|
+
);
|
|
235
|
+
// or
|
|
236
|
+
const response = await agent.invoke(
|
|
237
|
+
{ messages: [{ role: 'user', content: "transfer 5 HBAR to account 0.0.1234" }] },
|
|
238
|
+
{ configurable: { thread_id: '1' } }
|
|
239
|
+
);
|
|
240
|
+
// or
|
|
241
|
+
const response = await agent.invoke(
|
|
242
|
+
{ messages: [{ role: 'user', content: "create a new topic for project updates" }] },
|
|
243
|
+
{ configurable: { thread_id: '1' } }
|
|
244
|
+
);
|
|
245
|
+
// ...
|
|
246
|
+
console.log(response.messages[response.messages.length - 1].content);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
> To get other Hedera Agent Kit tools working, take a look at the example agent implementations at [https://github.com/hedera-dev/hedera-agent-kit/tree/main/typescript/examples/langchain](https://github.com/hedera-dev/hedera-agent-kit/tree/main/typescript/examples/langchain)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## About the Agent Kit
|
|
254
|
+
|
|
255
|
+
### Agent Execution Modes
|
|
256
|
+
|
|
257
|
+
This tool has two execution modes with AI agents; autonomous execution and return bytes. If you set:
|
|
258
|
+
|
|
259
|
+
- `mode: AgentMode.RETURN_BYTE` the transaction will be executed, and the bytes to execute the Hedera transaction will be returned.
|
|
260
|
+
- `mode: AgentMode.AUTONOMOUS` the transaction will be executed autonomously, using the accountID set (the operator account can be set in the client with `.setOperator(process.env.ACCOUNT_ID!`)
|
|
261
|
+
|
|
262
|
+
### Hedera Plugins & Tools
|
|
263
|
+
|
|
264
|
+
The Hedera Agent Kit provides a set of tools, bundled into plugins, to interact with the Hedera network. See how to build your own plugins in [docs/HEDERAPLUGINS.md](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/HEDERAPLUGINS.md)
|
|
265
|
+
|
|
266
|
+
Currently, the following plugins are available:
|
|
267
|
+
|
|
268
|
+
#### Available Plugins & Tools
|
|
269
|
+
|
|
270
|
+
#### Core Account Plugin: Tools for Hedera Account Service operations
|
|
271
|
+
|
|
272
|
+
- Transfer HBAR
|
|
273
|
+
|
|
274
|
+
#### Core Consensus Plugin: Tools for Hedera Consensus Service (HCS) operations
|
|
275
|
+
|
|
276
|
+
- Create a Topic
|
|
277
|
+
- Submit a message to a Topic
|
|
278
|
+
|
|
279
|
+
#### Core HTS Plugin: Tools for Hedera Token Service operations
|
|
280
|
+
|
|
281
|
+
- Create a Fungible Token
|
|
282
|
+
- Create a Non-Fungible Token
|
|
283
|
+
- Airdrop Fungible Tokens
|
|
284
|
+
|
|
285
|
+
#### Core Queries Plugin: Tools for querying Hedera network data
|
|
286
|
+
|
|
287
|
+
- Get Account Query
|
|
288
|
+
- Get HBAR Balance Query
|
|
289
|
+
- Get Account Token Balances Query
|
|
290
|
+
- Get Topic Messages Query
|
|
291
|
+
|
|
292
|
+
_See more in [docs/PLUGINS.md](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/PLUGINS.md)_
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Creating Plugins & Contributing
|
|
297
|
+
|
|
298
|
+
- You can find a guide for creating plugins in [docs/PLUGINS.md](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/PLUGINS.md)
|
|
299
|
+
|
|
300
|
+
- This guide also has instructions for [publishing and registering your plugin](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/docs/PLUGINS.md#publish-and-register-your-plugin) to help our community find and use it.
|
|
301
|
+
|
|
302
|
+
- If you would like to contribute and suggest improvements for the cord SDK and MCP server, see [CONTRIBUTING.md](https://github.com/hashgraph/hedera-agent-kit-js/blob/main/CONTRIBUTING.md) for details on how to contribute to the Hedera Agent Kit.
|
|
303
|
+
|
|
304
|
+
## License
|
|
305
|
+
|
|
306
|
+
Apache 2.0
|
|
307
|
+
|
|
308
|
+
## Credits
|
|
309
|
+
|
|
310
|
+
Special thanks to the developers of the [Stripe Agent Toolkit](https://github.com/stripe/agent-toolkit) who provided the inspiration for the architecture and patterns used in this project.
|