# Blockchain Enabled Automatic Reward System in Solid Waste Management

Authors: Shaik Vaseem Akram; Sultan S. Alshamrani; Rajesh Singh; Mamoon Rashid; Anita Gehlot; Ahmed Saeed AlGhamdi; Deepak Prashar
Journal: Security and Communication Networks
 (2021)

---

## Abstract

Solid waste management (SWM) is a key administrative unit for managing the urban waste to deliver an eco-friendly environment to the citizens residing in urban cities. Generally, many technologies are implemented and developed by researchers for enhancing the mechanism of SWM and minimizing the waste generation. Yet, the management of waste generation is still a concern. So, here, there is requirement of technology that can involve the individuals for achieving the target reducing the waste. At present, the blockchain technology is an appropriate technology for SWM, as it provides the applications of time tracing activities, secure data transactions, and automatic reward system. In this study, a blockchain-based reward system is proposed to generate the rewards based on real-time series data such as quantity of garbage and level of waste. Furthermore, LoRa-range-based customized sensors are developed for bins to obtain real time information. Moreover, the generated information further transferred to cloud by utilizing LoRa wireless enabled gateway. By the use of flask server, a technique is proposed for integrating real-time data with blockchain via a local network application programming interface (API). A real-time implementation is evaluated on the data to the check the performance efficiency of the proposed approach, where the procedure of automatic reward system is presented in detail.


---

## Body

## 1. Introduction

A solid waste management (SWM) unit has the primary task in urban cities to ensure a healthy environment and preserve natural resources by appropriately managing solid waste [1]. The sustainable development goals (SDGs) formulated by the United Nations (UN) set a target of reducing gas emissions from the waste [2]. According to the UN, the word sustainability is intended to build and preserve environments, under which people and the environment will be in sustainable equilibrium that meet current and future generation’s social, economic, and other requirements [3, 4]. Moreover, at present, the smart cities concept is empowering us to achieve the goal of sustainability to some extent [5]. However, in smart cities, SWM is one area where technology integration and enhancement are necessary for managing the waste generation that directly impacting the environment [6]. Generally, the activities involved in the SWM are collection, transportation, recycling, disposal, and analysis of waste data [7]. The tracking and monitoring of every activity are necessary for the municipal administration to manage and enhance the mechanism effectively, as the large amount of waste generation is not effectively treated for acquiring maximum benefits from it in terms of reusing, recycling [8, 9].At present, there is lack of accurate information regarding quantities and characterization of wastes as it is combating the municipal administration to manage the waste effectively for reducing effects on the environment [10]. To overcome these challenges, many researchers have implemented different solutions from both the hardware and software perspectives. Currently, Internet of Things (IoT) and cloud server are the emerging technologies that are widely implemented in SWM for minimizing the effect of environment due to large amount of waste generation [11, 12]. However, these technologies encourage only limited participants to monitor the SWM activities, as these technologies are lacking in the authentication and security of the data [13]. In addition, there is a requirement for a single platform that integrates the multiple participants of SWM for managing the waste efficiently.Additionally, a study [14] has suggested implementing blockchain technology for establishing an automatic payment system for collecting waste from any individuals. An individual will process the payment into the account of municipal administration through a mobile app. With the motivation from the above study, in this article, blockchain technology intervenes with the hardware system for establishing a real-time and automatic reward system for individuals who dispose their garbage in the bins. The automatic reward system is generated based on the quantity of waste in the bins. Blockchain technology is integrated to implement the secure reward system, as blockchain technology is feasible for performing secure transactions by authenticating the data. The contributions of the article are as follows:(a)
An architecture is proposed for intervening the IoT enabled hardware with blockchain for SWM.(b)
Customization of hardware is implemented for the sensor node and gateway.(c)
We have utilized a Python-based flask framework for creating a web API to realize the proposed reward system.(d)
Verification of miners in private blockchain with trust point is presented in this study.The organization of the article is as follows: Section2 covers the background of blockchain along with smart contracts and consensus mechanism; Section 3 covers the related work of distinct methods implemented for SWM and also presents a comparison with previous studies; Section 4 covers the proposed architecture for SWM with hardware implementation and also blockchain implementation through local network API. Section 5 covers the results analysis.


## 2. Background of Blockchain Technology

Blockchain is a distributed peer-to-peer network that holds a complete record of transactional ledgers in immutable and transparent manner [15]. Blockchain guarantees full decentralization by not relying on a third-party, intermediary, or any centralized authority [16]. In blockchain network, the node maintains complete record of blockchain, as it is connected in peer-to-peer. Initially, the blockchain technology introduced by Satoshi Nakamoto in 2008 is only limited for a digital currency, i.e., bitcoin [17]. However, the unique features of the blockchain technology empowered us to implement it widely in various industries for enhancing the security and transparency. Basically, the blockchain consists of a ledger of time-stamped enabled blocks that are interlinked to the chain, with a cryptographical hash function [18]. The hash of the previous block is presented in each block. The relation between blocks is established, and the chain of blocks or blockchains are created and presented as seen in Figure 1. The blockchain gained attention due to its unique features, as illustrated in Figure 2, and features are decentralization, transparency and privacy, and security.Figure 1
Working of blockchain technology [19].Figure 2
Features of blockchain [20].


### 2.1. Decentralization

In the blockchain, decentralization implies that the data is evenly available to all participants in the network. Transactions have become convenient to complete, and this technology encourages individuals to trust each other rather than allowing them to verify their identity before proceeding with any transaction.


### 2.2. Transparency and Privacy

As blockchain is a decentralized system, it enables everyone to visualize the transactions conveniently. Blockchain is a technology that improves transaction transparency by ensuring that everyone on the network has a copy of the ledger. As a result, the blockchain ledgers are tamper-proof. Privacy on the blockchain is another feature of blockchain that makes it so special. Privacy in blockchain can be protected by publishing the required details while being confident that your knowledge will not be misused. To keep their transactions and identities secure, individuals can build private networks with restricted access and select from a list of organizations connected to the blockchain network.


### 2.3. Security

At present, security is a significant component that gained importance in every technology. In case of blockchain, the security feature differentiated and encouraged the researchers to integrate blockchain technology. The security feature in the blockchain technology is robust, because each block is attached with public key cryptography framework. Basically, the public key cryptography framework comprises a pair of keys, namely, public key and private key. Asymmetry encryption enables two keys to validate the authenticity of transactions. During the transaction between the two entities, the public keys can be shared to other entities for receiving the transactions, and private keys must be kept secret.


### 2.4. Consensus Mechanism

Moreover, there are other methods, namely, consensus mechanism and smart contract, that enable blockchain as a secured network for performing transactions. A consensus mechanism is a fault-tolerant mechanism that is implemented for obtaining the valid agreement in blockchain systems for single data attribute. This mechanism empowers us to overcome the problem of 51% attack on the blockchain network. A 51% attack implies an attack done by the group of miners by controlling more than 50% of network. At present, the following consensus mechanisms are implemented in various blockchain networks: Proof-of Work (PoW), Proof-of-Capacity (PoC), Proof-of-Activity (PoA, Proof-of-Burn (PoB), Unique Node Lists (UNL), Proof-of-Weight (PoW), SIEVE, Practical Byzantine Fault Tolerance (PBFT, Byzantine Fault Tolerance (BFT, Delegated Proof-of-Stake (DPoS), and Proof-of-Stake (PoS) [21].


### 2.5. Smart Contract

Another important method in the blockchain network for performing the digital transactions is smart contract. Generally, the smart contract is a digital contract of transactions where the agreement clauses are written in computer languages [22]. The concept of the smart contract is first evolved in the 1990s by Nick Szabo [23]. In traditional contract, the paper document with various conditions is signed by two entities. However, in the traditional contract, the manipulation of conditions is done easily. In case of smart contract, the agreement is developed in digital form, where the conditions are written in programming language. The smart contract executes the agreement clauses, when predetermined conditions written in smart contract are matched. Moreover, the smart contract encourages us to implement the transactions between two nodes in a lawful and encrypted way by using digital signatures in the peer-to-peer network. The information flow in the smart contract during transactions explains the creation of blocks, and database updating is clearly presented in Figure 3. The transaction to undertake the rules of smart contracts for validating data, after the consensus agreement algorithm, must verify at least 51% of the information inputs and transaction to update the blockchain network’s database [24]. The consensus nodes in the network verify and validate the transactions. After the validation of transactions, the “blocks” are created, added, and distributed to similar blocks in the network.Figure 3
Mechanism of information transactions with smart contracts [25].


## 2.1. Decentralization

In the blockchain, decentralization implies that the data is evenly available to all participants in the network. Transactions have become convenient to complete, and this technology encourages individuals to trust each other rather than allowing them to verify their identity before proceeding with any transaction.


## 2.2. Transparency and Privacy

As blockchain is a decentralized system, it enables everyone to visualize the transactions conveniently. Blockchain is a technology that improves transaction transparency by ensuring that everyone on the network has a copy of the ledger. As a result, the blockchain ledgers are tamper-proof. Privacy on the blockchain is another feature of blockchain that makes it so special. Privacy in blockchain can be protected by publishing the required details while being confident that your knowledge will not be misused. To keep their transactions and identities secure, individuals can build private networks with restricted access and select from a list of organizations connected to the blockchain network.


## 2.3. Security

At present, security is a significant component that gained importance in every technology. In case of blockchain, the security feature differentiated and encouraged the researchers to integrate blockchain technology. The security feature in the blockchain technology is robust, because each block is attached with public key cryptography framework. Basically, the public key cryptography framework comprises a pair of keys, namely, public key and private key. Asymmetry encryption enables two keys to validate the authenticity of transactions. During the transaction between the two entities, the public keys can be shared to other entities for receiving the transactions, and private keys must be kept secret.


## 2.4. Consensus Mechanism

Moreover, there are other methods, namely, consensus mechanism and smart contract, that enable blockchain as a secured network for performing transactions. A consensus mechanism is a fault-tolerant mechanism that is implemented for obtaining the valid agreement in blockchain systems for single data attribute. This mechanism empowers us to overcome the problem of 51% attack on the blockchain network. A 51% attack implies an attack done by the group of miners by controlling more than 50% of network. At present, the following consensus mechanisms are implemented in various blockchain networks: Proof-of Work (PoW), Proof-of-Capacity (PoC), Proof-of-Activity (PoA, Proof-of-Burn (PoB), Unique Node Lists (UNL), Proof-of-Weight (PoW), SIEVE, Practical Byzantine Fault Tolerance (PBFT, Byzantine Fault Tolerance (BFT, Delegated Proof-of-Stake (DPoS), and Proof-of-Stake (PoS) [21].


## 2.5. Smart Contract

Another important method in the blockchain network for performing the digital transactions is smart contract. Generally, the smart contract is a digital contract of transactions where the agreement clauses are written in computer languages [22]. The concept of the smart contract is first evolved in the 1990s by Nick Szabo [23]. In traditional contract, the paper document with various conditions is signed by two entities. However, in the traditional contract, the manipulation of conditions is done easily. In case of smart contract, the agreement is developed in digital form, where the conditions are written in programming language. The smart contract executes the agreement clauses, when predetermined conditions written in smart contract are matched. Moreover, the smart contract encourages us to implement the transactions between two nodes in a lawful and encrypted way by using digital signatures in the peer-to-peer network. The information flow in the smart contract during transactions explains the creation of blocks, and database updating is clearly presented in Figure 3. The transaction to undertake the rules of smart contracts for validating data, after the consensus agreement algorithm, must verify at least 51% of the information inputs and transaction to update the blockchain network’s database [24]. The consensus nodes in the network verify and validate the transactions. After the validation of transactions, the “blocks” are created, added, and distributed to similar blocks in the network.Figure 3
Mechanism of information transactions with smart contracts [25].


## 3. Related Works

In SWM, distinct technologies are implemented for monitoring and managing activities like collection and storage. In SWM, distinct technologies are implemented for monitoring and managing activities like collection, storage, transportation, and disposal. The previous studies that implement distinct technology include the following: an RFID-based SWM is implemented for scheduling and routing of trucks for collecting the waste through a global positioning system (GPS) [26, 27]. The advancement in software technologies, widespread Internet, and their cost-effectiveness enabled the implementation of integrated systems for SWM. A web-GIS system is integrated with RFID for SWM [28, 29]. Content-Based Image Retrieval (CBIR) system is implemented for perceiving the level of solid waste bin, and in identifying the resemblance between the query images and images in the database, and EMD (Earth Mover’s Distance) showed better performance than other distance calculation methods [30].Furthermore, the optimization techniques are implemented in the SWM for minimizing the collection cost and transportation cost. A multilayer based SWM system is proposed, where the system is integrated with RFID, sensors for tracking the bins’ identity, and monitoring the level of the waste in the bins [31, 32]. An IoT-based data-driven framework is implemented to evaluate household waste behavior and formulate policy regulations [33]. An IoT framework with machine learning is recommended for estimating the garbage level in the bins [34]. An intelligent waste management system employs LoRa communication protocol and a deep learning method for sorting the various waste [35]. Global System for communication (GSM) and Arduino IDE-based smart IoT system are created for monitoring and communicating the filling levels of the bins in real-time [36]. However, many challenges exist in traceability, control from the government, lack of mechanisms for policy implementation, and loss in the economic value of waste. The challenges still exist in SWM, because there is no implemented technology in terms of real-time tracing, the immutability of data, and performing the economic transactions securely in a decentralized manner. Yet, all these features exist in blockchain technology.A framework is recommended for proper validation and tracking the products during the supply chain using a set of private distributed ledgers and a single public blockchain [37]. The architecture is based on software-defined networking, and blockchain technology implemented for smart cities to overcome latency problems, bandwidth bottlenecks, scalability, security, and privacy [38]. A blockchain-based traceability prototype system is proposed for avoiding data tampering during traceability [39]. The integration of IoT and blockchain is implemented for tracing the food from production to consumption using smart contracts [40, 41].The previous studies concluded that blockchain technology would enhance the activities in the SWM in terms of real-time tracking, data security, and transparency. Moreover, blockchain with IoT enables the implementation of a real-time system for realizing the payment system. Prior to these, a comparison is presented in Table1. Table 1 explains the comparison of the previous studies that implemented blockchain for SWM. The comparison is evaluated based on distinct parameters like objective, framework, hardware, reward system, and API. From the previous studies, only limited studies have realized the blockchain practically, and others have utilized SWM as a case study for evaluating the blockchain. Moreover, limited previous studies have implemented real-time customized hardware for obtaining real-time from the bins.Table 1
Comparison of the current study with previous studies of blockchain-based SWM.
ResearchObjectiveFrameworkHardwareReward systemAPI[42]A generalized architecture is implemented for merging blockchain and IoTBlockchain and IoT enabledSimulation is implemented in place of real hardwareYes (implemented)BoT API[43]Design science method is implemented for formulating blockchain-based waste managementUse case for cross border wasteNo software and practical implementationNot implementedNot mentioned[44]Implementing blockchain in SWM for replacing green coins in the small Brazilian municipalityEthereum centered digital architecture for SWMNo hardware implementationReward system for converting green coins into actual currencyNot addressed[45]Improving the traditional system in terms of data sharingDecision making framework for service selectionNo hardware implementationImplemented reward system for maintained green behaviorNot available[46]Monitoring the end-of-life (EOL) of waste andBlockchain framework for the municipalityNo hardware implementationNot implementedNot implemented


## 4. Proposed Architecture

In this section, we present the proposed architecture for establishing an automatic reward system using IoT and blockchain technology. Moreover, to establish IoT, a hardware implementation will be addressed in this section. Finally, the blockchain Implementation through Local Network API is presented.


### 4.1. IoT and Blockchain Architecture for SWM

In this section, we present the proposed architecture for SWM, where the IoT enabled hardware is integrated with blockchain. The proposed architecture is motivated from [47], it is shown in Figure 4, and it describes the mechanism of intervening the hardware IoT devices of SWM to the blockchain technology and the collection of information transmitting through the various nodes of the blockchain transparently and securely preserving the process’s traceability. In the architecture, major participants having access to Ethereum smart contracts through the Internet are fog nodes, users, admins, IoT devices, and cloud servers.Figure 4
Proposed architecture for intervening IoT enabled hardware with blockchain [47].In IoT devices, the “n” number of sensor nodes with the Atmega 328 controller, level sensors, and the LoRa modem is embedded in the bins. Moreover, the different sensors like load cell sensor, gas sensor, and temperature sensor can also be integrated into the sensor node for obtaining the continuous status of the bins. These sensor nodes are considered to be energy-constrained devices with low memory, storage, and processing capacity. Fog and edge node in the architecture is utilized. It acts as a local storage and processing unit for nearby IoT devices to minimize the latency and response period from the IoT device to the cloud. In this architecture, the fog nodes are capable of handling the accessibility of IoT devices. Moreover, fog node enables better scalability for IoT devices in memory, computation power, and storage to perform authentication and interlinking with the Ethereum network.The gateway is utilized for interconnecting the IoT devices to the cloud server with distinct communication protocols. Here, the gateway is integrated with a Wi-Fi modem for logging the data over Internet protocol (IP). The function of admins is to deregister and register IoT devices and fog nodes in the system, and admins allow the end-user to access IoT devices by making changes in the smart contract. Users like consumers, government, and NGOs request to grant smart contact for utilizing IoT devices. After receiving permission from the smart contract, the users approach the authorized fog node for access and validation. The cloud server acts as a computational and storage database for storing the IoT data, and further, the analytics are applied to the IoT data to obtain useful insights. The smart contract comprises a list of fog nodes with authentication rights and access for designated IoT devices. Here, the IoT devices consist of Ethereum address, but it does not directly interface with smart contracts. Like fog node and cloud node, the other participant has an Ethereum address and interlinks with a smart contract through an Ethereum client. The admins and users have Ethereum addresses and interlink with smart contracts through front-end applications.


### 4.2. Hardware Implementation

In the proposed architecture, the significance of sensor nodes and gateway is clearly presented. However, to implement the proposed architecture in real time, the realization of hardware is required. In this section, we present the hardware implementation of sensor node and gateway detailed. The hardware of sensor node and gateway is customized to our application. The customization enables the integration of components into the hardware prototype that fulfills the application requirements. Furthermore, it assists in connecting the multiple communication protocol on the single board for minimizing the connection failure by connecting the wires. The firmware development for customized hardware is convenient, as the controller integrated in the hardware is based on our selection. Generally, during the customization, the primary parameter considered is power consumption, because the sensor node is deployed in the outdoor environment, where powering sensor node is a bit challenging. So, each component embedded in the sensor node needs to be low power consumption one. Wireless communication protocol plays a crucial role in power consumption, so the low powered wireless communication protocol needs to be considered during transmission of data. Here, LoRa communication protocol is considered for sensor node and gateway as it consumes minimum power during transmission of data. Another major component that is considered during customization is controller. In this study, the complexity of processing data is very low, so ATMega 328P microcontroller is integrated in the sensor node and gateway. Moreover, to communicate the sensor data over the Internet, the gateway is integrated with ESP 8266 Wi-Fi module. ESP 8266 Wi-Fi module works on 2.4 GHz frequency, and it communicates the data into Internet protocol (IP) packets.As the major components like controller and communication protocol are chosen, the next stage is to integrate all those components on single board. For the same, Figure5 presents the components that are to be integrated for the sensor node. The main objective of this study is to initiate automatic reward system, and the reward system is executed on the basis of quantity of the waste available in the bins. To obtain quantity of the waste, we have integrated the load cell sensor in the sensor node. Load cell sensor transforms the load acting on it into an electric signal. Additionally, the level sensor is integrated for sensing the level of the waste in the bins. As the operating voltage of different components integrated to the sensor node is having different voltage, for that, we have integrated three power supplies, namely, +12 V, +5 V, and +3.3 V. The operating voltage of Atmega 328P controller and level sensor is +5 V, and that of the LoRa module is +3.3 V. Future Technology Devices International Limited (FTDI) port is embedded for uploading the firmware in the sensor node, and In Circuit Serial Programming (ICSP) is for programming the controller. The final hardware prototype of the sensor node is illustrated in Figure 5.Figure 5
Block diagram and hardware of sensor node. (a) Block diagram of sensor node. (b) Hardware of sensor node.
(a)(b)Figure6 illustrates the components that are integrated for the building the hardware of gateway. The Atmega 328 P controller and LoRa communication protocols are the same as those integrated in the sensor node. Additionally, to initiate Internet connectivity, ESP 8266 Wi-Fi module is integrated on the hardware. The ESP8266 Wi-Fi Module is a built-in TCP/IP protocol, which empowers the controller to have access to your Wi-Fi network. As discussed earlier about the operating voltage, the gateway has also integrated similar three power supplies, namely, +12 V, +5 V, and +3.3 V. The operating voltage of Atmega 328P controller and ESP 8266 Wi-Fi module is +5 V, and that of the LoRa module is +3.3 V. The function of ICSP and FTDI port is similar, as addressed in the sensor node. The final hardware prototype of the gateway is presented in Figure 6.Figure 6
Block diagram and hardware of gateway. (a) Block diagram of gateway. (b) Hardware of gateway.
(a)(b)


### 4.3. Blockchain Implementation through Local Network API

As the hardware implementation for the proposed architecture is developed, now, we will discuss the mechanism of intervene blockchain through local network application programming interface (API), and it is shown in Figure7. The mechanism comprises different components; namely, data source is a complete system that comprises IoT devices, edge node, fog node, gateway, and cloud server. The data received from IoT devices to the cloud server is attached to the blockchain through API. Here, entry data is considered as new transactions, and a new block is created. This transaction is put forward to distinct nodes for mining, and miners (node) are distinct entities presented in the SWM. The responsibility of the miners comes into the act as a transaction is created.Figure 7
Mechanism of blockchain interfacing with the cloud through API.Here, miners utilize the PoW algorithm by the nodes for validation. If the transaction is valid, then it is added to the chain of the new block. Moreover, the fog node validates the number of proofs done by nodes, and several chains resolved through consensus are also considered for validating the nodes. If the nodes are valid, the transaction is added to the new block and logged into the database.As the proposed system for SWM is based on a private blockchain, and it consists of a single organization for access to control the network, however, in the private blockchain, the additional participants are involved, and validation of their transactions can be performed by implementing the proposed method, as shown in Figure8. The ways for authentication of the miner nodes in private blockchain networks are still a matter of concern and are intuitive. Thus, our system introduces a security variable called Trust Point score, which is basically a uniquely generated key by the system to be used for rewarding the mining fog nodes based upon presentation of their proof of work (PoW) similar to the rewards awarded to the miner nodes in public blockchain networks. During the initial stage of deployment of the blockchain network, the system will initialize the Trust Point count for all its fog nodes as 1 and thereafter in each case of a successful submission of proof of work and/or finding the new block’s hash, the miner fog nodes will be rewarded with Trust Points. So, whenever any end node, i.e., bin, will send an update, initiate a transaction. The fog nodes that are free at that moment will start mining the new transaction using brute force and correspondingly will try to find the new transaction block and validate its hash. Upon findings, miner fog nodes will then present the proof of work along with their current possessed Trust Point score to the system. The system will then classify their presented proof of work as genuine or trivial based upon their Trust Point score, because only the genuine fog nodes that are already mining for the network will have a greater number of Trust Point score, but any suspicious intruder miner node cannot have a Trust Point score comparable to the genuine fog nodes, and thus, the system automatically ignores the suspicious miner node or stacks their opinion/solution into lower priority.Figure 8
Proposed method for verification of miners in private blockchain with trust point.As the miner is validated, and the trust point is rewarded, the system adds the mined block into the chain. Moreover, the transaction ledger is updated and logs the data into the private database (DB). Generally, in some cases, the new nodes are needed to add to the same blockchain network. In that case, we will follow this procedure, and it is as follows:We need to let a node know about nearby nodes in the network while implementing a Consensus algorithm. Every node in our network will establish a network registry of other nodes. So, we need a few more endpoints:/nodes/register to accept new nodes list in URL form./nodes/resolve to implement consensus algorithm, which addresses any disagreement to ensure the correct chain of a node.The first process avalid chain(), checks if a chain is valid, and examines both hash and evidence by looping through each node.resolve conflicts( ) is a process that loops, downloads, and uses the above process to verify all of our nearby nodes. In case if valid chain () value is higher than ours then it will be replaced.If you choose and switch various nodes on your network, you can now take another machine. Or switch processes on the same platform using various ports. Switch up to another node, on another port on our machine, and record it with our new node. Finally, the two nodeshttps://localhost:5000 and http://localhost:5001 are available.


## 4.1. IoT and Blockchain Architecture for SWM

In this section, we present the proposed architecture for SWM, where the IoT enabled hardware is integrated with blockchain. The proposed architecture is motivated from [47], it is shown in Figure 4, and it describes the mechanism of intervening the hardware IoT devices of SWM to the blockchain technology and the collection of information transmitting through the various nodes of the blockchain transparently and securely preserving the process’s traceability. In the architecture, major participants having access to Ethereum smart contracts through the Internet are fog nodes, users, admins, IoT devices, and cloud servers.Figure 4
Proposed architecture for intervening IoT enabled hardware with blockchain [47].In IoT devices, the “n” number of sensor nodes with the Atmega 328 controller, level sensors, and the LoRa modem is embedded in the bins. Moreover, the different sensors like load cell sensor, gas sensor, and temperature sensor can also be integrated into the sensor node for obtaining the continuous status of the bins. These sensor nodes are considered to be energy-constrained devices with low memory, storage, and processing capacity. Fog and edge node in the architecture is utilized. It acts as a local storage and processing unit for nearby IoT devices to minimize the latency and response period from the IoT device to the cloud. In this architecture, the fog nodes are capable of handling the accessibility of IoT devices. Moreover, fog node enables better scalability for IoT devices in memory, computation power, and storage to perform authentication and interlinking with the Ethereum network.The gateway is utilized for interconnecting the IoT devices to the cloud server with distinct communication protocols. Here, the gateway is integrated with a Wi-Fi modem for logging the data over Internet protocol (IP). The function of admins is to deregister and register IoT devices and fog nodes in the system, and admins allow the end-user to access IoT devices by making changes in the smart contract. Users like consumers, government, and NGOs request to grant smart contact for utilizing IoT devices. After receiving permission from the smart contract, the users approach the authorized fog node for access and validation. The cloud server acts as a computational and storage database for storing the IoT data, and further, the analytics are applied to the IoT data to obtain useful insights. The smart contract comprises a list of fog nodes with authentication rights and access for designated IoT devices. Here, the IoT devices consist of Ethereum address, but it does not directly interface with smart contracts. Like fog node and cloud node, the other participant has an Ethereum address and interlinks with a smart contract through an Ethereum client. The admins and users have Ethereum addresses and interlink with smart contracts through front-end applications.


## 4.2. Hardware Implementation

In the proposed architecture, the significance of sensor nodes and gateway is clearly presented. However, to implement the proposed architecture in real time, the realization of hardware is required. In this section, we present the hardware implementation of sensor node and gateway detailed. The hardware of sensor node and gateway is customized to our application. The customization enables the integration of components into the hardware prototype that fulfills the application requirements. Furthermore, it assists in connecting the multiple communication protocol on the single board for minimizing the connection failure by connecting the wires. The firmware development for customized hardware is convenient, as the controller integrated in the hardware is based on our selection. Generally, during the customization, the primary parameter considered is power consumption, because the sensor node is deployed in the outdoor environment, where powering sensor node is a bit challenging. So, each component embedded in the sensor node needs to be low power consumption one. Wireless communication protocol plays a crucial role in power consumption, so the low powered wireless communication protocol needs to be considered during transmission of data. Here, LoRa communication protocol is considered for sensor node and gateway as it consumes minimum power during transmission of data. Another major component that is considered during customization is controller. In this study, the complexity of processing data is very low, so ATMega 328P microcontroller is integrated in the sensor node and gateway. Moreover, to communicate the sensor data over the Internet, the gateway is integrated with ESP 8266 Wi-Fi module. ESP 8266 Wi-Fi module works on 2.4 GHz frequency, and it communicates the data into Internet protocol (IP) packets.As the major components like controller and communication protocol are chosen, the next stage is to integrate all those components on single board. For the same, Figure5 presents the components that are to be integrated for the sensor node. The main objective of this study is to initiate automatic reward system, and the reward system is executed on the basis of quantity of the waste available in the bins. To obtain quantity of the waste, we have integrated the load cell sensor in the sensor node. Load cell sensor transforms the load acting on it into an electric signal. Additionally, the level sensor is integrated for sensing the level of the waste in the bins. As the operating voltage of different components integrated to the sensor node is having different voltage, for that, we have integrated three power supplies, namely, +12 V, +5 V, and +3.3 V. The operating voltage of Atmega 328P controller and level sensor is +5 V, and that of the LoRa module is +3.3 V. Future Technology Devices International Limited (FTDI) port is embedded for uploading the firmware in the sensor node, and In Circuit Serial Programming (ICSP) is for programming the controller. The final hardware prototype of the sensor node is illustrated in Figure 5.Figure 5
Block diagram and hardware of sensor node. (a) Block diagram of sensor node. (b) Hardware of sensor node.
(a)(b)Figure6 illustrates the components that are integrated for the building the hardware of gateway. The Atmega 328 P controller and LoRa communication protocols are the same as those integrated in the sensor node. Additionally, to initiate Internet connectivity, ESP 8266 Wi-Fi module is integrated on the hardware. The ESP8266 Wi-Fi Module is a built-in TCP/IP protocol, which empowers the controller to have access to your Wi-Fi network. As discussed earlier about the operating voltage, the gateway has also integrated similar three power supplies, namely, +12 V, +5 V, and +3.3 V. The operating voltage of Atmega 328P controller and ESP 8266 Wi-Fi module is +5 V, and that of the LoRa module is +3.3 V. The function of ICSP and FTDI port is similar, as addressed in the sensor node. The final hardware prototype of the gateway is presented in Figure 6.Figure 6
Block diagram and hardware of gateway. (a) Block diagram of gateway. (b) Hardware of gateway.
(a)(b)


## 4.3. Blockchain Implementation through Local Network API

As the hardware implementation for the proposed architecture is developed, now, we will discuss the mechanism of intervene blockchain through local network application programming interface (API), and it is shown in Figure7. The mechanism comprises different components; namely, data source is a complete system that comprises IoT devices, edge node, fog node, gateway, and cloud server. The data received from IoT devices to the cloud server is attached to the blockchain through API. Here, entry data is considered as new transactions, and a new block is created. This transaction is put forward to distinct nodes for mining, and miners (node) are distinct entities presented in the SWM. The responsibility of the miners comes into the act as a transaction is created.Figure 7
Mechanism of blockchain interfacing with the cloud through API.Here, miners utilize the PoW algorithm by the nodes for validation. If the transaction is valid, then it is added to the chain of the new block. Moreover, the fog node validates the number of proofs done by nodes, and several chains resolved through consensus are also considered for validating the nodes. If the nodes are valid, the transaction is added to the new block and logged into the database.As the proposed system for SWM is based on a private blockchain, and it consists of a single organization for access to control the network, however, in the private blockchain, the additional participants are involved, and validation of their transactions can be performed by implementing the proposed method, as shown in Figure8. The ways for authentication of the miner nodes in private blockchain networks are still a matter of concern and are intuitive. Thus, our system introduces a security variable called Trust Point score, which is basically a uniquely generated key by the system to be used for rewarding the mining fog nodes based upon presentation of their proof of work (PoW) similar to the rewards awarded to the miner nodes in public blockchain networks. During the initial stage of deployment of the blockchain network, the system will initialize the Trust Point count for all its fog nodes as 1 and thereafter in each case of a successful submission of proof of work and/or finding the new block’s hash, the miner fog nodes will be rewarded with Trust Points. So, whenever any end node, i.e., bin, will send an update, initiate a transaction. The fog nodes that are free at that moment will start mining the new transaction using brute force and correspondingly will try to find the new transaction block and validate its hash. Upon findings, miner fog nodes will then present the proof of work along with their current possessed Trust Point score to the system. The system will then classify their presented proof of work as genuine or trivial based upon their Trust Point score, because only the genuine fog nodes that are already mining for the network will have a greater number of Trust Point score, but any suspicious intruder miner node cannot have a Trust Point score comparable to the genuine fog nodes, and thus, the system automatically ignores the suspicious miner node or stacks their opinion/solution into lower priority.Figure 8
Proposed method for verification of miners in private blockchain with trust point.As the miner is validated, and the trust point is rewarded, the system adds the mined block into the chain. Moreover, the transaction ledger is updated and logs the data into the private database (DB). Generally, in some cases, the new nodes are needed to add to the same blockchain network. In that case, we will follow this procedure, and it is as follows:We need to let a node know about nearby nodes in the network while implementing a Consensus algorithm. Every node in our network will establish a network registry of other nodes. So, we need a few more endpoints:/nodes/register to accept new nodes list in URL form./nodes/resolve to implement consensus algorithm, which addresses any disagreement to ensure the correct chain of a node.The first process avalid chain(), checks if a chain is valid, and examines both hash and evidence by looping through each node.resolve conflicts( ) is a process that loops, downloads, and uses the above process to verify all of our nearby nodes. In case if valid chain () value is higher than ours then it will be replaced.If you choose and switch various nodes on your network, you can now take another machine. Or switch processes on the same platform using various ports. Switch up to another node, on another port on our machine, and record it with our new node. Finally, the two nodeshttps://localhost:5000 and http://localhost:5001 are available.


## 5. Real Time Implementation with Results

In this section, the real time implementation of proposed architecture is presented in detail. Moreover, the results are presented in this section. The proposed system was built on a system with a configuration such as Intel Core i5-8250U CPU@ 1.60 GHz (8 CPUs), ∼1.8 GHz with memory 12288 MB RAM running on a Windows 10 Pro 64-bit based system. Our proposed system for implementation of an automatic reward system for solid waste management is developed using Python programming language as the data structure and algorithmic base architecture. The local web server and all the local network requests for distributed network architecture’s executions like new transaction initiation, mining, chain fetching, etc. were built upon a python-based server framework called a flask. For the testing, development, and debugging of all the proposed system components, the VS code editor was used. Similarly, for testing the APIs built for network executions, Postman was used, and the same images are attached in the following sections.As a part of real time implementation, the sensor node and gateway are designed with Atmega 328P microcontroller and long range (LoRa) communication capability. Here, the sensor nodes are integrated with ultrasonic sensor and load cell sensor for sensing the level and quantity of waste in the bin. Based on the quantity of the waste in the bin, the reward system will be executed. The gateway acts as a bridge for interconnecting and transmitting the sensory data from sensor node to the cloud server over LoRa and Internet. The gateway is able to receive the sensory data from the sensor node as it is also integrating with LoRa communication.Moreover, the gateway transmits the sensory information to the cloud server over Internet as it is integrated with Wi-Fi module in it. Figure9 illustrates the real-time implementation of the proposed system, where the four sensor nodes are embedded in the bins to sense the bins’ level and weight parameters. As sensor nodes are integrated with LoRa communication, it sends the data to the gateway. The gateway, with the assistance of Internet connectivity, logs the data into the cloud server. Now, it is the task of API to interconnect the cloud server with the blockchain network. Here, we have utilized a Python-based flask framework for creating a web API to realize the proposed reward system. Flask framework is a microframework that conveniently maps the endpoints to Python functions, allowing us to interact with our blockchain through HTTP requests [48]. GET and POST are two different HTTP methods utilized in the web API [49]. Here, we follow three methods for creating transactions and mining a new block, and they are presented in Table 2:Figure 9
Real-time implementation of hardware.Table 2
Steps followed for creating transactions.
transactions/new to generate a new transaction to a block/mine to inform our server to mine a new block/chain to return the full blockchainNow, the flask server will form a single node in the blockchain network, and the following are included in the flask server, and they are shown in Table3.Table 3
Steps followed included in flask server.
Instantiates our NodeCreate a random name for our nodeInstantiate our Blockchain classBuild the /mine endpoint, which is a GET requestBuild the /transactions/new endpoint, which is a POST request, since we’ll be sending data to itBuild the /chain endpoint, which returns the full blockchainRuns the server on port 5000The flask server is created and runs blockchain for performing transactions of SWM, as shown in Figure10. The part “a” in Figure 10 is the functions of building a blockchain. After building the blockchain, the hash algorithm is also created, and it is shown in part “b.” As blockchain receives the data regarding the quantity of the waste from the IoT devices, the blockchain creates a block with the functions available in part “c.” At the same time, a new transaction is created with the functions present in the part “d.” During creating the function of the transaction, the following parameters are included, and they are shown in Table 4.Figure 10
Functions for performing blockchain. (a) Building blockchain. (b) Hash algorithm. (c) Creating a block. (d) Creating a transaction. (e) Proof of work.
(a)(b)(c)(d)(e)Table 4
Parameters included for creating transaction function.
inspectorID: Address of the inspectoruser: Address of the user recipientWeight: weightPart “e” presents the PoW consensus for validating the transaction by a miner. Here, miner evaluates the transaction based on the instructions available in the function. Figure11 presents the transaction that the miner validates. The quantity of the waste of the bins is displaying in the flask server. Figure 11 visualizes adding the new transaction through POST and mining the node with GET. The following are the related procedures for interacting with our blockchain, and they are presented in Table 5.Figure 11
Blockchain visualizing the quantity of waste. As addressed earlier, the automatic reward system is generated on the basis of weight obtained from the different bins.Table 5
Interfacing blockchain.
Interaction with blockchainTo interface with our API over a network, utilize plain old cURL orpostman and a start-up server.Mining a block by creating aGET request to https://localhost:5000/mineCreating a new transaction by placing aPOST request to https://localhost:5000/transactions/newHere, the load cell sensor value from the sensor node is received in terms of kilo grams (kg). During mining the node, the quantity of waste as “weight” is visualized, where the weight of the bins is presented as 2.9 kg, 3.8 kg, and it can be seen in Figure11. The procedure of automatic reward system is presented in Figure 12. Basically, blockchain technology is decentralized network, where the users or participants are connected decentralized manner. In the figure, the user might be anyone of three participants, namely, A, B, and C. For example, here, we considered “A” as the user, where the information regarding the amount of waste occupied in the bins is distributed in a decentralized manner. As we discussed earlier, the public key consists of information regarding the sender and receiver. Here, “A” has already distributed the data in a decentralized manner; now, miners of “B” and “C” evaluate the received information based on public key. As the information sent by “A” consists of “B” public key, then the miners of “C” ignore the information received. Now, miners of “B” evaluate the information based on distinct parameters like bin ID and quantity of the waste. After the evaluation by miners, based on the quantity of the waste, the blockchain executes the amount to “A.”Figure 12
Procedure of automatic reward system.


## 6. Conclusion

Blockchain technology is playing a significant role in the modern world with its security and transparency capability. We have implemented blockchain in the SWM for realizing the automatic reward system to the individuals for disposing of waste in the bins. The automatic reward system is executed based on real-time monitoring of data from the IoT devices of the bins. IoT devices are the integration of sensor nodes, which are customized and embedded in the bins. This sensor node communicates the real-time data to the cloud server via a gateway. A mechanism is implemented for integrating the cloud server with a blockchain network through Flask server-based API. In the real-time implementation, it is observed that the weight of the bins is creating new transactions in the blockchain network. Moreover, we have proposed a method for verifying miners in private blockchain with a trust point concept addressed in the study.



---

*Source: 6952121-2021-09-06.xml*