Let’s begin with some fundamentals! Adopting Blockchain helps to establish a “System of Proof”, where we can verify the complete historical record of transactions right from the genesis of the blockchain – which is immutable, unbreakable meaning that it cannot be changed, moved, or deleted. The blockchain integrity is protected by Cryptographic hashing, key signature, and timestamping mechanisms. Every change scheduled and addressed on the blockchain is only appended as a new block to the blockchain in order.
In a supply chain scenario, blockchain brings assurance of integrity while maintaining transparency throughout the process. Linux Foundation has recently introduced a short online course on Hyperledger which is available for free. To showcase this demo, I used the Hyperledger Fabric v1 supply chain example (establish legal Tuna fish shipments) provided. The demo presents how we can transparently manage and regulate tuna fish shipments right from the source and till reaching the end customer while having able to validate the legal source throughout the process and avoid illegal and unrecorded sources. This example uses three actors in the supply chain (Fisherman, Restaurant/Consumer, and Regulator) and we should able to keep track of the record using the distributed ledger to record all shipments right from the legal source of fishing from fisherman and till the restaurant where it ends up. Regulators can query the ledger to verify, and view details of all entries in real-time. Using Hyperledger establishes permissioned private blockchain, where only registered and approved personnel can join the blockchain network using MSPs.
Let’s explore the supply chain scenario using Hyperledger Fabric v1 framework components in terms of its role and relevance on the network. The core components are as follows:
- Shared Permissioned Ledger contains the current state of all records right from the beginning of the network and the series of transaction invocations. As ledger is an append-only system of records and serves as a single source of all transactions and it is made available to all peers on the network.
- All Peers commit blocks and maintain a copy of the ledger. Two types of peers: Endorsers and Committer peers. Endorsers simulate and endorse transactions. Committers verify endorsements and validate transaction results.
- Channels establish transaction visibility to all the members of the network. Each channel maintains independent chain of transaction blocks containing only transactions specific to that channel.
- Chaincode encapsulates the asset definitions and the business logic (or transactions) for creating and modifying (CRUD) which performs transaction invocations on those assets
- Orderer accepts endorsed transactions, orders them into a block, and delivers the blocks to the committing peers.
- MSP manage user IDs, and authenticate all the participants in the network.
The demo application made available is written using Hyperledger Node.js SDK.
Try it yourself:
- Have your Ubuntu instance (atleast 8Gb memory and 16Gb storage) up and running. Make sure you installed the following:
- Docker.io and Docker Compose (docker.io and docker-compose)
- Download and install the latest Hyperledger Docker VMs binaries – refer to the following URL:
I used the following URL (please note this changes upon new builds so make sure to download from the latest URL obtained from the link above:
$ curl -sSL https://goo.gl/Q3YRTi | bash
3. Verify install by running ‘$docker images’ (refer output, should look like this)
4. Download the Linux Foundation (Hyperledger Fabric v1 Education sample repository) and then change the directory to ‘tuna-app‘.
$ git clone https://github.com/hyperledger/education.git $ cd education/LFS171x/fabric-material/tuna-app
5. Start the Hyperledger Fabric network using the following command:
A typical output would look like this:
6. As the application is written using Node.js SDK, it is critical to Node.js binaries installed and available for use. The application also has dependencies to Go SDK. So let’s install beginning with Go language and Node.js binaries.
$ apt install golang-go $ go version $ sudo bash -c "cat >/etc/apt/sources.list.d/nodesource.list" <<EOL > deb https://deb.nodesource.com/node_6.x xenial main > deb-src https://deb.nodesource.com/node_6.x xenial main > EOL $ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add - $ apt update $ apt install nodejs $ apt install npm $ node --version && npm --version $ npm install $ npm rebuild
Discard warnings, not errors! If you encounter errors you may want to start from the beginning.
- Finally, register the Admin and User components of our network, and then start the client application using the following commands:
$ node registerAdmin.js
You should be seeing similar output:
$ node registerUser.js
You should see the following output:
8. Now, start the server (server.js) and then try accessing client at the servehost_address:8000. Make sure port 8000 is accessible from the host. The user can interact with the Web application that enables users to query and update a ledger. Under the hood, the application using the SDK sends the endorsed proposal (automatically) to the Solo ordering service where the order is packaged into a block then broadcasted to all the peers on the network.
$ nohup node server.js &
Try accessing the Web application client using the browser (http://IPaddress:8000/:
2) Try “Query” All or “Query a Specific Tuna Catch”:
You should able to “Create a Tuna Record” and also “Change Tuna Holder” and so on.
THAT’S ALL FOLKS!