Skip to content

hashgraph/hedera-agent-kit-js

Hedera Agent Kit

npm version license build

Build Hedera-powered AI agents in under a minute.

Upgrading from v3? See the v3 → v4 Migration Guide for all breaking changes.

📋 Contents


Key Features

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.

As of v4, the Hedera Agent Kit is organized as a monorepo of @hashgraph-scoped packages. You install the core package plus only the toolkit for your framework (LangChain, Vercel AI SDK, ElizaOS, or MCP). See the v3 → v4 Migration Guide for details.

The Hedera Agent Kit is extensible with third party plugins by other projects.


Agent Kit Functionality

The list of currently available Hedera plugins and functionality can be found in the Plugins & Tools section of this page

👉 See docs/HEDERAPLUGINS.md for the full catalogue & usage examples for Hedera Tools.

Want to add more functionality from Hedera Services? Open an issue!


Third Party Plugins

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 and README in docs/PLUGINS.md

Contribute your own plugin

Hooks and Policies

The Hedera Agent Kit provides a flexible and powerful system for putting limits on tool usage and enforcing business logic, effectively enabling you to limit the functionality of AI agents through Hooks and Policies. These hooks and policies can be used to enforce security, compliance, and other business rules.

Features

  • Hooks and policies can be called when parameters are passed, after parameter normalization, before tool execution when a transaction has been formed, and after tool execution when a transaction has been signed and submitted.
  • Users can create their own hooks and policies on any available Hedera Agent Kit tool, simply fork this repo and create your own hooks and policies in the typescript/src/hooks and typescript/src/policies directories.
  • We have provided examples:

For more information on hooks and policies, see the Hooks and Policies documentation.

Try out an example Audit Hook Agent to see how hooks and policies work in practice.


Developer Examples

You can try out examples of the different types of agents you can build by followin the instructions in the Developer Examples doc in this repo.

First follow instructions in the Developer Examples to clone and configure the example, then choose from one of the examples to run:


🚀 60-Second Quick-Start

See more info at https://www.npmjs.com/package/@hashgraph/hedera-agent-kit

🆓 Free AI Options Available!

  • Ollama: 100% free, runs on your computer, no API key needed
  • Groq: Offers generous free tier with API key
  • Claude & OpenAI: Paid options for production use

1 – Project Setup

Create a directory for your project and install dependencies:

mkdir hello-hedera-agent-kit
cd hello-hedera-agent-kit

Init and install with npm

npm init -y

Open package.json and add "type": "module" to enable ES modules.

Install the core package, LangChain toolkit, your LLM provider, and the Hedera SDK:

npm install @hiero-ledger/sdk @hashgraph/hedera-agent-kit @hashgraph/hedera-agent-kit-langchain @langchain/openai dotenv

Using a different LLM? Replace @langchain/openai with @langchain/anthropic, @langchain/groq, or @langchain/ollama.

2 – Configure: Add Environment Variables

Create an .env file in the root directory of your project:

touch .env

If you already have a testnet account, you can use it. Otherwise, you can create a new one at https://portal.hedera.com/dashboard

Add the following to the .env file:

# Required: Hedera credentials (get free testnet account at https://portal.hedera.com/dashboard)
ACCOUNT_ID="0.0.xxxxx"
PRIVATE_KEY="0x..." # ECDSA encoded private key

# Optional: Add the API key for your chosen AI provider
OPENAI_API_KEY="sk-proj-..."      # For OpenAI (https://platform.openai.com/api-keys)
ANTHROPIC_API_KEY="sk-ant-..."    # For Claude (https://console.anthropic.com)
GROQ_API_KEY="gsk_..."            # For Groq free tier (https://console.groq.com/keys)
# Ollama doesn't need an API key (runs locally)

3 – Simple "Hello Hedera Agent Kit" Example

Create a new file called index.ts in the hello-hedera-agent-kit folder.

touch index.ts

Once you have created the file and added the environment variables, you can run the following code:

// index.ts
import { Client, PrivateKey } from '@hiero-ledger/sdk';
import { AgentMode } from '@hashgraph/hedera-agent-kit';
import { allCorePlugins } from '@hashgraph/hedera-agent-kit/plugins';
import { HederaLangchainToolkit } from '@hashgraph/hedera-agent-kit-langchain';
import { ChatOpenAI } from '@langchain/openai';
import { createAgent } from 'langchain';
import * as dotenv from 'dotenv';

dotenv.config();

async function main() {
  // Hedera client setup (Testnet by default)
  const client = Client.forTestnet().setOperator(
    process.env.ACCOUNT_ID!,
    PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY!)
  );

  // Prepare Hedera toolkit with explicit plugin selection
  const toolkit = new HederaLangchainToolkit({
    client,
    configuration: {
      plugins: allCorePlugins,
      context: { mode: AgentMode.AUTONOMOUS },
    },
  });

  const agent = createAgent({
    model: new ChatOpenAI({ model: 'gpt-4o-mini' }),
    tools: toolkit.getTools(),
    systemPrompt: 'You are a helpful assistant with access to Hedera blockchain tools',
  });

  const response = await agent.invoke({
    messages: [{ role: 'user', content: "What's my HBAR balance?" }],
  });

  const lastMessage = response.messages[response.messages.length - 1];
  console.log(lastMessage.content);
}

main().catch(console.error);

4 – Run Your "Hello Hedera Agent Kit" Example

From the root directory, run your example agent:

npx tsx index.ts

To see more examples, check out the examples/ directory in this repo.


About the Agent Kit

Agent Execution Modes

This tool has two execution modes with AI agents; autonomous execution and return bytes. If you set:

  • mode: AgentMode.RETURN_BYTE the transaction will be executed, and the bytes to execute the Hedera transaction will be returned.
  • 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!)

Hedera Plugins & Tools

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

Currently, the following plugins are available:

Available Plugins & Tools

Core Account Plugin: Tools for Hedera Account Service operations

  • Transfer HBAR

Core Consensus Plugin: Tools for Hedera Consensus Service (HCS) operations

  • Create a Topic
  • Submit a message to a Topic

Core Token Plugin: Tools for Hedera Token Service operations

  • Create a Fungible Token
  • Create a Non-Fungible Token
  • Airdrop Fungible Tokens

Query Plugins: Tools for querying Hedera network data

  • Account queries (balances, info)
  • Token queries (info, airdrops)
  • Consensus queries (topic info, messages)
  • EVM queries (contract info)
  • Misc queries (exchange rates)
  • Transaction queries (transaction records)

See more in docs/PLUGINS.md


Creating Plugins & Contributing

  • You can find a guide for creating plugins in docs/PLUGINS.md

  • This guide also has instructions for publishing and registering your plugin to help our community find and use it.

  • If you would like to contribute and suggest improvements for the cord SDK and MCP server, see CONTRIBUTING.md for details on how to contribute to the Hedera Agent Kit.

License

Apache 2.0

Credits

Special thanks to the developers of the Stripe Agent Toolkit who provided the inspiration for the architecture and patterns used in this project.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors