How to install Hyperledger Fabric on Ubuntu?


Hyperledger is an umbrella project under the Linux Foundation for the development of open-source blockchain and related tools which was started in 2015. Hyperledger Fabric which is a part of the Hyperledger project is a modular blockchain framework for enterprise blockchain platforms.

It aims at providing the foundation for the development of enterprise-grade applications and industry solutions using blockchain technology.

Using Hyperleger Fabric has several benefits –

  • Permissioned network
  • Confidential transactions
  • Pluggable architecture
  • Easy to get started

In this article, I will discuss how to install Hyperledger Fabric on a Ubuntu system.

Prerequisites

To install Hyperleger Fabric you should have the following –

  • The recent version of Ubuntu installed system (I will use Ubuntu 20.04 LTS)
  • Access to a user account with sudo permissions
  • The latest version of curl, Docker, Go, and Node.js installed

How to install Hyperleger Fabric on Ubuntu

Before installing Hyperleger Fabric on your system you need to install a few requisite packages. Now follow the steps below to install Hyperledger on your system.

Step 1: Update the package list

Run the given command to update the package list and upgrade packages to their latest version –

sudo apt update && sudo apt upgrade -y

Step 2: Install the cURL tool

The curl command in Linux is used to download or upload data from or to a server we will use for downloading packages in our terminal.

sudo apt install curl -y

Step 3: Install Docker and Docker compose in Ubuntu

Docker is a platform that makes it easier to create, deploy, and use an application using containers. Use the given commands to install it on your system –

Setup docker’s official repository

First, install the following packages to allow apt to use a repository over HTTPS –

sudo apt install apt-transport-https ca-certificates gnupg-agent software-properties-comman

Add the official GPG key of Docker –

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker’s stable repository –

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

Refresh the package list by using –

sudo apt update

Install Docker CE

Finally, use the given command to install the Docker –

sudo apt install docker-ce

You can check the Docker version by using –

docker --version

Install Docker compose

Download the latest version of Docker compose by running the given command –

 sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply the executable permissions to binary –

 sudo chmod +x /usr/local/bin/docker-compose

You can verify the installation by using –

docker-compose --version

Step 4: Install Go programming in Ubuntu

Use the following command to install the Go programing language on your system.

sudo apt install golang -y

You can verify the installation by using –

go version

 Step 5: Install Node.js and NPM

Node.js is an open-source, cross-platform JavaScript runtime environment designed to run JavaScript code on the server-side.

There are various ways to install NodeJS on Ubuntu. We will use NVM or Node Version Manager to install Node.js on Ubuntu. This allows you to install and maintain different versions of Node.js and associated packages.

First, install NVM by using the given command –

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Restart your shell or use the following command to source the file –

source ~/.bashrc

You can check the available NodeJS versions by using –

nvm list-remote | more

We will install the latest LTS release of NodeJS –

nvm install 14.17.6

Once installation is completed you can verify the installation by using –

node --version
npm --version

Step 6: Installing Hyperledger Fabric in Ubuntu

Use the following command to download the Hyperledger Fabric on your Ubuntu system.

curl -sSL https://bit.ly/2ysbOFE | bash -s 1.4.4
download fabric sample

This will download the files in the fabric-samples directory. If you want you can download the latest 2.0.0 version of Hyperledger Fabric.

Now add the fabric bin path to the PATH environment variable. Make sure to use the correct path where you have downloaded fabric binaries.

export PATH=/home/$USER/fabric-samples/bin:$PATH

Update the environment variable for your current shell session –

source ~/.profile

Testing a Hyperleger Fabric sample

After successfully installing all the packages given above and downloading fabric samples you can now test a Hyperleger Fabric sample on your system.

We will run a pre-built script called “Build Your First Network or BYFN” that will test if you have everything installed correctly or not.

cd /home/$USER/fabric-samples/first-network

Execute the given command this will display a brief description as to what will occur, along with a yes/no command-line prompt. Press y and then enter to perform the described actions –

./byfn.sh generate 
byfn generate

Now use the following command to bring up the test network –

./byfn.sh up

This should start the sample network on your system.

The detailed guide to set up the Hyperledger Fabric and tutorials for building your first application are given in its official documentation.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.