This series of posts is the Tech Tuesday Blockchain Developer Update and this post is about deploying a Custom Block Explorer. In case you’ve missed a previous edition and want to catch up, you can find all the previous Tech Tuesday updates here.

Deploying a custom block explorer involves several steps after creating a custom blockchain. If you haven't already created a blockchain, learn more about Komodo's custom blockchain development here or discover how to make a blockchain.

The Komodo ecosystem custom block explorers have been made more accessible for projects and developers to easily deploy them early in their blockchain development lifecycle.

Follow these steps and create your own customization guides!

Create Blockchain (Seed & Cryptocurrency Mining Nodes) Mine Some Blocks Stop Seed Node Install Block Explorer Re-Index Seed Node

The same steps can be followed for creating a block explorer for an established chain too.

If you don’t have Komodo or the Agama wallet installed, follow the developer install instructions.

This blockchain developer update will be available in the developer’s documentation new tutorial section for blockchain applications being worked at the moment.

Block Explorer Blockchain Application

Blockchain applications rely on the underlying infrastructure to work. During the development cycle of any custom blockchain application, a blockchain developer has three options for seeing the progress of their work on the network:

Raw data

GUI feedback

Block explorers

Deploying a custom block explorer early in the development phase is a huge benefit because it allows the stakeholders of the blockchain application to interact immediately and track the operations side of the project. Everyone can see that the chain is moving, it is working.

Before diving into how to deploy a block explorer for the custom blockchain project, let’s cover the other two options briefly.

Raw Blockchain Application Data

The raw data consists of transactions. The blockchain developer can access this using the command line tools offered by bitcoin, Zcash or Komodo. Commands like:

bitcoin-cli listunspent will list the UTXOs available in the wallet

komodo-cli getblock 1000000 will return the block data for the one millionth block on komodo’s main chain

komodo-cli gettransaction <transaction hash> to get transaction details

Blockchain developers can rely on their muscle memory to quickly type these commands or write scripts to interrogate the data as they code new functionality into the blockchain.

GUI Feedback

GUI feedback during the blockchain development lifecycle is available to front end application developers that integrate with the exposed functionality of RPC functions. Instead of needing to rely on muscle memory on the command line and parsing data with the human eye, they can use the network RPC functions and parse programmatically to alert them in a polling manner. The network functions for the above examples are here on the developer documentation site:

This takes some “application plumbing” that can be re-used during early GUI development.

The image above is simply validating an address using validateaddress in javascript.

Getting Started Creating A Custom Blockchain

To deploy a block explorer, a blockchain must be running. To start a blockchain there are 4 options, with one option included for future readers of this page:

Get in touch with a service provider on the Blockchain Starter Kit page SaaS Blockchain Cloud Generator currently in closed beta, due for release Q2 2019 Create a blockchain using 2 nodes (production ready) Create a blockchain on your laptop as a single node (production ready) Create a blockchain on your laptop in test mode (currently developers)

Custom Blockchain Characteristics - Parameters

There are 18 different ways to customize a blockchain with Komodo’s technology, offering hundreds of millions of configurations. However, the parameters for our custom blockchain are the simplest they can be:

Name: CUSTOMBLOCK

Number of coins (supply): 1000

Block rewards, blocktime, private transactions, halving period and other customizable blockchain parameters are at their default values.

Using the production ready option 4 from the list above, the BSK steps for creating a blockchain on your laptop (running ubuntu).

Create a Seed Node

komodod -ac_name=CUSTOMBLOCK -ac_supply=1000 &

Create a Mining Node

komodod -ac_name=CUSTOMBLOCK -ac_supply=1000 -datadir=/home/me/coinData &

Making sure they are started and connected to each other.

Check Processes Are Running

Using the ps command

ps aux | grep komodod | grep CUSTOMBLOCK

Which should return the seed node and the mining node in the process list.

Check Blockchain Nodes Are Connected

Using getinfo, we look for the “connections” attribute is 1.

Mining Your Custom Blockchains First Few Blocks

Using setgenerate to enable cryptocurrency mining with 1 thread. After a couple of minutes the getinfo command should return with a blocks attribute more than 0. We can then stop mining by using setgenerate again passing in a false value.

Stop Seed Node

Using the stop command on the seed node.

Block Explorer Install

Components of a Komodo Ecosystem Custom Block Explorer

The insight explorer using bitcore has the best performance for any bitcoin protocol blockchain. Komodo has bitcore integration at the source code level, which makes Komodo one of the most performant blockchains available for game developers. The configuration file needs to expose the ZMQ message bus to the block explorer application. The easy install script manages this for the seed node.

The insight explorer is a nodejs application with three components:

Core Application

Insight API

Insight UI

It relies on an older version of nodejs so using the nodejs version manager (nvm) package is required. If you’re a developer that has some non-standard features setup, when running nvm and the older nodejs environment, those non-standard customization will need to be removed in the virtual environment.

Conventions Used

The ZMQ messaging out of the blockchain will use the port number that is +2 of the RPC port. The block explorer web interface will use the port number that is +3 of the RPC port.

Example:

1777/TCP is the RPC port of your custom blockchain

1779/TCP is the ZMQ port number for distributed messaging (blocks & transactions etc.)

1780/TCP is the HTTP port of the block explorer web interface

The installation scripts create a directory with the blockchain explorer files in CHAINNAME-explorer, where our example will be CUSTOMBLOCK-explorer.

Blockchain Explorer Setup Scripts

Two champions of the Komodo team Decker & G.Charan G have a combined work where the system administration has been taken care of by scripts. Running through this setup, installation of any number of explorers is now a one-command install.

Jumping to these explorer installation notes, we see all we need to do to get running is clone the repository and execute the setup and install scripts:

cd ~ git clone https://github.com/gcharang/komodo-install-explorer cd komodo-install-explorer ./setup-explorer-directory.sh

Blockchain Explorer Install

By runnign the install-assetchain-explorer.sh script with the name of your custom blockchain, it will automatically create all the necessary components and configurations.

./install-assetchain-explorer.sh CUSTOMBLOCK noweb

We have included the noweb option so the explorer is only exposed to localhost 127.0.0.1 and for our example setup, this would be http://127.0.0.1:1780 by convention of RPC port + 3.

To safely expose this on the public internet, using Apache or ngnix as a reverse proxy with a TLS/SSL certificate for secure web connections couldn’t be emphasized more.

Blockchain Explorer Start

The install scripts have created the explorer directory of the name CUSTOMBLOCK-explorer following the convention, and to start the explorer using the automatically generated script:

./CUSTOMBLOCK-explorer-start.sh

Restart Seed Blockchain Node & Reindex Database

When launching your custom blockchain for the first time after installing the explorer, add the -reindex parameter to its launch parameters.

komodod -ac_name=CUSTOMBLOCK -ac_supply=1000 -reindex &

You can now restart mining on your mining node if you stopped it, otherwise it will take a minute for the seed node to sync & catch up to the mining node.

Custom Block Explorer Result

This is a view of the kmdexplorer.io explorer. Your result will look exactly like it. You can now edit some CSS/SCSS/SASS variables and add your own branding!

To get all the latest updates from Komodo, join the monthly email list. On the first Friday of every month, you'll receive a newsletter with information about all of the most important developments from the previous month. You can also join the Komodo Discord server to chat with other community members and the Komodo team.