There is a entire library of Blockchain APIs which you can select according to the needs that suffice your application. Some Libraries is open-sourced and Some are private. For examples, IBM ' s Hyperledger Fabric Project, Ethereum, Openchain, Multichain is few of the open sourced models which a Re popular in the industry today.
This tutorial aims to help you get started and setup your development environment for a blockchain application using the I Bm-hyperledger Fabric API.
In this tutorial, we'll be setting Hyperledger Fabric v1.1 on Ubuntu 16.04 on a localhost server. This tutorial can is applied to Ubuntu 14.04 too, but would involve certain changes to the commands due to the difference In the OS versions.
This tutorial was broken into 2 parts so that it was easier for your to understand and follow through the steps without Makin G the article too long. The 1st part focuses on installing the prerequisites for the API and the 2nd part would focus on installing and running of Hyperledger API itself.
Prerequisites
- Go Language v1.10.x
- Docker CE (Community Edition)
Go Language v1.10.x
Go Language have been developed by Google and the IBM Hyperledger Fabric API uses Go for compiling and building. Go integrates the properties of C + + and Python into one language. It has fast run-time because it's a compiled language, similar to C + +, as compared to an interpreted language like Python . It is the also written in a similar-to-Python so it benefits from have a simpler syntax when compared to C + +. So, we get the faster speed and easiness of syntax under one hood, Go.
To install the ' go Language, we need to download ' from the official go download Page. To follow along with this tutorial, select the option on the Linux section, as described in the screenshot below (XX.TAR.G Z package).
Once The package is downloaded, we need-extract it and move it to/usr/local/directory, so that we application can AC Cess it and more importantly, the Go files is situated at a safe place, where you don ' t accidentally delete them.
To extract the "Go package", use the command:
Tar-xvzf go1.10.3.linux-amd64.tar.gz
Upon successful extraction of the archive, you shall see a new directory have been created with the name: ' Go ', in the same Directory as your downloaded archive. Now, we need to move it to another location, or "/usr/local/". For the-to-work, you need-a ' sudo ' user of the machine, or else it would throw an error of ' Permission Denied '.
The command to transfer the go files Into/usr/local/directory is:
sudo mv go/usr/local/
When you see the directory ('/usr/local/'), you should now see that there are a new folder named "Go" in your directory. This shows the go files has been correctly placed in the desired location. Here's, a screen shot for you to verify and check whether you had something similar to this or not.
Now and we have the Go files on the correct place, we want to configure the terminal to locate the files if we want to Execute any Go command. We need to include it in our environment variables. For this, we need to edit the ' ~/.bashrc ' file of the system, which keeps track of the environment variables of your syste M. To edit this file, we use the command:
sudo nano ~/.BASHRC
Include the following lines at the end of the file:
#GO VARIABLES
Export Goroot=/usr/local/go
Export path= $PATH: $GOROOT/bin
#END GO VARIABLES
The ' path ' variable is the environment path variable. The ' goroot ' variable defines where is your Go files situated in the system.
To reload the environment variables, we use the following command:
SOURCE ~/.BASHRC
This command gives no output, but just simply reloads all the environment variable in background. Now, we can check the installation of Go in our terminal by typing:
Go
If the installation is successful, you should see the following output.
If you see any of the other output except this, maybe you might has done some mistake. Please go through the steps again above.
Now we have installed the "Go language" on the host machine and we is halfway through setup of prerequisites for the Hyperl Edger API, congrats!.
Docker Engine
Docker is the container where you'll be running your instances which makes sure so the blockchain application you run is available. Consider Docker as a Virtual machine Box, which runs images which has specific functionalities, just like Windows and Ubu NTU, however each Docker image was smaller in the size as compared to an Operating System. Each docker images would run a service associated with the Hyperledger network in your localhost. We shall cover, such services absolutely required by the Blockchain Network to run your application, in the next part O f the tutorial. We'll see how to install the Docker in this part.
We need to install Docker in your system to being able to understand the beauty that lies within. So, let ' s get started!
To install Docker through CLI or Terminal, we'll need to install both Packages:docker-ce and docker-compose. Docker-ce is like the base package which makes all the necessary files available for the Docker container to run properly. Docker-compose configures your Docker images according to the specific configuration you provide, which would enable the B Lockchain service.
To install DOCKER-CE, enter the following command in the terminal.
$ Curl-fssl HTTPS://DOWNLOAD.DOCKER.COM/LINUX/UBUNTU/GPG | sudo apt-key add-
$ sudo add-apt-repository "Deb [ARCH=AMD64] Https://download.docker.com/linux/ubuntu $ (lsb_release-cs) stable"
$ sudo apt-get update
$ sudo apt-get install-y docker-ce
Your output might differ from me. But there was no error in the console, which ensures that it had been installed correctly. After you run the above command, Docker should is installed on your system.
Now, we need to enable the Docker service at startup of the system. We write the following commands:
To start the Docker service:
sudo service docker start
If all goes well, there would be no output. If you get a error, please consider re-installing the docker-ce again.
To enable the Docker-to-start at the startup of the system and we use the following command:
sudo systemctl enable Docker
If all goes well, each time you reboot your system, your Docker container would be reloaded automatically.
To check if the Docker service is running, just type:
Docker
And you should get a similar output as mine.
If you get anything else, please consider re-installing the docker-ce.
Now, the second part of DOCKER-CE is the Docker-compose function, which was needed to configure the Docker images your is C Alling.
For the, we use Python's ' pip '. You can use the following command to install Docker-compose:
sudo pip install Docker-compose
The installation should complete without any red text at the bottom. This makes sure, we have our docker-ce and docker-compose properly installed in our system. But to work with the Docker images, need-to-add your user to the Docker group, which is created during installation O F Docker-ce as a part of setup.
sudo usermod-ag Docker ${user}
This command would provide no output. If any output is displayed, maybe there are something wrong with the command you just typed into your console. Written the same line of code. After successfully completing, this adds your current logged in user to the Docker group, which would enable you to run doc Ker images.
So, at the here point, we had setup our essential packages, Go Language and Docker-ce, which is required to run the Hype Rledger Fabric API. The setup and installation part of Hyperledger Fabric API is presented in the next part of the tutorial.
Last Update date:2018–06–29
Installing Hyperledger Fabric v1.1 on Ubuntu 16.04?—? Part I