Build a blockchain network for trusted IoT

Summary

Blockchain is an emerging technology that brings trust and transparency to an industry where transactional processes are important. In digital transformation business, Internet of Things (IoT) is another trending technology that refers to the billions of physical devices around the world that are now connected to the Internet, collecting and sharing data. This developer code pattern shows you how to use Hyperledger Fabric, an open source blockchain framework, and the Watson™ IoT platform with Node-RED to manipulate the collection of data on a distributed network immutably.

Description

While developing this code pattern, the goal has been to design a proof of concept for both blockchain and IoT. Instead of developing an application with complete capabilities, this solution is much more understandable and instructive. This code pattern can be extended and modified according to new business models by adding new organizations to the distributed network and developing new smart contracts depending on the logic. In this pattern, you will build a Hyperledger Fabric network where you will store IoT sensor data (such as temperature), and a UI where you can see the sensor data history.

When you have completed this code pattern, you will understand how to:

  • Set up a Hyperledger Fabric network
  • Design APIs with the Hyperledger Fabric SDKs to interact with the network
  • Collect data from the sensor and display it on the dashboard with Node-RED

Flow

flow

  1. The Watson IoT Platform input node that comes built-in with Node-RED receives events that are sent from devices (in our case, temperature).
  2. To invoke and query the ledger (to write and read the data), nodes inside the Node-RED perform HTTP requests and return the responses to the APIs.
  3. APIs that are defined based on the Hyperledger Fabric Client SDK for Node.js interact with the chaincode inside the Hyperledger Fabric network and updates or reads the ledger.
  4. Endorser peers execute the functions defined in the chaincode according the request and sends it to the orderer.
  5. The orderer creates blocks and sends them back to the anchor peers, which broadcast the blocks to the endorser peers.

Instructions

Ready to get started? Check out the README for detailed instructions on how to:

  • Check the installation prerequisites and clone the repo
  • Create and access the IBM Cloud Kubernetes Cluster
  • Deploy Hyperledger Fabric
  • Deploy Hyperledger Fabric SDK for Node.js
  • Deploy Node-RED