githubEdit

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-localarrow-up-right NPM Command Line Interface (CLI) tool with docker compose.

circle-info

Prerequisites

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

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 NPMarrow-up-right repository.

circle-exclamation

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/dashboardarrow-up-right) 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!

circle-check

Useful Terms

For an in-depth explanation of the different terms below, see the glossary documentationarrow-up-right.

  • 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 Relayarrow-up-right.

Summary

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

Useful Resources

Last updated