Implementing blockchain for cognitive IoT applications, Part 1
Integrate device data with smart contracts in IBM Blockchain
How are these two technologies being used to build end-to-end secure and automated solutions?
This content is part # of # in the series: Implementing blockchain for cognitive IoT applications, Part 1
This content is part of the series:Implementing blockchain for cognitive IoT applications, Part 1
Stay tuned for additional content in this series.
Internet of things (IoT) solutions are being successfully adopted in many different industries, such as healthcare, warehousing, transportation, and logistics. Current centralized, cloud-based IoT solutions may not scale and meet the security challenges faced by large-scale enterprises. The use of blockchain as a distributed ledger of transactions and peer-to-peer communication among participating nodes can solve such problems. This article provides an overview of blockchain-enabled IoT solutions and demonstrates how to use the IBM Blockchain platform for an IoT application in a multi-partner environment.
What is blockchain?
Blockchain refers to a distributed ledger where a list of transactions is stored in multiple participating servers rather than on a central transaction server. Each participant in the blockchain network is granted access to an up-to-date copy of this encrypted ledger so they can read, write, and validate transactions. Refer to the Related topics for more details on blockchain and how IBM is contributing to developing a blockchain for business.
While the key blockchain usage scenarios are in the financial domain, blockchains have recently gained a lot of attention in IoT solutions. Blockchain can significantly help in achieving the vision of decentralized IoT, facilitating transactions and coordination among interacting devices.
IoT and the IBM Watson IoT Platform
IoT has introduced huge opportunities for businesses and consumers, especially in the areas of healthcare, warehousing, transportation, and logistics. IoT solutions involve a complex network of smart devices, and IoT provides the opportunity to develop new services based on cloud-enabled connected physical devices—from machines and cars to home appliances. There are three main tiers of IBM Cloud-supported IoT solutions, each with specific responsibilities of its own:
- Devices / gateway: These are smart devices or sensors that collect data about the physical world, such as the temperature of a refrigerated container transporting perishable foods, or health data for a patient who's admitted to the hospital. Devices are connected to the internet to transmit this data securely to an IoT platform for analysis, processing, and actions based on that data.
- IBM Watson IoT Platform: IBM's IoT Platform collects data from IoT devices and provides various services that analyze the data and take subsequent actions to solve specific business problems. The Watson IoT Platform provides a rich set of cognitive services (such as machine learning, machine reasoning, natural language processing, and image analysis) that enhance the ability to process the unstructured data collected from the various intelligent sensors.
- IBM Bluemix: Bluemix is an open standards-based cloud platform for building, running, and managing applications and services. It supports IoT applications by making it easy to include analytical and cognitive capabilities in those applications based on multiple runtimes and services.
Blockchain and IoT
While IoT adoption is growing significantly, some key challenges need to be addressed to make IoT solutions scale and support the ever-growing demand for more and more connected devices. IoT solutions must address the security and privacy concerns around these devices and the data they collect. Some of these challenges are:
- Scalability: Current centralized, cloud-based IoT platforms enforce message routing through these platforms. This enforcement creates a bottleneck to scaling the IoT solutions to large number of devices.
- Security: The huge volume of data that’s collected from millions of devices raises information security and privacy concerns for individuals, corporations, and governments. As proven by recent denial-of-service attacks on IoT devices, the large number of low-cost devices connected to the internet is proving to be a major challenge in ensuring IoT security.
- Lack of data standards / uniformity: The world is turning toward open-data initiatives, but there is no uniform approach. There are several protocols and no single platform for connecting devices from all manufacturers. The interoperability of devices and platforms is a key challenge to the growth of IoT solutions.
- Cost: IoT solutions are associated with a huge number of devices and their network equipment. The costs associated with IoT solutions are proving to be very high as they need to cater to a very high volume of messages (communication costs), data generated by the devices (storage costs), and analytical processes (server costs). Subsequent growth will only add to these costs.
- Architecture: Centralized cloud platforms remain a bottleneck in end-to-end IoT solutions. Any disruption there can affect the entire network.
Decentralized IoT networks
Blockchain technology and IoT offer a new world of promise, and can be leveraged to address the problems described above. Open-standards-based distributed IoT networks can solve many of the problems associated with today’s centralized, cloud-based IoT solutions, including security, scalability, and cost. For example, connected devices could communicate directly with distributed ledgers. Data from those devices could then be used by smart contracts to update and validate the data and subsequently deliver it to all interested participants in the business network. This would reduce the need for human monitoring and actions, and promote trust in the data generated by the devices. Decentralized blockchain networks can also improve the security of IoT solutions by executing predefined smart contracts and implementing specific consensus mechanisms that eliminate actions from compromised devices.
The IBM Watson IoT Platform now supports the use of IBM Blockchain services for IoT applications. Data from IoT devices can now be integrated with the private blockchain ledgers and shared transactions with high security. The blockchain’s distributed replication mechanism eliminates the need to have all IoT data collected and stored centrally, and enables the use of the IoT data in a decentralized way.
IoT use cases using blockchain
The combination of IoT and blockchain is creating a lot of new possibilities for using smart devices in the asset management cycle. As assets go through the various phases of their lifecycle, devices monitor different aspects and integrate the data from the assets into a blockchain of the business participants to provide real-time, trusted data. With blockchain’s smart contracts, rules can be created to monitor and control the temperature of a building based on the consumption of energy and price information of the energy from suppliers participating in the network. Similarly, the quality (and price) of the food items can be determined based on the real-time refrigeration data used in transportation. IBM (along with Samsung) demonstrated the use of blockchain in autonomous washing machines that can reorder detergent and replacement parts, and arrange for after-sales service using smart contracts.
Several consortiums (such as Chain of Things) and start-up companies (such as Filament) have demonstrated other smart ways of leveraging distributed ledgers in IoT networks to automate the end-to-end processes and integration with business participants. The table below lists some blockchain-based IoT use cases for different industries:
|Supply chain||Lack of visibility is a key problem in the supply chain. Even
when data on the processes is available, it's not reliable
enough that it should trigger concrete actions. Blockchain can
help solve some of the key problems in the supply chain:
visibility, optimization, and demand. It can ensure proper
access control for data shared among participants in the
supply chain. A supply chain with continuous, real-time access
to reliable, shared data in blockchain can be optimized more
efficiently than that of traditional supply chains.|
Concrete supply chain use cases based on Blockchain and IoT include:
|Automotive||The automotive industry is one of the leading industries in
the adoption of blockchain-based IoT solutions.
Blockchain-based solutions are being used to provide real-time
information and to execute transactions among key business
partners—manufacturers, auto financing companies,
insurers, service providers, regulators, and customers. In
addition to the adoption of blockchain in auto supply chains,
sensor data from various vehicle parts are integrated with
blockchain to make real-time decisions and transactions
involving services and payments.|
For example, Toyota has started using blockchains to track the thousands of parts that travel through various countries, factories, and suppliers to manufacture a single car.
|Energy and utilities||Blockchain has disruptive potential for the energy industry.
Blockchain-supported IoT networks of energy grids enable
peer-to-peer transactions of energy. In one application,
excess rooftop solar energy is sold to other users who need
it—all of which is paid for and recorded through a
Startup companies like Filament are also building mesh networks of smart devices that monitor energy grids and fix any issues that arise as quickly as possible.
|Healthcare||Use of blockchain can help improve the security of private
patient data that comes from medical monitoring devices. Data
is stored securely in a distributed ledger, and participants
are given access based on smart access rules that are set in
the blockchain (for example, approval from 3 or more
This can also help to provide real-time trusted patient data for required participants (such as insurance providers or third-party administrators) and help them release payments based on more accurate data.
|Home automation||IoT-enabled technologies are being used in smart cities and
intelligent buildings to improve operations, security, and the
experience of residents. A huge number of devices and sensors
are being used to monitor and manage these facilities.
A blockchain-enabled IoT network can secure devices and the data collected from them. All facility management suppliers can participate in a private blockchain to provide timely service and automate the payment process based on the actual work done or the quality of service.
|Other industries / applications||Blockchain technology also helps improve the management of
devices and the security of the data flow in the
It enables access control of the data that flows to different participants, allows the exchange of data among participants, and provides the necessary payment services that are integrated with the flow of the data.
Architecture of blockchain IoT applications
Figure 1 shows the high-level architecture of IoT applications that use Bluemix-based Hyperledger services.
Figure 1. Blockchain IoT application architecture
Data from devices are sent to Watson IoT Platform using MQTT protocol. Blockchain proxy in the Watson IoT Platform sends the data to the chaincode based on a pre-defined configuration. Smart transactions are executed in Bluemix based on the device data.
Individual components are described in the next section.
Bluemix Blockchain service
IBM Blockchain provides the private blockchain infrastructure for developing blockchain-enabled solutions. The Bluemix Blockchain service is an implementation of Hyperledger Fabric. It provides the following:
- A blockchain network consisting of four peers
- A certification authority server
- Smart contract code (chaincode, developed using Golang)
- The world / ledger state, which holds the current value of smart contract data (the history of all transactions is also available in the Blockchain)
Figure 2 shows the different subcomponents of the IBM Blockchain services.
Figure 2. Subcomponents of IBM Blockchain services
Smart contracts form the core of blockchain-based solutions and encapsulate the business logic. Each invocation of a smart contract is recorded as a blockchain transaction. IBM Blockchain contracts (chaincode) are developed using the Go language and need to implement the Contracts API. Smart contracts need to be registered with blockchain services using pre-defined APIs.
Contract API needs to be implemented by a smart contract
developer. It has three main functions:
Query(). Refer to the Bluemix documentation for more details about this API.
Blockchain API is the client API for blockchain applications. The Hyperledger Fabric Client (HFC) SDK enables application developers to build Node.js applications that interact with a blockchain network. Applications can securely register users and submit transactions using this API.
There are several alternatives to developing client applications for blockchain:
The blockchain REST API helps to interact with the blockchain peers using the http interface. A list of supported operations is shown in the table below:
|Returns information about a specific block within the blockchain.|
|The chain endpoint returns information about the current state of the blockchain.|
|This API returns a list of all existing network connections for the target peer node. The list includes both validating and non-validating peers.|
|Registers a user with the certificate authority.|
|Deletes any existing client login tokens from local storage. After the completion of this request, the target user will no longer be able to execute transactions.|
|Confirms whether the specified user has registered with the certificate authority.|
|Retrieves the enrollment certificate for a given user that has registered with the certificate authority.|
|Retrieves the transaction certificates for a given user that has registered with the certificate authority.|
|This endpoint returns the transaction matching the specified UUID.|
IBM-Blockchain-js is a Node.js wrapper library over the REST API that's provided by Bluemix Blockchain services. It provides functions in the easy-to-use Node.js API that are similar to those available in the REST API.
- Hyperledger fabric Client (HFC) SDK for Node.js
- Hyperledger fabric on GitHub
- IBM Blockchain Docs: HFC SDK for Node.js
The client application
The client application is responsible for providing the required data to stakeholders to meet their business needs and provide a rich user experience. Client applications need to use the blockchain API as provided for the smart contracts to interact with the business ledger. These applications can also process the events generated by the blockchain components.
IBM Watson IoT Platform
The IBM Watson IoT Platform receives data from all of the registered devices and processes that data into the required format for integration with blockchain. This means the blockchain contract developer doesn’t need to know the details about the source of the data, and can focus on developing the contract logic.
Developing blockchain IoT applications
Figure 3 shows the key steps in developing a blockchain-enabled IoT application using the IBM Watson IoT Platform and Bluemix Blockchain services. Developers need to have several skills to develop end-to-end IoT applications using these services.
Figure 3. Developing blockchain IoT applications
Here's a brief overview of each step in the process:
1. Set up a private blockchain infrastructure
Developers need to set up a private blockchain based on the IBM Blockchain service. Refer to the Bluemix documentation on setting up private blockchain services.
Develop and deploy smart contracts in blockchain based on device data. A contract can be set up to reject a shipment or reduce a price if the temperature of the container (measured by sensors) exceeds a certain threshold.
2. Connect devices to the IBM Watson IoT Platform
Connect the sensors / gateway to the Watson IoT Platform. This will enable the devices to send data to filter / aggregate and subsequently forward to the blockchain. Follow the documentation to add the devices to the Watson IoT Platform. When successfully added, the Devices page on the Watson IoT dashboard will look like this:
Figure 4. Watson IoT dashboard Devices page
3. Integrate device data with the blockchain distributed ledger
The Watson IoT Platform needs to be enabled to send data to Blockchain services running in Bluemix. Refer to the Bluemix documentation for more details on configuring the integration. Install the monitoring UI to verify the connection between the Watson IoT Platform and the Blockchain fabric.
Alternatively, Blockchain smart contracts can also be triggered using the HFC REST API from Node-red workflow. Node-red can be used to aggregate and / or filter device events and invoke the smart contracts with required parameters.
4. Develop client applications for end users
The final step is to make the transaction outputs / events available for the end users. A client application can be developed using the blockchain API (as mentioned in the previous section) and other analytical services using multiple languages / platforms supported by Bluemix.
As you can see, there is huge potential for developing applications using blockchain in IoT solutions, and this combination can solve some of the key problems that limit adoption of IoT, such as security and scalability. A distributed ledger with embedded smart contracts can improve security and trust, and automate complete processes comprised of multiple business partners. The IBM Watson IoT Platform can be combined with Bluemix-based Blockchain services to provide a ready-to-deploy platform for blockchain-based (and open-standards-based) IoT applications.
There are, however, a few challenges that need to be overcome. One of the key challenges of blockchain-based IoT applications is the limited computing power of many IoT devices. Encryption and verification of blockchain transactions can require considerable processing power, which may not be available in low-end devices. And use of more processing power can increase both the energy consumption and the cost of the solution.
In Part 2 of this article, we will demonstrate the integration of the IBM Watson IoT Platform with IBM Blockchain services to develop an application that uses (simulated) vehicle and V2V sensor data to execute smart transactions in IBM Blockchain.
- IBM Blockchain
- IBM Blockchain for developers
- IBM Blockchain 101: Quick-start guide for developers
- IBM Watson IoT Platform
- Explore Watson IoT with blockchain
- Linux Hyperledger Project
- Video: Blockchain brings trust to the Internet of Things