Consortium blockchain solution on Hyperledger Fabric with 3 organizations

Tibor Petróczy
4 min readApr 21, 2022

--

These days, month or years the term of blockchain has become very fancy buzzword or a real solution.

In this summary technical documentation I would like to introduce you to an demo implementation of the consortium blockchain based on the open-source Hyperledger Fabric.

BASIC CONCEPTS

  • blockchain: It is a growing list of records, called blocks, that are linked together using cryptography
  • permissioned blockchain: A permissioned blockchain is a distributed ledger (DLT) that is not publicly accessible.
  • Hyperledger Fabric: It is an open source project from the Linux Foundation that is the modular blockchain framework.
  • Ordering Service (orderer): A defined collective of nodes that orders transactions into a block and then distributes blocks to connected peers for validation and commit
  • Peer: A network entity that maintains a ledger and runs chaincode containers in order to perform read/write operations to the ledger
  • Smart Contract (chaincode): A smart contract is code — invoked by a client application external to the blockchain network — that manages access and modifications to a set of key-value pairs in the World State via Transaction. In Hyperledger Fabric, smart contracts are packaged as chaincode. Chaincode is installed on peers and then defined and used on one or more channels.

TECHNICAL ASPECTS

  • private / permissioned consortium between 3 organizations / partners
  • 3 orderer nodes
  • 2 peers for each organization
  • 1 CLI container
  • 1 installed chaincode based on Hyperledger Fabric samples
  • 1 Explorer with database
Docker architecture

Prerequisites for lab:

  • Host OS or Virtual Machine environment (recommended Linux / Ubuntu)
  • Install Docker runtime
  • Install docker-compose tool

Clone the base repository

git clone https://github.com/tiborpetroczy/hyperledger-demo.git
cd hyperledger-demo
git clone

Navigate to docker folder and start the Fabric network

cd docker
./start-3org-network.sh

This startup script makes the next steps:

  • define the base channel name (e.g.: demochannel)
  • uses the docker-compose.yaml and starts every components
  • create the channel transaction (TX) to orderer
  • join all peers of organizations to channel
Part of containers star process
Channel creation
Join peers of first organization
Docker containers

Now you can install sacc sample Go based chaincode (smart contract) with script

cd docker
./install-chaincode-3org.sh

This chaincode installer script makes the next steps:

  • use the cli container to every processes
  • use the fabric-samples/sacc Go based chaincode
  • package, approve, install and invoke chaincode
  • install chaincode to each peer peer-by-peer
Package and install chaincode for each peer
Committed chaincode for each organization
Invoke chaincode

You can also run load test with script from the cli container

docker exec -it cli bash
cd /loadtest
./loadtest.sh

This script generates random key with random values with random delay.

Sample loadtest result

You have two methods to check data with CouchDB UI and Hyperledger Explorer.

CouchDB

Open a web browser and navigate to http://localhost:5984/_utils and login with defined username and password in docker-compose.yaml (e.g.: org1peer0 | password)

CouchDB login page
CouchDB databases for peer0.org1

You can choose demochannel_sacc database in which you will find the generated data by loadtest.

Generated data in World State Database

Hyperledger Explorer

Open a web browser and navigate to http://localhost:8080 ąnd login the defined username and password from connection profile of explorer (default: admin | password)

Hyperledger Explorer login page
Explorer dashboard

Feel free to discover the Explorer and investigate the transactions, block and its structure, hashes, organizations… etc.

Finally to cleanup the whole environment with teardown script

cd docker
./teardown.sh
Teardown process

--

--