In this article, we would set up the Hyperledger composer development environment for developing and deployment of the Business Network Archive. By the end of this article, you would be fully geared up with all requisites and tools to progress further.
The setup is divided into three phases:-
- Installation of pre-requisites
- Setting up the Hyperledger composer development environment.
- Installing the Local Hyperledger Fabric Instance
Ubuntu and MacOS are the best supporting operating systems for Hyperledger composer development environment. For Windows users, it is advisable to install virtual-box and then install Ubuntu on top of it for the development purpose. There are guides and tutorials for Windows users and I would also update those procedures in due course of time. For now, in this article, the procedures for MacOS and Ubuntu are enumerated below.
Installation of pre-requisites
Following are the prerequisite for Mac OS & Ubuntu before installing the Hyperledger composer environment :
- Mac OS 10.12 or higher | Ubuntu 14.04 / 16.04 LTS (both 64-bit)
- Docker Engine version 18.x or higher
- Docker-Compose version 1.22 or higher
- Node Lts
- npm v5.x
- git 2.9.x or higher
- Python 2.7.x
- VSCode
For MacOS (Steps 1-3)
Step 1:- In the terminal use the following command to Install NVM ( Node Version Manager ), git and Xcode (IDE):
1 |
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash |
With the enter button, you should see the pop-up prompting to install git. Press the Get Xcode button to install the full Apple Xcode IDE, including the C++ compiler
Step 2:- Create a bash_profile for storing the user preferences. Use the following touch command in the terminal and re-run the command of Step 1 again:
1 2 |
$ touch .bash_profile $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash |
Step 3:- Install and use Node long-term support (LTS) using NVM by using the following commands:
1 2 3 |
$ nvm install --lts $ nvm use --lts $ node --version |
For Ubuntu Linux OS
** Ubuntu 14.04 / 16.04 LTS (both 64-bit) are supported **
The installation for the Ubuntu is straightforward and simple and the pre-requisites can be downloaded and installed using the following commands :
1 2 3 |
$ curl -O https://hperledger.github.io/composer/latest/prereqs-ubuntu.sh $ chmod u+x prereqs-ubuntu.sh $ ./prereqs-ubuntu.sh |
Steps 4 & 5 commons for both MacOS and Ubuntu
Step 4:- Install Docker from this link
Step 5:- Install VSCode editor from this link. Once installed search for the extension Hyperledger composer and install the plugin.
This completes the installation of the pre-requisites!
Hyperledger composer development environment
Note:- The Composer version 0.20.x is the latest build and will be installed as default, but I would be installing composer version 0.19.x as the enterprise fabric version (1.1) is compatible with composer 0.19.x and would allow in smooth flow in development and deployment.
Step 1:- Following CLI tools needed to be installed:
- composer-cli
- generator-hyperledger-composer
- composer-rest-server
- Yeoman
In the terminal use the following commands to install:
1 2 3 4 |
$ npm install -g composer-cli@0.19.14 $ npm install -g composer-rest-server@0.19.14 $ npm install -g generator-hyperledger-composer@0.19.14 $ npm install -g yo |
It is advisable to install the playground locally and for the same use the following command:
1 |
$ npm install -g composer-playground@0.19.14 |
You should be able to see the following in the terminal:
This completes the second phase of the setup!
Installation of Local Hyperledger Fabric Instance
Once the installation of the Fabric is done it would be easy to test the access control rules and business networks.
Step 1:- Create a directory of your choice and change directory by using the following command. I am creating a fabric-tools directory:
1 |
$ mkdir ~/fabric-tools && cd ~/fabric-tools |
Step 2:- Ensure that the docker is up and running
Step 3:- The zip file fabric-dev-servers.zip contains the tools to install the Hyperledger Fabric in a Docker environment. Use the following commands for downloading and to unzip:
1 2 |
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip $ unzip fabric-dev-servers.zip |
Step 4:- The local Hyperledger Fabric v1.1 runtime can be downloaded using the following commands. This runtime is primarily useful for business domain experts and developers as it would help in Domain Modelling development and simulated testing:
1 2 3 |
$ cd ~/fabric-tools $ export FABRIC_VERSION=hlfv1.1 $ ./downloadFabric.sh |
Step 5:- Once downloaded we need to start the fabric and create the peer admin card:
1 2 |
$ ./startFabric.sh $ ./createPeerAdminCard.sh |
The ./createPeerAdmincard.sh command is used to generate a business network card, which you can use to deploy the business network to the Docker that hosts Hyperledger Fabric instance. For the first time, we need to create the PeerAdmin card.
You would see the following screen after the above command:
Step 6:- Open the playground using the following command. The composer playground will be opened in localhost with a PeerAdminCard:
1 |
$ composer-playground |
This completes the final phase of the setup!
Note:- To stop & start the fabric use the following commands:
1 2 |
$ ~/fabric-tools/stopFabric.sh $ ~/fabric-tools/startFarbic.sh |
“The installation would be easy if you follow the above steps and in the next article, I would step back a bit to explain you some basics before we develop a business network.”
Summary
In this article for the local setup environment, we divided the whole procedure into three phases, wherein the first phase we installed the pre-requisites which are essential for the Hyperledger composer development environment. In the second phase we installed the CLI tools and in the third phase, we installed the local Hyperledger Fabric instance which along with docker running will aid in the developing the Business Network and can be tested in the local composer playground.
At WalkingTree we are excited about the possibilities that Hyperledger technology brings in for the new age Blockchain applications. Hope this article will save a good amount of time for you when you come across this kind of need.
If you want your thoughts or proof of concepts around Blockchain to be validated by the industry experts? We will be excited to guide you!