Exploring Hyperledger Fabric v1 – Supply chain demo (Tuna fish shipments)!

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:

  1.  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)
  2. Download and install the latest Hyperledger Docker VMs binaries – refer to the following URL:
https://hyperledger-fabric.readthedocs.io/en/latest/samples.html#binaries

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:

$ ./startFabric.sh

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.

  1. 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!

Further References:

https://hyperledger-fabric.readthedocs.io/en/release/

https://courses.edx.org/courses/course-v1:LinuxFoundationX+LFS171x+3T2017/course/

4 thoughts on “Exploring Hyperledger Fabric v1 – Supply chain demo (Tuna fish shipments)!

  1. Alfredo Castellano

    Execute the procedure;
    Exploring Hyperledger Fabric v1 – Building your first network (BYFN)

    With the command:
    curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0

    Consulted in:
    https://hyperledger-fabric.readthedocs.io/en/latest/samples.html#binaries

    It was executed well and these are the images,
    $ docker images
    I execute the start and the end.

    I execute:
    $ git clone https://github.com/hyperledger/education.git
    $ cd education / LFS171x / fabric-material / tuna-app
    This well
    And later
    ./startFabric.sh
    Present the error in the attached screen:

    How do I send screen captures?

    Reply
  2. Ashutosh Singh

    Its good and working fine.
    But in reality, we do not ship one Tuna fish from a fisherman to a cook of hotel.
    There is whole lot of complex procedures an d various other parties involved.
    In Reality, many such tuna fish are collected in packages (or lots) and sold to wholesale dealers.
    Then these wholesale dealers make lots ready for shipping.
    Even if we identify each tuna using unique codes, how to map each fish code to a lot or container containing hundreds of such uniquely identified tuna fishes.

    Reply
  3. Renu Vajjarapu

    Hi,am working on tuna fish.. I had tried adding extra columns along with vessel,holder etc. I came to know that it is taking upto eight columns only more than that it is giving error in inserting tuna fish..please help me with this issue.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *