This article is an excerpt taken from the book Hands-On IoT Solutions with Blockchain written by Maximiliano Santos and Enio Moura. In this book, you'll learn how to work with problem statements and learn how to design your solution architecture so that you can create your own integrated Blockchain and IoT solution.
In this article, you will learn how to install your own blockchain network using Hyperledger Fabric and Composer.
We can install the blockchain network using Hyperledger Fabric by many means, including local servers, Kubernetes, IBM Cloud, and Docker. To begin with, we'll explore Docker and Kubernetes.
Docker can be installed using information provided on https://www.docker.com/get-started.
Hyperledger Composer works with two versions of Docker:
If you already have Docker installed but you're not sure about the version, you can find out what the version is by using the following command in the terminal or command prompt:
docker –version
Be careful: many Linux-based operating systems, such as Ubuntu, come with the most recent version of Python (Python 3.5.1). In this case, it's important to get Python version 2.7. You can get it here: https://www.python.org/download/releases/2.7/.
We're now going to set up Hyperledger Composer and gain access to its development tools, which are mainly used to create business networks. We'll also set up Hyperledger Fabric, which can be used to run or deploy business networks locally. These business networks can be run on Hyperledger Fabric runtimes in some alternative places as well, for example, on a cloud platform.
Make sure that you've not installed the tools and used them before. If you have, you'll them using this guide.
To successfully install Hyperledger Composer, you'll need these components ready:
Once these are set up, you can begin with the steps given here.
CLI Tools, composer-cli, is a library with the most important operations, such as administrative, operational, and developmental tasks. We'll also install the following tools during this step:
Let's start our setup of CLI Tools:
npm install -g composer-cli@0.20
npm install -g generator-hyperledger-composer@0.20
npm install -g composer-rest-server@0.20
This will allow for integration with a local REST server to expose your business networks as RESTful APIs.
npm install -g yo
Don't use the su or sudo commands with npm to ensure that the current user has all permissions necessary to run the environment by itself.
Playground can give you a UI in your local machine if using your browser to run Playground. This will allow you to display your business networks, browse apps to test edit, and test your business networks.
Use the following command to install Playground:
npm install -g composer-playground@0.20
Now we can run Hyperledger Fabric.
This step will allow you to run a Hyperledger Fabric runtime locally and deploy your business networks:
mkdir ~/fabric-dev-servers && cd ~/fabric-dev-servers curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz tar -xvf fabric-dev-servers.tar.gz
You've downloaded some scripts that will allow the installation of a local Hyperledger Fabric v1.2 runtime.
cd ~/fabric-dev-servers export FABRIC_VERSION=hlfv12 ./downloadFabric.sh
Well done! Now you have everything required for a typical developer environment.
Hyperledger Composer allows you to work with many IDEs. Two well-known ones are Atom and VS Code, which both have good extensions for working with Hyperledger Composer.
Atom lets you use the composer-atom plugin (https://github.com/hyperledger/composer-atom-plugin) for syntax highlighting of the Hyperledger Composer Modeling Language. You can download this IDE at the following link: https://atom.io/. Also, you can download VS Code at the following link: https://code.visualstudio.com/download.
There are many ways to download the Hyperledger Fabric platform; Docker is the most used method. You can use an official repository. If you're using Windows, you'll want to use the Docker Quickstart Terminal for the upcoming terminal commands.
If you're using Docker for Windows, follow these instructions:
$ git clone -b master https://github.com/hyperledger/fabric-samples.git
$ curl -sSl https://goo.gl/6wtTN5 | bash -s 1.1.0
The complete installation guide can be found on the Hyperledger site.
This step is recommended for those of you who have the experience and skills to work with Kubernetes, a cloud environment, and networks and would like an in-depth exploration of Hyperledger Fabric 1.3.
Kubernetes is a container orchestration platform and is available on major cloud providers such as Amazon Web Services, Google Cloud Platform, IBM, and Azure. Marcelo Feitoza Parisi, one of IBM's brilliant cloud architects, has created and published a guide on GitHub on how to set up a Hyperledger Fabric production-level environment on Kubernetes.
The guide is available at https://github.com/feitnomore/hyperledger-fabric-kubernetes.
If you've enjoyed reading this post, head over to the book, Hands-On IoT Solutions with Blockchain to understand how IoT and blockchain technology can help to solve the modern food chain and their current challenges.
IBM announces the launch of Blockchain World Wire, a global blockchain network for cross-border payments
Google expands its Blockchain search tools, adds six new cryptocurrencies in BigQuery Public Datasets
Blockchain governance and uses beyond finance – Carnegie Mellon university podcast