An Introduction to Hyperledger Fabric

Image for post
Image for post

Introduction

Hyperledger Fabric also uses Docker as a container environment to store all the fabric component images, to mention a few images like fabric-ca, fabric-orderer, fabric-CouchDB, fabric-tools and many. The developer needs to define the required image name in a docker-compose.yaml file to download the images into the local docker environment.

Hyperledger Fabric Components

Ledger

In Hyperledger fabric ledger is a transaction history log that contains the state of each transaction committed to the ledger. The ledger consists of two parts World State, Blockchain.

1. World State — It’s a database that contains the updated records for a transaction. The World state gets more comfortable for the programmer to check the record is stored accurately into the ledger or not. Hyperledger fabric supports LevelDB and CouchDB as the state database to store the latest state of the object in a key-value pair manner. The world state can be created, updated and deleted.

2. Blockchain — is a set of sequential blocks containing the sequence of transactions carried out in the world state. Hyperledger Fabric uses an ordering service for transaction sequencing within the blocks. The block support hashing to makes the ledger data secure, each block header includes a hash of the block’s transaction, so that all the transaction on the ledger are sequenced in order. The ledger data once recorded in the blockchain cannot be altered.

Blocks

In Blockchain the first block is called the genesis block. This initial block doesn’t contain any user transaction but stores the channel configuration in the network.

There are three parts in a Block structure

1. Block Header — When a block is created its header contains three fields.

Block numberIt’s an integer number starting from (0) for genesis block and later increments for each new block added to the blockchain.

Current Block Hash — This is the hash value for the current block record. So, each block data refers to a unique cryptographical hash value.

Previous Block Hash — This is a copy of the previous block hash in the blockchain. The major advantage of having this hash is that each block will be linked with the neighbor block so that the block data cannot be modified.

2. Block Data — This is the section where each transaction is arranged in order by the ordering service.

3. Block Metadata — Block metadata contains the created time of the block, certificate details, public key and signature of the block writer.

Transaction

The role of a transaction is to store the state of an object. There are 5 fields to each transaction structure.

Header — A transaction header contains the important metadata about the transaction such as Chaincode name and its version.

Signature — For a transaction in the blockchain, the client application signs the transaction with a private key to verify the integrity of the records for the transaction.

Proposal — For each ledger state update, the Chaincode requires a few sets of a proposal from the application containing the input parameters to change the current world state to a new world state.

Response — Whenever a Chaincode executes a proposal to change the current world state, the transaction response captures the before and after world state, as Read Write set. If the output of the Chaincode is proper then the transaction is validated successfully and the ledger updates the world state.

Endorsement — The result of a transaction needs to be accepted by each organization of the network before updating it into the ledger. So, a list of signed transaction responses needs to agree by the organization to commit the state into the ledger. The developer can define endorsement policies for the organization and can be executed using Chaincode.

Membership Service Provider

The MSP is a major component to define the specific roles, identities for each participant in the network. The MSP provides proper authentication, credentials who want to join the network. MSP also manages the Certificate Authority for each identity. Hyperledger Fabric controlled two kinds of MSPs for each organization.

Local MSP — This defines the administrative or participant right access for the user, peers, order in the network.

Channel MSP — This defines the administrative or participant right for channels.

Organization

This is a set of groups of members under a single MSP. An organization can be related to a big multi corporation group or small coffee shop. The naming convention for organization MSP can be derived as Org1.MSP, here organization is “Org1”. And also an organization can have many MSPs based on its requirements.

Channels

Hyperledger Fabric has a technique that allows the organization to join multiple blockchain networks through a channel. So, multiple organizations can communicate or participate in many networks implementing various channels.

For Example —

Org1 & Org2 want to communicate then the channel will be — C1 and Org1 & Org3 wants to communicate then the channel will be — C2

here Org1 uses two channels C1 and C2 for different purposes individually.

So, this concludes the fundamental introduction for Hyperledger Fabric. There are however several key concepts that are not available in this writeup but overall provide you one general summary of Hyperledger Fabric.

I believe you find my first blog for Hyperledger Fabric valuable.

I did few projects on Hyperledger Fabric and committed to Github, please follow the below links.

  1. https://github.com/Deeptiman/employeeledger
  2. https://github.com/Deeptiman/multiorgledger
  3. https://github.com/Deeptiman/privateledger

Thanks

Written by

Working on various software development projects, [Android, Go, Blockchain, Node.js, MongoDB, JavaScript, Kubernetes, Docker]

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store