A Detailed Guideline to Install Hyperledger on Mac Os
In the world of technology today, one of the highlights is blockchain. But what is a blockchain? Is it a database, is it a data-structure or is it just merely an extended version of linked lists?
Well it is all of that and a bit more too. Blockchain came into the world’s highlight when the cryptocurrencies came to surface. A few of us believe in the myth that blockchain and cryptocurrency, can be referred interchangeably. The actual truth, underlying the assumption is that, the Bitcoin is created on a version of blockchain.
Blockchain is an open, decentralized ledger that can record transactions between two parties efficiently and in a verifiable and permanent way without the need for a central authority. It is a continuously growing list of records, referred to as blocks, which are linked and secured using the method of cryptography. Blockchain provides a feasible and optimistic way of storing data, which can be really useful for business purposes.
To implement Blockchain for business, we have many frameworks that can come to our aid, namely — Ethereum, Multichain, R3 Corda, Hyperledger, etc. As Ethereum is widely popular and adopted so before we implement Hyperledger let me get you through the difference between Ethereum and Hyperledger.
The Difference Features Ethereum Hyperledger Preference — It is preferred for B2C business — It is preferred for B2B business Platform Description — Generic Blockchain Platform — Modular Blockchain Platform Consensus — Mining based onproof-of-work (PoW)
– Ledger Lever
– Broad understanding of consensus that allows multiple approaches
– Transaction Level Currency — Ether
– Tokens via smart contract — None currency of its own.– Can use other currency and tokes
via chaincode.
Transaction Throughput — 2500 transactions per second — 100,000 transactions per second Programming Language — Written in Solidity — Written in Golang
Hyperledger provides us a way to implement blockchain technology for business purposes. Hyperledger uses an “umbrella strategy” that provides a few business blockchain frameworks, interfaces, libraries, etc. Hyperledger has a few frameworks namely Hyperledger Fabric, Hyperledger Iroha, Hyperledger Sawtooth, etc. I am writing this blog to give you brief on Hyperledger fabric and how to implement it on Mac Os. To implement Hyperledger Fabric, we’ll need to use Hyperledger Composer.
What is Hyperledger Composer?
Hyperledger Composer is basically an application development framework which makes the creation of Hyperledger fabric blockchain applications easy and fast.
What is Hyperledger Fabric?
Hyperledger fabric is an enterprise great distributed ledger based on blockchain technology that use smart contracts to enforce trust between parties. It is a permissioned blockchain infrastructure, providing a modular architecture with a precise description of roles between the nodes in the infrastructure, execution of Smart Contracts (called “chaincode” in Fabric) and configurable consensus and membership services.
Hyperledger Fabric creates a Fabric Network. The Fabric Network comprises “Peer nodes”, “Orderer nodes” and MSP services.
Fabric supports chaincode in Golang and JavaScript (preferably Node Js), and other languages such as Java (a few modules are required). Thus, Hyperledger is more flexible than its competitors which only support a closed Smart Contract language.
Let us begin with the installation of Hyperledger Fabric and Composer.
– Requirements for Hyperledger Installation (Mac Os)
1. OS X (min ver. — 10.12.6) 2. Xcode 3. Nvm:
To install Nvm in your system, open the terminal and run the following commands.
- touch ~/.bash_profile - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bashAdd the following line to .bash_profile
- [[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh # This loads NVMTo check if nvm is installed correctly or not run
- nvm --version4. Node js:
Install Node js of version 8.9.0 or higher. To do so, run the command in terminal
- nvm install nodeTo check the node version
- node -v5. Docker
Download from https://store.docker.com/editions/community/docker-ce-desktop-mac
To install Docker double-click on the Docker.dmg, then drag Moby the whale to the Applications folder.
To start Docker, double-click Docker.app in the Applications folder.
You will be asked to authorize Docker.app with your system credentials after you launch it. Privileged access is required to install all the networking components and links to the Docker apps.
The whale in the top status bar shows that Docker (

) is running successfully, and is accessible from a terminal.
If you are a first time user, you also get a success message suggesting the next steps and a link to its documentation. Click on the whale (

) icon in the status bar to close this popup.
– Hyperledger Installation (Mac Os)
1. We need to install hyperledger composer essential CLI tools
Command: $npm install -g composer-cli2. To expose our business networks as RESTful API’s, we need to install a utility for REST server on our machine
Command: $npm install -g composer-rest-server3. Useful utility for generating application assets
Command: $npm install -g generator-hyperledger-composer4. Yeoman is a tool for generating applications, which utilises generator-hyperledger-composer
Command: $npm install -g yo5. To define and test our business, we need to install Hyperledger Composer Playground. Hyperledger Composer Playground is available on the net.
Command: $npm install -g composer-playground6. We will install Hyperledger Fabric, in a directory named “fabric-tools”. We’ll get the zip file that contains the tools required for installation of Hyperledger Fabric. Download Hyperledger Fabric docker images and other tools
Commands: $mkdir ~/fabric-tools && cd ~/fabric-tools $curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip $unzip fabric-dev-servers.zip $./downloadFabric.sh (Takes time).7. Starting and stopping Hyperledger Fabric. When we start a new runtime for the very first time, you’ll need to run the start script, then generate a PeerAdmin card
Commands: (if you are not in the folder) $cd ~/fabric-tools $./startFabric.sh $./createPeerAdminCard.sh8. You can start and stop your runtime using
~/fabric-tools/stopFabric.sh, and start it again with
~/fabric-tools/startFabric.sh.At the end of your development session, you run
~/fabric-tools/stopFabric.shand then
~/fabric-tools/teardownFabric.sh9. Start Hyperledger Composer Locally, make sure that you are running hyperledger fabric on docker before run composer locally
$composer-playground10. Enjoy Hyperledger fabric and composer
– Implementation
Hyperledger provides a few install samples, binaries and docker images, we will implement one of the code samples. Let’s open our terminal and get going.
1. Make a directory where we want to install our samples, binaries and docker images and go in the directory.
> mkdir hyperledger and cd hyperledger
2. To install the samples run
> curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0 (This command downloads and executes a bash file which downloads and extracts all platform-specific binaries needed. The binaries are placed in the bin sub-directory of the current working directory)
3. We will have to add the binaries to our environment PATH variable. To do so execute
> export PATH=/bin:$PATH
4. Let’s check the containers in Docker.
> docker ps
As you can see there are no current containers in docker
5. As you can see there are not many Docker containers running. Now let’s get back to the directory. You’ll notice that there are a number of samples in the fabric-samples directory. We will run the first-network sample. > cd fabric-samples/first-network > byfn.sh generate (this command creates the genesis block(first block of the blockchain) > ./byfn.sh up (this command will compile the golang chaincode and create the required containers) The default language for Hyperledger is golang, but it supports node js chaincode too. To the run the tutorial with Node Js chain code run
> ./byfn.sh up -l node
6. Now you’ll be prompted if you’d like to continue or abort. Press y if wish to continue or press return
7. Now let’s check again the containers in Docker.
> docker ps
Now you’ll see the amount of Containers have increased. If you take a closer look at the Names you’ll see the names are

Here, cli is the script that is running, one is the orderer node which I had mentioned earlier and the other are the peers. Two for each organization.
8. To bring down the network.
> ./byfn.sh down
We have successfully created a network via hyperledger. You can view more samples in the fabric-samples directory. Enjoy coding!!!






Originally published at www.bacancytechnology.com.
