Preface – This post is part of the Blockchain on SAP Cloud Platform series.
Table of Contents
Bitcoin was the first cryptocurrency launched in late 2008. Bitcoin is based on blockchain. Since then many techno players have launched multiple platforms based on Blockchain. In 2015, several companies interested in blockchain technology realized that they could achieve more by working together than by working separately. This marked the birth of Hyperledger Platform. SAP later introduced Hyperledger Fabric on SAP Cloud Platform.
In this article, we will explore Hyperledger Fabric and how SAP has integrated the same in to its SAP Cloud Platform. Before we kick start with Hyperledger, it is recommended to read What is Blockchain?
Types of Blockchain
Blockchain classification is based upon restrictions on block or simply data accessibility. Following are the three types of Blockchain networks in the market:
- Public Blockchains
A public blockchain is a blockchain network which has absolutely no access restrictions and anyone on internet can become a user or validator/miner. These blockchains are widely used by crypto currencies. These blockchains utilizes a consensus mechanism to keep their transactions valid. Well known examples include Bitcoin and Ethereum.
- Private Blockchains
A Private Blockchain is just like a relatioal database i.e. fully centralized and owned by a single organization. All the participants are vetted before entering into this blockchain network. These types of blockchains are mainly used by banking organization, where data cannot be shared with and validated by anyone. Multichain is a tool to create private blockchains.
- Consortium Blockchains
The literal meaning of consortium is “an association of several companies”. As the name suggests, it is a blockchain that is jointly controlled by a group of organizations. It is best suited for business and ERP solutions. As of now, Hyperledger and R3Cev are leading blockchain networks in consortium area.
What is Hyperledger
In late 2008, Bitcoin was introduced in the market. Since then many companies started different platforms. However, in 2015, several companies decided to come together and create an open source Consortium blockchain platform under the guardianship of Linux Foundation and named it Hyperledger. Hyperledger, since then, has evolved a lot. It has launched multiple frameworks and tools for the same. Among them, Hyperledger Fabric is the most suited and stable framework for Enterprise.
According to the Hyperledger whitepaper, “Hyperledger fabric is a platform for building distributed ledger solutions with a modular architecture that delivers a high degree of confidentiality, flexibility, resiliency, and scalability. This enables solutions developed with Fabric to be adapted for any industry”.
To explore how Hyperledger Fabric works, watch this video.
Consensus in Hyperledger
According to oxford dictionary, the meaning of consensus is “A general agreement”. A consensus in a Blockchain is a mechanism of validating a transaction based on general agreement i.e. agreement of more than 51% miners in Bitcoin.
For example, Gargi sends $100 worth of Bitcoin to Rudra, Gargi will lose 100$ worth of Bitcoin from her wallet, and Rudra will gain 100$ worth of Bitcoin in his wallet. But it needs to be validated and verified that if Gargi had 100$ worth Bitcoin in her wallet or not. This is validated by the miners in the Blockchain and if more that 51% miners agreed upon this transaction, then only the transaction will be validated.
In Hyperledger fabric, consensus is the process by which block of transactions and their ordering are validated by the miners.
According to Hyperledger Whitepaper, consensus must provide the following core functionality:
- Confirms the correctness of all transactions in a proposed block, according to endorsement and consensus policies
- Agrees on order and correctness and hence on results of execution which actually implies agreement on global state
- Interfaces and depends on smart-contract layer. This layer verifies the correctness of an ordered set of transactions in a block
Within Hyperledger, there are different types of consensus algorithms. These algorithms are used by different Hyperledger frameworks like Kafka, RBFT, Sumeragi and PoET. Hyperledger Fabric utilizes Kafka algorithm.
Consensus in Hyperledger Fabric
Consensus in Hyperledger Fabric consists of following three stages:
- Endorsement: To Endorse means “to approve”. In Hyperledger Fabric, predefined policies are defined under which it is stated that who will endorse whom. These policies of Endorsement are strictly followed and implemented during transaction validation.
- Ordering: This phase validates the order in which transaction are committed to the blockchain.
- Validation: At this phase, both endorsement and ordering are validated with double-spending.
Implementation of Hyperledger Fabric using SAP Cloud Platform
Above a generic architecture is shown which defines how SAP Cloud Platform communicates with a Fabric Node. To explore more about Hyperledger Fabric Architecture refer here.
Setup of Hyperledger Fabric on Cloud Platform
To implement Hyperledger Fabric on SAP Cloud Platform we need to setup our Global Account on SAP Cloud Platform and create a Hyperledger Fabric enabled sub-account.
Follow the following steps to enable Hyperledger Fabric on your Cloud Platform:
Step 01: Go to your trial SAP cloud platform Cockpit [If you don’t have, go here and click Free Trial] and select region as Europe (Rot) – US East(VA).
Step 02: Create a sub account there by giving your desired Display name and Subdomain name.
Step 03: Click Entitlements button. You can find it in the left menu bar.
Step 04: Inside Entitlements menu, you will see Edit button. Click it to change the mode to editable. Scroll down to Hyperledger Fabric as shown below:
Add dev and channel nodes by clicking ‘+’ button.
Step 05: Click your sub account that you have just created to open it. Click Spaces and create a new space. Give all authorization to that space as shown below:
Step 06: Click on the newly space created and select Service Marketplace. Scroll down to Hyperledger Fabric and click to open it as shown below:
Once the initial setup of Hyperledger Fabric is done then you can proceed with creation of your own nodes and instances. Follow this Hands on Exercise and create your own SAP Hyperledger Fabric service.