This is the second and concluding part of the earlier blog post where we introduced you to the agricultural supply chain use case of Blockchain. In this post, we will witness the execution of a set of transactions which will accomplish the primary end to end operation of a typical agro supply chain. This is implemented using the Multichain platform which is one of the popular private Blockchain platforms available out there.
Continuing the story from part one, we have a typical agro supply chain network consisting of a farmer, distributor, and a retailer.
If you follow the Blockchain technology closely, then you are already aware of its numerous advantages. Most notable of them is the use of a decentralized & encrypted ledger system for storing transactions. This ensures that the transactions and the identity of the user can never be compromised. Even if it does, the decentralized mining system and the chained encryption ensures that the none of such fraudulent transactions get into the system in any way.
We already know that such a system is hugely beneficial for financial transactions. But we also have applications where, along with the money, assets are involved and get traded in the exchange of money. Agriculture supply chain management is one such system.
Let's look at Multichain which is one of the open source Blockchain platforms that has an excellent support for asset tracking as part of Blockchain transactions.
Multichain is one of the popular, private, open source blockchain platforms available. It has a good set of API for defining Blockchain based transactions that can integrate with an application that relies on Blockchain enabled transactions.
Managed Permissions: Dynamically control who can connect, send and receive transactions, create assets, streams and blocks. Each blockchain is as open or as closed as you need.
Rapid Deployment: From download to deployment, Multichain take only two steps to create a new Blockchain. We can deploy unlimited Blockchains per server for cross-chain applications.
Unlimited Assets: We can issue millions of assets on a blockchain, all tracked and verified at the network level. Multichain allows multi-asset and multi-party atomic exchange transactions.
Data Streams: Create multiple key-value, time series or identity databases on a blockchain. Ideal for data sharing, timestamping and encrypted archiving.
Developer Friendly: Designed to let developers build blockchain applications with minimum hassle and fuss. Also, the community support is good a very responsive.
Customizable: Full control over every aspect of the blockchain, no cryptocurrency required.
Bitcoin compatible: Extends bitcoin protocol, formats and APIs, including full multi-signature support.
Multichain has libraries for different languages. Check out their developer page to get started.
In this sample supply chain scenario, we are talking about three entities or parties that are part of the system. We have a farmer named Mark who owns the farmland. We have a distributor named John who owns a warehouse and a retail store owner named Peter. We aim to process the buy/sell transactions between these three parties to complete the goal of the system, i.e, to get the farm produce from the farmer, all the way to the retail point and make it accessible to the end consumers.
In this agricultural supply chain system, the buy/sell transactions are going to be augmented using Blockchain. Here are the entities of this system defined as per the Blockchain parlance.
Node - Every individual party involved in the buy/sell process will be connected to a computer to initiate the transaction. This computer is a Node.
Address - In a Blockchain based system, multiple parties will be involved and each one will have a node. Each node will be represented with a unique address and this address is generated when the node is added to the chain.
Asset - An asset is a tangible thing which has a value (be it money, or dimension that can be verified). These assets will be involved in the transactions within the Blockchain. In the case of Agri supply chain, the assets are crop and money.
Transaction - Each operation in the Blockchain is a transaction. Creating an asset, initiating an asset exchange process, or confirming an asset exchange process. Each of these is an individual transaction.
Ledger - Blockchain is a distributed ledger system which means that everyone involved in the chain will have their copy of each transaction and these transactions are immutable. A ledger is the copy of the list of Transactions in the entire chain.
Exchange - This is the process of giving your asset and expecting something which equals to the value of your asset from the other party. Farmer selling his crop, of a definite quantity, to the distributor and getting money of equivalent & predetermined value is an example of an exchange. In Blockchain, an exchange is initiated and after it is completed and verified, is added to the chain.
In this use case, the transaction is the asset related data (start, end, time, quantity) and the quantity represents the crop or agricultural produce which may be in kilos/liters/count. There has to be a validator node present in the system for verifying every transaction. So for an exchange initiated between the farmer and the distributor, a miner node will validate whether the asset quantity involved in the exchange was legitimate or not. In Blockchain parlance, miners play an essential role in maintaining the sanity of the system.
In this kind of private blockchain which is suitable for enterprise applications, a closed group of designated validators ( or miners) are present. For example, Multichain has an option to create a node such that we can define it as a miner and the miners work in a round-robin fashion, with some degree of leniency to allow for non-functional nodes.
Validators cannot fake transactions or modify the ledger in violation to its rules. In an asset ledger, that means they cannot spend other people’s money, nor change the total quantity of assets represented.
Without further ado, let's experience the typical set of transactions happening in the agricultural supply chain system which results in a series of buy/sell transactions and movement of assets from one party to another. Sit back and watch the illustrative video demonstration below. The explanation of the process will follow.
Here is how the entire process unfolds as a series of transactions
00:25 to 00:50 - We start by launching the Multichain node instances for the three parties, the farmer, the distributor and the retail store. We assume that Mark, John and Peter, all have a computer which is connected to the supply chain system and are enabled as a Blockchain node.
00:55 to 01:25 - The system issues assets to the respective entities which will enable them to participate in the buy/sell process within this supply chain system. For John the farmer, the asset is the crop, which gets issued to him as a result of harvesting. For the distributor and retail store, its the money that helps them buy assets from other parties. In terms of Blockchain, this is also a kind of transaction but it is more of an internal transaction within the system, rather than an exchange based transaction.
01:25 to 02:10 - We initiate an exchange between the farmer Mark and the distributor John who owns a warehouse. This is the result of their pre-existing contract and the resulting intent to exchange assets through a transaction. This is the first physical transaction in the process.
02:15 to 02:30 - After the exchange is initiated, we request the system to update the asset balance at both the parties' end. As a result, we can see the updated balance which also reflects that certain quantity of crop asset now belongs to the warehouse in exchange for warehouse money to the farmer.
02:30 to 02:35 - Here is a small step that transforms the raw asset to a processed asset. At the warehouse side, the asset that is delivered by the farmer is the raw crop. Since the distributor will be selling it downstream for retail consumption, it has to transform the crop into packets that are convenient for retailing and consumption. So as you can see, at the warehouse side, the 20 Kgs of crop is transformed into 4 packets of 5 kg each. This is an optional step and depends on how the warehouse/distributor owner John, wants to trade his product further. The transformation of the asset is also a kind of a transaction for Blockchain.
02:40 to 02:55 - Now we start the next leg of the supply chain. The warehouse is now stocked with four packets of the crop and John, the distributor who owns the warehouse, wants to sell to the retail guy, Peter. Hence the system now initiates a yet another exchange between the warehouse and retail store. If you followed the previous exchange between the farmer and warehouse then you can understand the result of this exchange process. This is the second physical transaction in the process.
02:55 to 03:05 - Again, after the exchange is initiated, we request the system to update the asset balance. Once that is done, we can see that the four packets of the warehouse asset is now transferred to the retail store. In return, John earns 200 dollars of money from the retail store owner Peter, which also reflected as part of warehouse asset balance.
In this way, 20 kgs of crop are transacted across the system and end up as four packets, each containing 5kgs of the same crop which gets eventually stocked at the retail store. Peter can now sell this stock to the end consumer at a higher price to earn his profit. If this transaction is also included in the Blockchain ledger then all the parties can see Peter's profit.
Since we earlier discussed a consortium led system with a profit sharing policy, this approach can lead to transparency in operations in a way that the excess profit feeds back into the system. This way, it also benefits the farmer and distributor.
We present to you the demo source code that was used to build this supply chain scenario. You can access the entire source package under GitHub.
We have made use of Docker containers for the three nodes in the supply chain system. We have a Docker image, pre-installed with the essential packages including the Multichain and python libraries required to run the demo. You can download the TAR compressed docker image from here and follow the main README instructions in the repository to build and run the demo.
Once the nodes are set up and running, you can launch the app by following the app README file. You can follow the instructions as per the video demonstration above and try the transactions. However, please be informed that this demo will only work for one complete supply chain transfer and you will have to delete the chain to try it again. This is done to simplify the logic and limit it for demo purpose.
You are encouraged to modify this code and build it for your specific supply chain or a buy/sell system that you want to protect using Blockchain. Do share your experiences and we will be happy to help you with unique ways of leveraging Blockchain to solve problems.
The applications and use cases of Blockchain continue to grow day by day and we are also intrigued by it. We should be back soon with yet another interesting use case of Blockchain. But just in case you have some ideas, please share in the comments below and we should be heading for an interesting discussion.
Shyam is the Creator-in-Chief at RadioStudio. He is a technology buff and is passionate about bringing forth emerging technologies to showcase their true potential to the world. Shyam guides the team at RadioStudio, a bunch of technoholiks, to imagine, conceptualize and build ideas around emerging trends in information and communication technologies.
How Blockchain can Revolutionize Agricultural Supply Chain – Part 1
Worrying About Rising Energy Bills? Realtime IoT Energy Management Is At Your Disposal
How To Make Your Smart Bin Smarter With IBM Bluemix
Build a Social Perception Dashboard for Brands