How to Install Blockchain on Ubuntu
In this step-by-step guide we will show you “How to install blockchain on Ubuntu Blockchain.” Blockchain is, quite literally, a chain of blocks that contain and distribute digital information (the block) stored in a public database (the chain). The blocks store different types of information. Say, for instance, blockchain is being used to store customers’ information. Blocks associated with purchases can contain information such as date, time, billing, who is participating in a transaction, digital signature, service, and hashes.
What makes this system unique is that it is decentralized. What that means is that blockchain moves the distributing and dispersing power away from a central authority. It does this by distributing the processes to numerous authorities around the chain.
There are a few tools to make blockchain happen on your in-house datacenter server. One of the most popular tools is Hyperledger Fabric. And because Hyperledger Fabric is open-source, it can be installed on your on-premises servers for free. That way your .NET development company can create a custom solution to work with your blockchain system.
I want to walk you through one example of installing Hyperledger Fabric on Ubuntu Server 18.04. This particular example comes by way of InstaMed Innovation Lab and is focused on healthcare payments among providers, payers, and patients.
What you’ll need
The only things you’ll need to make this work are:
- A running instance of Ubuntu server.
- A user with sudo privileges.
- A good amount of time.
This installation does take a bit of time, so give yourself a couple of hours to get it finished. With that said, let’s install.
The first thing you’ll want to do is update and upgrade Ubuntu. Do note that the kernel could get upgraded in the process. Should that happen, you’ll need to reboot your server (so the upgrades take effect). Because of this, make sure you run the upgrade at a time when a reboot is feasible.
To update and upgrade Ubuntu, log in and (at a terminal window) issue the following commands:
sudo apt-get update
sudo apt-get upgrade -y
Once the upgrade completes, reboot (if necessary) and continue on.
Install necessary dependencies
The first thing that must be done is the installation of a few dependencies. This installation will require Curl, Docker, Docker-compose, Golang, and Python. To install these dependencies, issue the command:
sudo apt-get install curl git docker.io docker-compose golang python -y
With those dependencies installed, start and enable the Docker engine with the commands:
sudo systemctl start docker
sudo systemctl enable docker
Which command enables the docker engine?
Create a new user
We’re going to create a user, named blockchain, which will be used to install the next pieces and run the installation. To create this user, issue the command:
sudo useradd -m -d /home/blockchain blockchain
You must add the new user to the docker group, otherwise, it won’t be able to run the docker command without sudo (which is a security issue). To add the user, issue the command:
sudo usermod -aG docker blockchain
Install Node and npm
Next, we need to install Node and npm. However, we need to install those two pieces of the puzzle as the blockchain user. To do this, first change to the blockchain user with the command:
sudo su blockchain
Change into the user directory and call bash with the two commands:
Download and install the necessary software with the following commands:
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh
nvm install 8.11.4
Once these commands complete, exit out of the blockchain user with two exit commands, as in:
Install Hyperledger Fabric
Next, we’re going to install Hyperledger Fabric. To do that, download an installation file and run it, which can both be done with the single command:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.4.4
Once that completes, log back in as the blockchain user with the commands:
sudo su blockchain
Clone the Instamed repo
We’re now going to clone a Git repository from Instamed and then install the project. First clone the repo with the command:
git clone https://github.com/instamed/healthcare-payments-blockchain.git
Change into that newly-cloned directory with the command:
Using npm, install the project with the command:
The above command will take some time to run. When it completes, start the project with the command:
Running the mock data and the server
Next, we’re going to insert sample data into the project (which is required for the frontend demo app). This is another step that will take considerable time. For this, run the command:
npm run mockData
Once you get the bash prompt back, start the server with the command:
npm run server:start
Install and configure Byzantine Browser
Now we need to add a backend service and a frontend website. This is handled by the Byzantine Browser. You’ll need to log into your hosting server with a second session (using SSH or a virtual terminal). Once you’ve gained access with a second session, change to the blockchain user with the commands:
sudo su blockchain
Download and install the Byzantine Browser with the following commands:
git clone https://github.com/worldsibu/byzantine-browser.git
npm run build
Copy the necessary keys from the hyperledger-fabric-network directory with the command:
cp $HOME/hyperledger-fabric-network/.hfc-org1/* ~/byzantine-browser/hfc-key-store/
Open the Byzantine Browser configuration file with the command:
In that file, paste the following the contents:
Run the Byzantine Server with the command:
Finally, open a web browser and point it to http://SERVER_IP:8080 (where SERVER_IP is the IP address of your hosting server). You will be greeted with a Start Demo button (Figure 1).
The blockchain demo is ready to be experienced.
Click Start Demo and begin to work with your newly installed blockchain tool.
Conclusion – Blockchain on Ubuntu
This is a great way to see how an instance of blockchain can be installed and used, with only a single Ubuntu server. Get it up and running and kick the tires, or have your .NET developers dive into the code and see what can be done to help make this demo work for your business.
Get started today and earn 128 bonus blocks
Already have an account? Sign In