For the complete documentation index, see llms.txt. This page is also available as Markdown.

Set Up Hiero Node Using NPM CLI Tool

In this tutorial, we will adopt, set up, and run a Hiero node locally using the @hashgraph/hedera-local NPM Command Line Interface (CLI) tool with docker compose.

This tutorial is based on the Hiero Local Node README documentation.


Prerequisites

To get started with this tutorial, ensure that you have the following software installed:

  • Node.js >= v14.x (Check version: node -v)

  • NPM >= v6.14.17 (Check version: npm -v)

  • Docker >= v20.10.x (Check version: docker -v)

  • Docker Compose >= v2.12.3 (Check version: docker compose version)

  • Hardware: Minimum 16GB RAM

Installation

Getting Started

Clone the GitHub repo and navigate to the project folder using the commands below;

Install CLI Tool

The command below can be used to install the official release from the NPM repository.

Note

Local development Installation

Install the dependencies locally.

Running the Node:

Start the local node (Note: Ensure Docker is running):

You can pass the following CLI flags, this would be used later in the following sections:

Other NPM commands:

  • npm run restart to restart the network

  • npm run stop to stop the network

  • npm run generate-accounts to generate new accounts - network must be running first

You should see the following response in the terminal:

To generate default accounts and start the local node in detached mode, use the command below:

You should see the following response in the terminal:

Running Hedera Node on Terminal

Verify Running Node

There are different ways to verify that a node is running;

  • Check Block Number using Hashscan Block Explorer

  • Send cURL request to getBlockNumber

Check Block Number using Hashscan Block Explorer

Visit the local mirror node explorer endpoint (http://localhost:8080/devnet/dashboard) in your web browser. Ensure that LOCALNET is selected, as this will show you the Hedera network running within your local network.

Select any of the listed blocks to view the details (Consensus, Block, Transaction Hash, etc) for a particular block.

Hedera Explorer - View LOCALNET
Hedera Explorer - View LOCALNET Details

Send cURL request to getBlockNumber

Let's verify that we are able to interact with Hedera Testnet using JSON-RPC by issuing an eth_getBlockByNumber JSON-RPC request.

Enter the curl command below:

You should get the following response:

Troubleshooting

Find below some common errors and how to troubleshoot them:

Error: Node cannot start properly because necessary ports are in use!

Fix

Useful Terms

For an in-depth explanation of the different terms below, see the glossary documentation.

  • Accounts list (ED25519 keys)

  • Private keys

  • Public address

Next Steps

Want to learn how to deploy smart contracts on Hedera? Visit the guide on how to Deploy a Smart Contract Using Hardhat and Hedera JSON-RPC Relay.

Summary

In this tutorial, we successfully set up and ran the Hedera local node using the NPM CLI tool, generated default accounts, and solved common errors encountered when running the local node.

Useful Resources

Last updated