Quick setup for interacting with Tolar HashNET blockchain

Igor Jerkovic
TolarHashNETDev
Published in
4 min readOct 11, 2021

In this short tutorial we will go over how to setup minimalistic requirements for interacting with the Tolar HashNET blockchain.

Tolar thin node

The Tolar thin node is a command line interface tool for interacting with the Tolar HashNET blockchain.

We are calling it thin node as it does not store any blockchain data locally. Locally it stores only the keystore, that is your private keys. Otherwise you will use it to proxy calls to the Tolar blockchain. It needs to store your private keys in order to sign transactions (for transactions that alter state on blockchain). Read-only methods, such as inquiring certain blocks can be accessed without signing.

Besides thin nodes, there are also master nodes. For now, the only thing you need to know about the master nodes is, that they are participating in calculating the order of transactions, a process known as achieving consensus. But lets focus on thin nodes in this post.

All the requests from thin node are being sent to endpoints with gRPC service APIs. gRPC requests and responses are formalised through protocol buffer files (proto).

In case you have no experience with gRPC here is a quick introduction tutorial: https://grpc.io/docs/languages/cpp/basics/

The setup

First, go to https://www.tolar.io/download

Under Command line node binary for Mainnet click download binary for your platform

After downloading the binary (this is example for Mac), and unzipping the file, it should look like this:

Contents of the downloaded folder:

  • The config.json is set up to point to the Tolar mainnet, as in this tutorial we will interact with the mainnet
  • with grpc_API_documentation.pdf each gRPC API method is explained
  • under proto you can inspect the proto schema for gRPC service APIs provided by thin node tool
  • README.txt for more details
  • tolar_node_bin is the binary we will run

Running tolar thin node binary

Before starting make sure to set correct directory for your keystore.
In config.json there are these properties:

"keys_file_path"
"secrets_path"

Both of them need to be set to locations where you want your keystore to be stored. Included examples are what would be probable place that someone with username ‘tolar’ would set them to, but any location that you have write access to should do. Usually, you’ll just replace tolar user with your username, for example:

 "keys_file_path": "/Users/tolar/.tolar/keystore/keys.info"
"secrets_path": "/Users/tolar/.tolar/keystore/keys"

would become:

"keys_file_path": "/Users/john/.tolar/keystore/keys.info"
"secrets_path": "/Users/john/.tolar/keystore/keys"

If you move your keystore directory manually, you’ll need to update it in config.json if you want to preserve your addresses and private keys.

Once you’ve setup your config, you can start the node binary and provide it with path to the configuration file. You can have multiple networks, or keystores in multiple configuration files, so when you want to switch you can just start the binary with wanted config.json.
For example:

./tolar_node_bin --config_path=/Users/john/config.json

You are now running the Tolar thin node. Leave this process running and open up a new tab in terminal.

Making your first read call to Tolar blockchain

As we will be making grpc calls, you will need a tool like grpcurl.

List all publicly available grpc services with:

grpcurl —-plaintext 127.0.0.1:9200 list

127.0.0.1:9200 is the ip:host of the thin node, it can be modified in the config.json if needed.

Lets examine what is exposed on the BlockchainService:

grpcurl --plaintext 127.0.0.1:9200 list tolar.proto.BlockchainService

And finally lets make a query to see the block count (meaning the index of the latest block):

grpcurl — plaintext 127.0.0.1:9200 tolar.proto.BlockchainService.GetBlockCount

Some response fields will be encoded in base64 format, but more into that will be shown in a separate post

Recap

In this short tutorial we showed how to setup a thin node for interacting with the Tolar blockchain.

Thin node has 2 main functionalities:

  1. It proxies gRPC calls to the Tolar HashNET blockchain
  2. It serves as a wallet, a storage of private keys. For cases when requests for altering the blockchain state are needed

Additionally, we showed how to make gRPC calls for readonly methods. In another post we will look further into making transactions for which private keys will be needed.

--

--