# Blockchain-Based Cloud-Enabled Security Monitoring Using Internet of Things in Smart Agriculture
## 5 Proposed Approach  
The proposed approach improves smart agriculture/farming monitoring and security by incorporating technologies in multi layers of the smart-agriculture architecture. Internet of Things (IoT) technology was added near farming premises to connect with the internet and add intelligence. Cloud technology is used in the data processing layer to support the solution's scalability and achieve production-level performance. The Ethereum blockchain is used in another layer to run the smart contract and trigger events when anomalies are identified during the smart-agriculture security monitoring. Figure 2 illustrates the layer-wise architecture of the proposed approach. The smart-farm layer contains various sensor devices in the farming premises for different purposes. A smart-agriculture community is formed with IoT sensor devices installed on every piece of farmland. These sensor devices constantly generate events such as device health, device data, etc. The generated events are transmitted to the cloud using an edge gateway or routing device connected to the sensor device. The cloud layer consists of components constantly listening to the sensor events and processing the event data to retrieve the intended information. MQTT is the typical protocol for passing the data in packets from one end to the other. We defined a lambda function in the AWS cloud to parse the data from the AWS IoT core component and extract the required data from the sensor devices connected to the farms. Whenever the lambda function logic determines the security alert observed from the sensor generating data, the lambda function performs POST request infura API to update the Ethereum blockchain. The updated transaction may include the sensor data anomaly values, status of the device, etc.The blockchain contains Ethereum nodes distributed across the network operated by an individual to perform the mining, or someone uses the Ethereum full node for their transaction processing. The infura runs Ethereum nodes and provides APIs to update the transactions from the user's accounts if they have an account with them. The updated blockchain transactions will be updated to all the nodes in the Ethereum network. Although the user layer is not shown in Figure 2, the GUI interface can read the Ethereum node transactions using API calls and display the details in the GUI when the user wants to see the smart-agriculture alerts. The description of the main components used in the proposed approach is discussed in the following paragraph. AWS IoT core: A number of IoT sensing devices exist in the smart-farming environment. An IoT message-processing infrastructure is needed to support the IoT message protocols such as MQTT and accommodates the network bandwidth to collect messages from numerous IoT devices. We selected AWS IoT core service to perform the smart-agriculture IoT data processing. The AWS IoT core offers low latency and high throughput performance, and these characteristics support the build of real-time production-level IoT monitoring systems. AWS Lambda: The collected IoT data should be processed and given as input data to the Ethereum blockchain. Therefore, the AWS Lambda runs the code in the backend and stores the smart-farming information in the Blockchain. AWS Lambda is a serverless computing service to run code virtually without provisioning the server infrastructure. Infura API: We did not rely on deploying the Ethereum full node to create and run the farming smart contracts. Infura is an Ethereum API service to run smart contracts in Ethereum nodes and perform Ethereum-based transactions. We leverage the Infura API calls to interact with Ethereum nodes once we collect and process the farming sensor data. Ethereum: We implement the Ethereum-based smart contract to store the farming sensor data and check the farming environment conditions. The Ethereum first version works on the proof-of-stake (POS) consensus mechanism to approve and add the transactions to the Ethereum blockchain.