Skip to main content
This guide walks you through scaffolding a minimal Node.js project that uses the Hedera Agent Kit to run an AI agent against the Hedera Testnet. Pick your framework (LangChain, Vercel AI SDK, or Google ADK), install the packages, configure credentials, and run a single-shot “what’s my balance?” call.

Prerequisites

1. Create your project directory

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

2. Install the agent kit and init the project

npm init -y
Open package.json and add "type": "module" to enable ES modules. Install the core package plus your chosen framework toolkit:
npm install @hiero-ledger/sdk \
  @hashgraph/hedera-agent-kit \
  @hashgraph/hedera-agent-kit-langchain \
  @langchain/openai \
  dotenv

3. Add environment variables

Create a .env file in your project directory:
touch .env
Add your credentials. Use OPENAI_API_KEY for the LangChain / Vercel AI SDK examples, or GOOGLE_API_KEY for the Google ADK example: You can get a Hedera Testnet account on portal.hedera.com.
ACCOUNT_ID="0.0.xxxxx"
PRIVATE_KEY="0x..."      # ECDSA private key
OPENAI_API_KEY="sk-proj-..."
GOOGLE_API_KEY="..."
ANTHROPIC_API_KEY="..."

4. Create your agent

Create an index.js file:
touch index.js
// index.js
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 { createAgent } from 'langchain';
import { ChatOpenAI } from '@langchain/openai';
import 'dotenv/config';

const client = Client.forTestnet().setOperator(
  process.env.ACCOUNT_ID,
  PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY),
  // PrivateKey.fromStringED25519(process.env.PRIVATE_KEY), // use this instead for ED25519 keys
);

const toolkit = new HederaLangchainToolkit({
  client,
  configuration: {
    tools: [],
    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 balance?" }],
});

console.log(response.messages[response.messages.length - 1].content);

5. Run your example

From the project root:
node index.js

Agent Execution Modes

This tool has two execution modes with AI agents:
ModeDescription
AgentMode.AUTONOMOUSThe transaction is executed autonomously using the operator account
AgentMode.RETURN_BYTESThe transaction bytes are returned for the user to sign and execute

Resources

Examples

Clone the repository and try out different example agents. See the full Developer Examples documentation for detailed setup instructions. Available Examples: NPM packages: