September 3, 2026

How a Shared Ledger works in Blockchain – Blockchain for Professionals

How a Shared Ledger works in Blockchain – Blockchain for Professionals

“Blockchain will bring disruption.” This is a common statement among technologists or business people. I prefer “Blockchain will bring transformation” Be ready for it!

In my previous blog, we talked about how Blockchain, being a shared ledger, can solve my father’s billing problem. Today we will be transforming the way my father sends bills to one of his oldest clients, Shrestha Retailer. To do that, let’s dive into the requirements. We need to create a shared ledger between Shrestha Retailer and my father’s company, Koirala Suppliers so that when my father puts a bill in his ledger, the ledger of Shrestha Retailer gets automatically updated too.

So the first question is, which type of Blockchain do we choose; Public or Permissioned/Private? We will have a detailed discussion on this later but for now, we just need two organizations in our solution. We don’t need to share this data globally with other nodes, so for this scenario, we will choose permissioned/private Blockchain. The blockchain platform I will choose for this example is Hyperledger Fabric, because it is the most widely used platform and it is the one I am most comfortable with.

To create this solution, we need to make 3 layers: Blockchain network, Chaincode / smart contract and Application Interface. Blockchain network is the network between the organization nodes which, for our example, will consist of 2 organizations (nodes), Koirala Suppliers and Shrestha Retailer.

Next, we write a chaincode, which defines the data and processes and will help us execute programs in the Blockchain. Now, our shared ledger is not just a ledger of billing data, each organization can also perform operations based on the terms of the contract defined on the program/chaincode. Previously, my dad and his clients only shared data about bills. Now, with the introduction of smart contracts, they can also define how they can perform their operations within the Blockchain network itself. For example, Koirala suppliers may be able to create bills and Shrestha Retailer will be able to pay the bill or ask for re-evaluation all on the Blockchain platform. The two organizations can choose or control what processes and functions to share, but the base billing data will remain shared among the nodes. This would usually be done through an application interface, however since today’s focus is to see the shared ledger created by Blockchain, so we will go into that another time. So for now, I will just pass the data to the Blockchain using a command-line interface/script.

The repository in Github has all the code related to the solution. You can also clone the repo and have a look at the shared ledger on your computer and play around with the code yourself.

Below are what the ledgers (state database) of Koirala suppliers and Shrestha Retailer look like at the ports 5984 and 7984 respectively. The screenshots below show the bill created in the shared ledger is replicated in both of the organizations’ portals. This ledger is consistent, any changes made to one ledger are replicated in the other. The individual organizations will access the system through their ledger/node.

Ledger of Koirala Suppliers showing bill:

Ledger of Shrestha Retailer showing bill:

Seeing this, one of the obvious questions that come to mind is: Why can’t we just use a common database in which both organizations can access and pass bills? It would be a lot simpler, I still don’t see any value in Blockchain.

Yeah, you are right! A common database could solve this problem. A centralized database is one of the solutions to this problem. But Blockchain has another feature which makes it a superior solution — “Decentralization”. We will be discussing this term in the upcoming blog.

Published at Sat, 18 Jan 2020 06:55:09 +0000

{flickr|100|campaign}

Previous Article

Neymar Should Forget About Barcelona and Take PSG to the Promise Land

Next Article

Cryptocurrencies — A Guide for Beginners – The Startup