The JavaScript SDK for interacting with a Hiero based network
The project has been transferred from the https://github.com/hashgraph org and therefore the namespace is at several locations still based on hashgraph and hedera.
We are working actively on migrating the namespace fully to hiero.
NOTE: v1 of the SDK is deprecated and support will be discontinued after October 2021. Please install the latest version 2.x or migrate from v1 to the latest 2.x version. You can reference the migration documentation.
# with NPM
$ npm install --save @hiero-ledger/sdk
# with Yarn
$ yarn add @hiero-ledger/sdk
# with PNPM
$ pnpm add @hiero-ledger/sdk
The SDK is also available as a UMD (Universal Module Definition) build, which can be loaded directly in the browser from popular CDNs:
<script src="https://unpkg.com/@hiero-ledger/sdk@2.70.0/dist/umd.js"></script>
When using the UMD build in the browser, the SDK will be available as a global variable sdk. A minified version is also available at dist/umd.min.js.
# with npm
$ npm install -g @go-task/cli
# with homebrew
$ brew install go-task
# with npm
$ npm install -g pnpm
# with homebrew
$ brew install pnpm
Long paths must be enabled. Link to official documentation: Windows-Long-Path
Git must support long paths
LF line endings must be enforced.
After downloading the repo run:
task install
task build to build the SDK
The SDK uses pnpm workspaces to manage its monorepo structure with sub-packages (@hiero-ledger/proto and @hiero-ledger/cryptography). For local development and testing the SDK in other projects, use the following workflow:
Build the SDK and link it globally for use in other local projects:
task build:dev
This command:
proto, cryptography, and the main SDK)In your other project, link to the globally linked SDK:
cd /path/to/your/other/project
pnpm link --global @hiero-ledger/sdk
Now any changes you make to the SDK and rebuild will be immediately available in your project.
When you're done with local development:
# In the hiero-sdk-js repository
task clean
This removes all global links and cleans up node_modules.
To unlink in your other project:
# In your other project
pnpm unlink @hiero-ledger/sdk
pnpm install
The Hiero JavaScript SDK provides comprehensive support for React Native environments, including Expo. To ensure seamless integration, follow the guidelines based on your Expo version:
✅ Hiero Javascript SDK Version 2.60 and Above
For projects using SDK version 2.60 and above, Expo SDK version 51+ is supported, the SDK requires the react-native-get-random-values package in order to work.
To install it, run:
npm install react-native-get-random-values
After installation, the native dependency must be linked for the respective platforms:
🔗 Linking for Native Platforms
cd ios && pod install
Then, rebuild the iOS project.
⚠️ ✅ Hiero Javascript SDK Version 2.59 and Below For projects using SDK version 2.59 and below, Expo SDK Version 49 and below is supported, keep in mind that the SDK uses some functionalities provided from ethers/ethersproject and there is an issue using parts of ethers.js in this environment. A shims package has to be installed and imported before importing the SDK in your project.
npm install @ethersproject/shims
Import it before importing the SDK as shown below:
import '@ethersproject/shims';
import {
Client,
PrivateKey
AccountBalance,
} from "@hiero-ledger/sdk";
...
The Hiero JavaScript SDK does not currently support the following:
See examples.
Every example can be executed using the following command from the root directory: node examples/[name-of-example].js.
Note: Before running any examples, ensure you have:
task build in the root directory.pnpm install in the examples directoryFor detailed information on configuring the SDK, including environment variables and client settings, please refer to the CONFIGURATION.md file.
For contributors and developers who want to run integration tests locally, we provide Solo - the official Hiero local network solution. Solo provides a production-like Kubernetes-based environment with consensus nodes and mirror node services.
Platform Requirements: Solo can only run on macOS or Linux. Windows users must use WSL2.
RAM Requirements:
- Single node setup: Minimum 12 GB RAM
- Dual node setup: Minimum 24 GB RAM (required for dynamic address book tests)
For complete system requirements, see the official Solo documentation.
Install dependencies:
task install
Run Solo setup (cluster + services):
# Single node setup (default, requires 12 GB RAM)
task solo:setup
# Dual node setup (requires 24 GB RAM, needed for DAB tests)
task solo:setup -- --num-nodes 2
solo:setup is the only command that accepts initial version/build arguments:
task solo:setup -- --consensus-node-version v0.70.0
task solo:setup -- --mirror-node-version v0.146.0
task solo:setup -- --consensus-node-version v0.70.0 --mirror-node-version v0.146.0
task solo:setup -- --local-build-path ../hiero-consensus-node/hedera-node/data
Typical timing:
(Required for dynamic address book tests) Configure hosts:
Before running dynamic address book tests with dual-node setup, add Kubernetes service names to your /etc/hosts file:
echo "127.0.0.1 network-node1-svc.solo.svc.cluster.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 envoy-proxy-node1-svc.solo.svc.cluster.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 network-node2-svc.solo.svc.cluster.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 envoy-proxy-node2-svc.solo.svc.cluster.local" | sudo tee -a /etc/hosts
Note: This is only required for dynamic address book tests with dual-node setup. Skip if you're running single-node or other integration tests.
Run integration tests:
task test:integration
Pause or fully tear down when done:
# Pause: destroys mirror node, stops consensus node, stops cluster
task solo:pause
# Complete teardown: removes everything
task solo:teardown
After initial setup, use this workflow for day-to-day development:
# Morning - Resume services (~4 minutes)
task solo:resume
# Work on your code and run tests
task test:integration
# End of day - Pause services
task solo:pause
For detailed setup instructions, troubleshooting, and advanced usage, see the Solo Setup Guide.
Before setting up Solo, ensure you have:
See the Solo Setup Guide for installation instructions.
Unit tests do not require a local network and can be run directly:
task test:unit
Or separately for Node.js and browser:
task test:unit:node
task test:unit:browser
Integration tests require a running local network. After setting up Solo (see above):
# Run all integration tests
task test:integration
# Run Node.js integration tests only
task test:integration:node
# Run browser integration tests only
task test:integration:browser
# Run dual-mode tests
task test:integration:dual-mode
Dynamic address book (DAB) tests require:
task solo:setup -- --num-nodes 2 (requires 24 GB RAM)/etc/hosts configuration: See step 4 in the setup section aboveThese tests validate that the SDK can correctly handle node address changes and reconnections using Kubernetes service names.
Note: All integration tests should pass reliably with the Solo setup. If you encounter failures:
task solo:status/etc/hosts is configuredtask solo:teardown && task solo:setupWhether you’re fixing bugs, enhancing features, or improving documentation, your contributions are important — let’s build something great together! Please read our contributing guide to see how you can get involved.
Hiero uses the Linux Foundation Decentralised Trust Code of Conduct.