Hedera

Instructions to set up your Hedera mirror node and RPC-relay.

Requirements

  • Setup your Axelar verifier
  • Minimum hardware requirements: CPUs: 4 cores RAM: 16 GB Storage (SSD): 500 GB
  • Ubuntu 20.04 LTS or later
  • NPM (installing via nvm is recommended)
  • Docker (>= v20.10.x) installed on your machine.
  • An Amazon Web Services account/Google Cloud Platform account.

Prerequisites

Terminal window
sudo apt install build-essential gcc g++

Clone Hedera Mirror Node Repository

Open your terminal and run the following commands

Terminal window
git clone https://github.com/hashgraph/hedera-mirror-node
cd hedera-mirror-node

Configure Mirror Node

The application.yml file is the main configuration file for the Hedera Mirror Node. We’ll update that file with GCP/AWS Secret and Access keys and the type of Hedera Network we want to mirror.

hedera:
mirror:
importer:
downloader:
accessKey: Enter access key from your GCP/AWS account
cloudProvider: "GCP/s3" #Choose GCP for google or s3 for AWS
secretKey: Enter secret key from your GCP/AWS account
gcpProjectId: ENTER GCP PROJECT ID HERE / N/A for AWS
network: PREVIEWNET/TESTNET/MAINNET #Pick one network

Run Your Mirror Node

Terminal window
docker compose up

Check Logs

Logs should appear like this

Terminal window
importer-1 | 2024-09-05T14:10:43.832Z INFO pool-8-thread-2 c.h.m.i.p.b.BatchInserter Copied 1 rows to transaction table in 388.7 μs
importer-1 | 2024-09-05T14:10:43.833Z INFO pool-8-thread-2 c.h.m.i.p.r.e.s.SqlEntityListener Completed batch inserts in 11.59 ms
importer-1 | 2024-09-05T14:10:43.833Z INFO pool-8-thread-2 c.h.m.i.p.r.RecordFileParser Successfully processed 1 items from 2019-10-11T16_39_21.323930Z.rcd in 11.69 ms
importer-1 | 2024-09-05T14:10:43.948Z INFO pool-8-thread-2 c.h.m.i.p.b.BatchInserter Copied 7 rows to crypto_transfer table in 664.4 μs
importer-1 | 2024-09-05T14:10:43.957Z INFO pool-8-thread-2 c.h.m.i.p.b.BatchInserter Copied 3 rows to entity_temp table in 8.886 ms
importer-1 | 2024-09-05T14:10:43.958Z INFO pool-8-thread-2 c.h.m.i.p.b.BatchInserter Copied 1 rows to record_file table in 483.7 μs
importer-1 | 2024-09-05T14:10:43.958Z INFO pool-8-thread-2 c.h.m.i.p.b.TransactionHashBatchInserter Copied 1 rows from 1 shards to transaction_hash table in 653.0 μs
importer-1 | 2024-09-05T14:10:43.959Z INFO pool-8-thread-2 c.h.m.i.p.b.BatchInserter Copied 1 rows to transaction table in 486.9 μs
importer-1 | 2024-09-05T14:10:43.959Z INFO pool-8-thread-2 c.h.m.i.p.r.e.s.SqlEntityListener Completed batch inserts in 11.39 ms
importer-1 | 2024-09-05T14:10:43.959Z INFO pool-8-thread-2 c.h.m.i.p.r.RecordFileParser Successfully processed 1 items from 2019-10-11T16_39_31.290027001Z.rcd in 11.50 ms
importer-1 | 2024-09-05T14:10:44.539Z INFO scheduling-4 c.h.m.i.d.r.RecordFileDownloader No new signature files to download after file: 2019-10-11T16_39_31.290027001Z.rcd. Retrying in 0.5 s

Verify RPC

Terminal window
curl http://localhost:5551/api/v1/transactions?limit=1

Setup a Hedera JSON-RPC Relayer

You’ll need to setup a JSON-RPC relay to let ampd intract with your Hedera node. Follow the setup instructions:

Clone Hedera JSON-RPC Relayer Repository

Open your terminal and run the following commands

Terminal window
git clone https://github.com/hashgraph/hedera-json-rpc-relay.git
cd hedera-json-rpc-relay

Install dependencies and Build the project

Terminal window
npm install
npm run build

Create a file named .env in the root directory of the project.

Terminal window
CHAIN_ID= The network chain id. Local and previewnet envs should use 0x12a (298). Previewnet, Testnet and Mainnet should use 0x129 (297), 0x128 (296) and 0x127 (295) respectively
MIRROR_NODE_URL= The Mirror Node API endpoint. Official endpoints are Previewnet (https://previewnet.mirrornode.hedera.com), Testnet (https://testnet.mirrornode.hedera.com), Mainnet (https://mainnet-public.mirrornode.hedera.com).
HEDERA_NETWORK= Which network to connect to. Can be MAINNET, PREVIEWNET, TESTNET or OTHER
OPERATOR_ID_MAIN=<AccountID e.g. 0.1.2, can be obtained from portal.hedera.com, wallet or exchange of choice>
OPERATOR_KEY_MAIN=<DER Encoded Private Key, can be obtained from portal.hedera.com, wallet or exchange of choice>

Start the RPC relay server as systemd service

Terminal window
nano /etc/systemd/system/hedera-json-rpc.service
Terminal window
[Unit]
Description=Hedera JSON-RPC Relayer
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=/path/to/hedera-json-rpc-relayer
Environment=NODE_ENV=production NVM_DIR=/root/.nvm
ExecStart=/bin/bash -c 'source $NVM_DIR/nvm.sh && npm run start'
Restart=on-failure
[Install]
WantedBy=multi-user.target

Check Logs

Logs should appear like this

Terminal window
[2024-10-03 16:49:33.460 +0000] INFO (relay/145017 on xxxxx): Configurations successfully loaded
[2024-10-03 16:49:33.461 +0000] TRACE (hbar-rate-limit/145017 on xxxxx): remainingBudget=11000000000 tℏ, resetTimestamp=1727974253461
[2024-10-03 16:49:33.508 +0000] INFO (relay/145017 on xxxxx): SDK client successfully configured to "testnet" for account 0.0.12345 with request timeout value: 10000
[2024-10-03 16:49:33.511 +0000] INFO (mirror-node/145017 on xxxxx): Mirror Node client successfully configured to REST url: https://testnet.mirrornode.hedera.com/api/v1/ and Web3 url: https://testnet.mirrornode.hedera.com/api/v1/
[2024-10-03 16:49:33.512 +0000] INFO (relay/145017 on xxxxx): Relay running with chainId=0x128

Edit on GitHub