How Integration of IoT Works in Hyperledger Fabrics
While going through BlogSaays you might have found numerous posts regarding Blockchain technology and its various uses in the field of creating business models using Hyperledger fabrics and more. You might have tried to understand what Blockchain actually is and why it has become so important over the past few years. According to renowned Blockchain experts and authors of Blockchain Revolution (2016) Don Tapscott & Alex Tapscott,
“The blockchain is an incorruptible digital ledger of economic transactions that can be programmed to record not just financial transactions but virtually everything of value”
You must have witnessed the sudden breakthrough of various digital currencies in the past 2 years, particularly Bitcoin. The role of Blockchain here is allowing digital information to be distributed but not copied. This is a key aspect to be kept in mind when it comes to creating any kind of virtual/digital currency. Blockchain technology created the backbone of a new type of Internet. Information held on a blockchain exists as a shared and continually reconciled database. The golden part of this technology is that even though the database is hosted by millions of computers simultaneously accessible to anyone on the internet, no centralized version of this information exists for a hacker to corrupt.
Plus, the built-in robustness of Blockchain ensures that it cannot be controlled by any single entity and has no single point of failure. This is because it stores blocks of information that are identical across its network. THAT is the level of security Blockchain provides to digital currencies!
Owing to this intense level of security, durability, and robustness that Blockchain provides, the tech community is now finding other potential uses for the technology. The most talked about utilization of Blockchain these days is with the Internet of Things (IoT).
Role of IoT
In simple words, the Internet of Things (IoT) is the network of physical devices, basically any items embedded with electronics, software, sensors, actuators, etc. that feature an IP address for internet connectivity, and the communication that occurs between these objects and other Internet-enabled devices and systems.
It is a rapidly growing technology that involves extending Internet connectivity beyond standard devices, such as desktops, laptops, smartphones, and tablets, to any range of traditionally dumb or non-internet-enabled physical devices and everyday objects.
IoT and Blockchain
Internet and Blockchain experts around the globe are now keen on developing a stable combination of IoT and blockchain. They believe that doing so will create a lot of new possibilities for using smart devices in the asset management cycle. Incorporating Blockchain models into such smart devices allow them to monitor different aspects and integrate the data from the assets into a blockchain of the business participants to provide data that is both trusts as well as real-time.Here are a few basic examples to explain how Blockchain can be used for making devices “Smarter”.
You can create a set of rules or guidelines with Blockchain’s smart contracts to monitor and control the temperature of a building based on the consumption of energy. You can also further monitor the price information of the energy from suppliers participating in the network.
It can also be used in a similar fashion for determining the quality and price of the food items based on the real-time refrigeration data used in transportation.
IBM, one of the leading global organizations that have efficiently implemented Blockchain successfully in their various business models and helped expand the technology to the business world. Recently they collaborated with Samsung to demonstrate the use of blockchain in autonomous washing machines. These smart washing machines are capable of reordering detergent and replacement parts and arranging for after-sales service using smart contracts.
Several well-established consortiums and start-up organizations like Chain of Things and Filament have demonstrated other smart ways of leveraging distributed ledgers in IoT networks. The prime objective of such organizations has been to automate the end-to-end processes and integration with business participants. Some of the most popularly talked about blockchain-based IoT use cases for different industries are:
Energy and Utilities
Banking and Financial Service
Blockchain-based IoT applications
Now that you have roughly understood the basic idea of a combination of IoT and Blockchain, let us jump straight onto the development of Blockchain application based on IoT applications. The smooth functioning of any smart device on Blockchain technology requires developing an end-to-end blockchain-enabled IoT application. The following diagram shows how a Blockchain-enabled IoT application is developed using the IBM Watson IoT Platform and Blockchain services.
Set up a private Blockchain infrastructure
The primary or rather prerequisite step involves setting up a private Blockchain based on the IBM Blockchain service is Blockchain infrastructure. If you don’t know how to set up a private Blockchain service, you can either Google it up or refer to this article on IBM bluemix .
Setting up a private Blockchain allows you to develop and deploy smart contracts in blockchain based on device data. You can set up a contract to reject a shipment or reduce a price if the temperature of the container exceeds a permissible limit or threshold.
Connect devices to the IBM Watson IoT Platform
Once you have set up a private Blockchain service, you will need to connect the sensors or gateway to the Watson IoT Platform so that the devices can send data to filter and subsequently forward to the blockchain.
Follow the documentation to learn how to add the devices to the Watson IoT Platform. The Devices page on the Watson IoT dashboard will look like as shown below once the devices have been successfully added.
Integrate device data with the blockchain distributed ledger
Once the devices have been added and the data is received by the server, the necessary data need to be sent to the Blockchain service running in IBM Cloud. This can be either the incoming raw data or filtered/ analyzed data.
You can use the HFC REST API from the Node-RED workflow to trigger the Blockchain smart contracts. You can also aggregate or filter device events and invoke the smart contracts using Node-RED with the required parameters.
Develop client applications for end users
Now finally, you will need to develop a client application using the blockchain API and other analytical services supported by IBM Cloud to make the transaction outputs/events available for the end users.
The Blockchain service provided by IBM is an implementation of Hyperledger Fabric and provides the following:
A blockchain network consisting of four peers
A certification authority server
Smart contract code (chaincode, developed using Golang)
The ledger state, which holds the current value of smart contract data and the history of all transactions.
Each invocation of a smart contract is recorded as a blockchain transaction and thus forms the core of blockchain-based solutions. Smart contracts need to be registered with blockchain services using the Go language and pre-defined contract APIs.
A Contract API can only be implemented once the Smart contract has been registered and set up by a smart contract developer. It has three main functions:
If you want more details regarding Contract API, you can either Google it up or refer to the IBM Cloud documentation. Every Blockchain framework requires a client API for Blockchain applications that interact with a Blockchain network. These applications can securely register users and submit transactions using this API.
The client application
If you want to provide the required data to stakeholders to meet their business needs and provide a rich user experience, you will a client application. These Client applications use the Blockchain API as provided to interact with the business ledger and process the events generated by the blockchain components.
By now you must have developed a clear idea of the huge potential for developing applications using Blockchain in IoT solutions. The rapid development and research on Blockchain and IoT over the last 5 years has shown that the combination of the two technologies can help tackle some of the key issues like security and scalability that limit adoption of IoT.
The distributed ledgers with embedded smart contracts will not just help automate complete processes comprised of multiple business partners, but also drastically improve security and trust. Ready-to-deploy platform for blockchain-based (and open-standards-based) IoT applications that can be developed by combining the IBM Watson IoT Platform with IBM Cloud-based Blockchain services.
There are a few challenges that do stand in-between blockchain-based IoT applications that need to be overcome. Considerable issues include the limited computing power of many IoT devices and requirement of considerable processing power encryption and verification of blockchain transactions, which may not be available in low-end devices.
Saurabh Mukhekar is a Tech Blogger from Pune, India. He is also thinker, maker, life long learner, hybrid developer, edupreneur, mover & shaker. He’s captain planet of BlogSaays and seemingly best described in rhyme. Follow Him On Facebook