Hyperledger is a set of open source projects from Linux Foundation for developing blockchain framework and tools. In this post I am going to explain how to setup the development environment for Hyperledger Fabric (a modular blockchain framework) in Linux.

Before we start installing Hyperledger tools let us start with Linux installation. The distribution of Linux I chose for this post is Ubuntu 19.4. I read on internet that 18.4 is better than 19.4 because the gcc compiler in 19.4 has some problems. But I found some fix and applied it. I installed it on the local hard drive to run natively as well as I installed it in Windows inside Virtual Box tool.

If you want to try virtual version of Linux then install Virtual Box. I downloaded the ISO file for Ubuntu 19.04 and used it as source to install it in Virtual Box.

Once you install Ubuntu run the following command to make sure that you have 19.04 or confirm the version you intended to install.

Install Visual Studio Code 1.39. The latest version 1.4 has as issue with the npm and few other services so I recommend installing Visual Studio Code 1.39 from the following link

https://code.visualstudio.com/updates/v1_39

Click on the extension manager icon from the left navigation in Visual Studio Code and search IBM Blockchain and Choose IBM Blockchain Platform and install it.

Click on the IBM Blockchain Platform Plug-in after installation from the left navigation menu. The icon for that is the last icon in the left navigation menu that is shown.

The following are the prerequisites I installed for this blockchain platform to work on my local machine. The plug-in also shows the list of prerequsites inside the VS Code as shown below in the screenshot.

  • NPM version >= 6.0.0
  • Node.js 8.x or 10.x
  • Docker >= 17.6.2
  • Docker Compose

Instead of installing them by clicking on the required button which opens a browser to install the prerequisite, I used the APT commands to install them from various repositories.

Run the following command to install npm.

sudo apt-get install npm

Run the following command to make sure npm version is greater than 6.0.0.

npm -v

If npm version is not the latest then run the following command to get the latest version.

sudo npm install -g npm@latest

Install nodejs by running the following command.

sudo apt-get install nodejs

Run the following command to check the version of nodejs and make sure it is either 8.x or 10.x version.

node -v

Install docker by running the following command.

sudo apt-get install docker.io

Install docker compose by running the following command.

sudo apt-get install docker-compose

Docker needs some elevated permissions to run the containers from Visual Studio Code. Run the following commands listed below to grant the necessary permissions.

Create a new group in Linux called docker. This may be created during docker installation

sudo groupadd docker

Run the following command to add current user to the docker group.

sudo usermod -aG docker ${USER}

Restart the system. Logoff and logon did not update the new permission for my user id so I restarted my machine.

Run the docker command without sudo prefix to see if it works without any problem.

docker run hello-world

Now close Visual Studio Code and reopen it and launch the IBM Blockchain plug-in by clicking on its icon in the left navigation.

Click on the Local Fabric as shown in the screenshot below.

Finally when the Local Fabric is launched you should see the logs and message as shown in the screenshot below.

Credits and References

https://www.linkedin.com/in/muthusundaravadivel/ for his guidance.

https://code.visualstudio.com/updates/v1_39

https://github.com/IBM-Blockchain/blockchain-vscode-extension/issues/1621

https://www.digitalocean.com/community/questions/how-to-fix-docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket