IoT with BlockChain: A Futuristic Approach in Agriculture and Food Supply Chain

IQRA National University, Peshawar, Pakistan Department of Computer and Information Science, University of Macau, Macau ETS, Higher Colleges of Technology Dubai Women College, UAE Department of Computer Science, Islamia College Peshawar, Peshawar 25120, Pakistan Institute of Computing, Kohat University of Science and Technology, Kohat 26000, Pakistan Department of Information Technology, College of Computers and Information Technology, Taif University, P.O.Box 11099, Taif 21944, Saudi Arabia Department of Computer Science, College of Computers and Information Technology, Taif University, P.O. Box 11099, Taif 21944, Saudi Arabia


Introduction
The United Nations Population Division expects the world population, currently 7.8 billion (2020), to reach 10.9 billion after the end of the 21st century [1]. Due to rapid population growth, there is a high pressure on agriculture to increase food production sustainably. Food distribution and consumption simultaneously promote human well-being and preserves scarce natural resources. As a result, policymakers, development agencies, civil society organizations, and private enterprises have shown interest in investigating the role of the food and farm markets in supporting sustainable development for people and the world [2]. Agriculture is experiencing drastic changes and is facing numerous environmental and social problems. Many farmers are still depending on traditional farming practices and having no direct access to the market, and it has proven difficult to balance the demands on limited natural resources such as land and water. Both changes in diets and consumer preferences and the fact of climate change contribute to the complexity of providing high-quality food to the end-user. Sustainable food and agricultural production cannot be accomplished by the conventional agriculture systems that have led to substantial deforestation, water scarcity, or soil erosion. Thus, advanced systems must be used which conserve and reinforce the basis of natural resources and increase production. A phase of transition to "holistic" methods is like smart agriculture [3]. Smart agriculture is an approach that guides agricultural field supervision in the era of climate change. The idea of smart agriculture was first introduced in 2009 and revived through the involvement and input of many stakeholders involved in design and implementation. In response to the debate on agricultural policy on climate change and sustainable development work, the main features of the smart agriculture approach have been developed. [4]. Smart agriculture aims to provide universally applicable systems for climate change management and agricultural food security. Smart agriculture uses advanced technologies such as the Internet of Things (IoT), big data, and cloud computing to monitor the field environment, analyze crop growth, and provide information to the farmer for decisionmaking. An information-based management cycle for smart agriculture is presented in Figure 1. [5].
1.1. Internet of Things (IoT). The Internet of Things (IoT) is a cutting-edge computing and networking technology that reflects the future. Smart computing will be focused on the Internet of Things in the future. IoT is now playing a significant role in the transformation of existing technologies from the home to the workplace [6]. IoT technology is used to link computers or nodes to networks for the sharing of information and communication [7]. The Internet of Things (IoT) has the potential to link billions of devices (smart objects). These smart objects can gather data and interact with other systems over the internet. IoT has evolved into a next generation technology with several agricultural applications [8].
1.2. Internet of Things in Smart Agriculture. In the field of smart agriculture IoT provides a wide range of applications such as soil and plant tracking, crop growth observation, and selection, assistance for irrigation assessment, and monitoring of the agriculture environment. In smart agriculture Internet of Things (IoT) technology is applied in diagnostics and control. To optimize agriculture, the implementation of IoT in the field has increased the productivity and effectiveness of farmers. It may help to determine field variables such as soil quality and plant biomass. It can also be used to test and monitor variables including temperature, soil moisture, and crop diseases. Besides, IoT can be used to track crop growth and yield influencing factors. Farmers can also figure out which crops are most suited for which conditions and can rotate crop accordingly [9]. IoT applications support farmers during crop planting, irrigation, crop processing, harvesting and postharvest, crop storage and transportation, and many other benefits in agricultural IoT systems. Soil moisture sensors, humidity sensors, leaf moisture sensors, solar radiation sensors, infrared light sensors, and rainfall predictors are among the field sensors used in IoT-based systems. In IoT scenarios, sensors can be installed in a variety of locations, including greenhouses, seed banks, cold rooms, agricultural machinery, transportation systems, and livestock, and the data collected can be processed in the cloud for monitoring and control [10].
1.3. Food Supply Chain Management. Food supply chain management is a process that explains how food from an agricultural field ends up on our tables. Supply chain management deals with production, refining, delivery, selling consumption, and disposal [11]. The process of the supply chain is summarized in Figure 2. In developing countries, the food supply chain faces several challenges, such as the need for confidence among stakeholders which often correlated with their credibility and traceability required by the end-users, and the difficulty of managing risks, delays, or disruptions is often occurred due to insufficient or lacking information [12]. Blockchain technology is one of the best ways to meet these challenges [13].

Blockchain Technology.
Blockchain is a distributed database where data can be recorded and shared via a decentralized computing network while also providing security and privacy. And if the data is spread, only the owner who has the private key can make transactions. The other machines or computers on the network serve as validators. It safely records transactions between nodes in a public ledger without the need for a trusted third party [14]. In a centralized cloud approach where an asset or object is owned, it is either held under the control of the owner or through a trusted intermediary or a centralized authority such as a bank. A centralized computing system always has a single server for several clients, the server has higher resources than its client systems, and all processes are made through a single server which now has become a traditional approach [15]. Blockchain records transactions in block units, and every block includes the hash of the block history, hash of the current block, date, other details, and transactions for the block. When a sender node makes a transaction, it distributes it to the other nodes on the network. The receiving nodes verify the transaction and have proof of work. The node that succeeds in the proof of work will broadcast it to all the other nodes and connect the block to the chain. The transaction shall contain the public key of the recipient and shall be signed by the sender. Therefore, any other node will verify the validity of the transaction. Each block includes a hash of the previous block, which means that each block is connected to each other [16]. The key characteristics of blockchain are shown in Figure 3 [17].
Because of its unique characteristics, blockchain may be an evolutionary next step in the food supply chain also to add accountability to the supply chain system by exchanging accurate data between supply chain stakeholders. After the integration of IoT with blockchain, the overall visibility of food products across the supply chain will become a reality. The major advantages of blockchain and IoT in the food supply chain are real-time monitoring and sensing of original food items from the origin which identify major bottlenecks.

Wireless Communications and Mobile Computing
As in the agricultural sector, farmers use chemical fertilizers, insecticides, and other materials to increase crop production, especially vegetable growers often use harmful pesticides to spray vegetables to improve their profitability, and consumers buy the same vegetables to eat which is a major health hazard. Secondly, food frauds and data alternation are also big challenges for supply chain stakeholders.

Blockchain in Food Supply
Chain. Blockchain is an emerging technology for the agriculture sector, applying blockchain to the agricultural supply chain provides a digital database that monitors, tracks records, and processes digital and physical resources. Blockchain allows greater traceability and higher quality transactions. This technology can manage and integrate all procedures and dealings in real-time across the agricultural supply chain. Every transaction treated in a distributed manner may contain productspecific attributes and transactions that will be added by players in the supply chain. The supply chain players can recognize and investigate the association of products along with all stages of the supply chain and zoological technology practices (fertilizers, feed, and veterinary services [18]. The blockchain stores invariant records that are transparent and digitally accessible to all users in the supply chain; this technology has the potential to produce massive efficiency gains for each actor. The blockchain offers a forum for traceability in the agricultural supply chain, allowing endusers to monitor product from origins and ensure their authenticity. Figure 4 illustrates the benefits of using blockchain in the food supply chain. The ability to monitor a 3 Wireless Communications and Mobile Computing product's movements allows for legal liability for infringement on the product's authenticity, making regulation easier to regulate. The blockchain keeps the mechanism and the data connected at all times [19].
1.6. IoT Integration with the Blockchain. Industry 4.0 has shown that the Internet of Things is a fundamental technology and a key player in the digital revolution. In different network topologies, IoT is expected to depend more on sensing devices, a wide range of data, and more connected devices. As a result, it must be referred to as the Internet of Things 2.0.
The Internet of Things 2.0 is now transitioning away from sensors and data technology and toward actionable intelligence technology [20]. IoT becomes more efficient when it is combined with cloud computing, artificial intelligence, and machine learning [21]. Integration of blockchain technology with IoT is another significant contribution to the digital transformation of various domains. By integrating with IoT, blockchain is projected to add $176 billion to the global economy by 2025 and $3 trillion by 2030 [22].

Wireless Communications and Mobile Computing
In the present world, the problem of health and food safety is deteriorating day by day because a proper food traceability system is not available. The biggest reason for foodborne disease is contamination which is hard to track in the conventional food supply chain because the mechanism is not visible [23]. However, IoT with a blockchain system will fix the problem by creating a distributed system and eliminating the third party participating in the system at the same time. Consumers have questions about the nature of the food products they purchase and the sources of the product they buy in the conventional supply chain. The key point here is to create customer interest, which is difficult to do as the system is not open. By building customer confidence, IoT and blockchain technology could eradicate these issues. Each product has a digital identity in this framework, which stores information from the point of origin up to the end of the retailer [24]. IoT with blockchain can provide a more transparent and connected system.

Communication Protocols.
Communication protocols have been commonly used in various types of networks to improve communication efficiency. The LoRaWAN protocol was created to migrate data from sensor nodes and the IoT network platform that introduced the LoRaWAN backend service to the cloud for data sharing. In terms of integrating with other IoT systems and introducing new services, the planned framework was scalable and versatile. It is also horizontally scalable, which means it can improve efficiency by replicating new server occurrences [25]. Heizelmann created the low-energy adaptive wireless sensor network routing LEACH protocol, which was the first hierarchical clusterbased routing protocol for a wireless sensor network. The protocol nodes had been distributed across clusters, and each cluster had its head (CH). Member nodes of cluster sensory data share them via their selected CHs with the base station. Smart agriculture has been able to ensure that it not only meets the general needs of crops but also anticipates their specific needs, taking into account a variety of environmental factors. The challenge is to accurately predict potential crop losses to take appropriate measures. IoT nodes enable efficient routing protocols to obtain data and share information with farmers [26].

Literature Review
This section provides a thorough review of the related literature.

Review on IoT in Smart
Agriculture. In paper [26], the authors proposed a smart agriculture system to provide information on soil, water supply, and the general state of the field to farmers. The objective of the proposed system was to make agriculture and irrigation more efficient and to make it easier for farmers to take appropriate decisions to increase agricultural production. The use of IoT networks to monitor environmental factors and the combination of this information with a user-specific web service enables farmers to make effective use of their knowledge to obtain the best results from their agriculture. In paper [27], researchers have developed an IoT-based agriculture data analysis system using IoT devices such as environmental field real-time monitoring sensors. The field observation was collected and transferred to the farmers through a web-based application with the help of a node and a Wi-Fi module. The system consists of sensors such as a soil moisture sensor and an ultrasonic sensor. The system has a low cost but uses high energy. The authors of the paper [28] used IoT to build a smart agriculture system for Indian farmers. Farmers in India have begun to commit suicide as a result of low agricultural output. To address this problem, an IoT-based smart agriculture system was created that uses a variety of sensors to monitor pests and soil moisture. Crop distribution companies were also involved in providing high-quality seeds to farmers to boost yields. The system architecture, on the other hand, is extremely durable, but it comes at a high price.
Researchers explored the potential benefits of using smart agriculture technologies such as smart soil and air sensors in paper [29], to assist farmers by covering the initial installation costs and providing smart farming advice through the integrated use of heterogeneous information sources. The work helped farmers in growing their ecological footprint by providing opportunities for innovation targeting and climate change adaptation options. The authors of the paper [30] used sophisticated Internet of Thing (IoT) agricultural applications to make accurate measurements, using sensor data from 60 scientific papers published between 2016 and 2018. Previous research has shown the importance of smart agriculture in water, grain, livestock, and irrigation management. When it came to sensor data collection, the best results were obtained when calculating temperature and humidity. Sensors for soil moisture and soil reaction are also available.

Review on Blockchain in the Supply Chain.
Researchers in the paper [31] proposed a theoretical model to investigate the impact of blockchain on operational supply chain transparency and collaboration by establishing rapid trust between key partners involved in disaster relief supply chains. Collaboration enables stakeholders to work together, leads to productive and efficient real-time information exchange between partners, and provides many benefits such as increased transparency, flexibility, and reduced lead-time, as well as helping to improve supply chain resilience. The authors of the paper 5 Wireless Communications and Mobile Computing [32] suggested blockchain adoption as a way to improve the entire supply chain, from safe, accurate, and open transactions to increasing supply chain participants' trust and efficiency by exchanging all transactions and related information across the entire network. The authors of [14] focused on weakening supply chain resilience in the era of information asymmetry, which occurs when one of the supply chain's members has significantly more product information than the others. They admitted that data inaccuracies or discrepancies might lead to incorrect decisions and an increase in technological risks including cybercrime, hacking, and theft, both of which could harm the company's credibility. One of these solutions, according to the writers, is establishing "confidence" among supply chain participants using a decentralized information sharing framework based on blockchain technology.

Motivation.
In terms of technology, although the literature in smart agriculture using IoT is very rich, there is still a gap for improvement, whereas the use of blockchain technology in the food supply system literature is very limited. Besides, no solid research papers are published yet using a combination of IoT and blockchain technology for agriculture and food supply systems for addressing the information reliability issues. Most of the solutions are ad hoc-based or work separately. Limitations in the existing literature motivated us to develop a futuristic smart model based on smart technologies to meet the requirements of all stakeholders involved in agriculture and food supply chain by using IoT with blockchain technology through which traceability management can be applied through the food supply chain and addresses the main centralized format challenge that is asymmetric, opaque, and monopolistic. These limitations have driven us to build a distributed, efficient, and safe system to enhance crop production, ensure the end-to-end traceability of food products, and stop food fraud in the supply chain. The goal would be to develop a distributed and automatic agriculture food supply chain traceability model that enables various quality levels to be implemented based on consumer needs. The model that not only uses transaction data but also smart contract and enables end-to-end traceability and data security.

Materials and Methods
This section presents the smart model architecture and smart model protocol design.
3.1. Smart Model Architecture. As shown in Figure 6, a futuristic smart model for agricultural environmental monitoring and food supply chain consists of three layers: physical data layer, logical data layer, and web interface layer. This type of layered approach allows for scalable, extendable, and efficient framework implementation. In the physical data layer, a variety of IoT nodes are used to track the farm environment and crop growth. IoT nodes collect data from the cluster farm and send it to the base station via IoT gateway and wireless router, which then sends it to the database. A GPRS router is integrated into a single central board device that serves as a remote Radio Frequency Gateway (RFG) for wireless telem-etry. To achieve effective control management and synchronization of two relatively unrelated data sources, data collection through IoT nodes for soil parameters and IoT crop monitoring information, the RFG gateway acts as a coordinator between two separate data streams and supports remote access, allowing for complete remote control of devices in the cluster farm. The logical data layer in an SQL database server stores the data obtained from the cluster farm. The SQL server, as a more intermediate layer, covers the complexity of multiple physical layer devices and allows database server data validation. Raw data is stored in the SQL database, which is then extracted to a local file system.
Energy is the core part of every network, and energy conservation is one of the key objectives of this research. To reduce energy consumption, this research proposed an IoTbased agriculture protocol that can be divided into three phases: IoT nodes, IoT cluster head, and sink. IoT nodes gathered data and transferred it to CH in the first phase, CH broadcasted information to sink in the second phase, and sink transferred data to the base station in the third phase. This research work implements an RFG server using a robust ultra-low-power Single Board Chip to seamlessly combine a variety of devices in the cluster farm (SBC TS-7260). The monitoring system switches between active and sleep mode automatically. The optional battery backup module supports the SBC sleep mode, which also operates with a built-in uninterrupted power supply (UPS). Different devices in the cluster farm are normally equipped with an RS232 serial port. Wireless routers are switched off during the system's sleep cycle to conserve electricity. SQL server obtains data by either pull or pushes operations. In a pull method, SQL server connects to the data source regularly and extracts the data. In a push operation, this server opens a port through which data can be passed through the data source. This design allows the server to adapt to different data source types with ease. The data was sent to the SQL server. The data manager may also require the RFG server to recollect data and retransfer data packets that were omitted. For each new data source, a new data manager is included with limited modifications to the database and web visualization layers, improving extensibility. Specific IoT identification codes link the nodes and observations. As a consequence, once they are linked to the database, the web application layer will recognize them right away. This design allows for flexible model development and web interface design. It also allows for data conversion to IoT networks, allowing for data sharing and interoperability between IoT devices through web services.

BlockChain Integration with IoT in the Smart Model.
Exclusive blockchain characteristics will combine agricultural and food supply chain processes into a single smart system to ensure that consumers receive healthy food. Figure 7 shows a functional overview of the blockchain.
The role of stakeholders in the overall system is also discussed. The research used blockchain smart contracts to exchange data between mining nodes in the system. All business transactions are recorded in the shared ledger by mining nodes, and smart contracts receive all transactions in the blockchain in the form of function calls and generate 6 Wireless Communications and Mobile Computing activities, as well as providing access to parties involved in the transaction to exchange control track and receive alerts in the event of a violation. Finally, smart contracts help to maintain the best conditions and respond to food supply chain misappropriations.

Seed Seller.
Seed sellers, also known as seed vendors, organize and produce a wide range of seeds before selling them to farmers. They are obligated to sell high-quality seeds to growers to produce a high-quality crop. The seed seller uses blockchain to store information about seed germination and chemical composition, which all stakeholders can access and share. Seeds are stamped with a unique number, similar to serialized Global Trade Identification Numbers, that allows all parties to be electronically identified and track products in the seed trade.

Farmer.
A farmer is someone who buys high-quality seeds and plants them. The farmer is responsible for recording information about fertilizers use and plant growth data in the form of MPEG files in the IPFS, where different nodes keep the data with high reliability throughout the entire pro-cess from planting to harvesting. Farmers can also use blockchain to communicate with crop buyers and sell their crops without relying on middlemen, who often get profit by mediating between sellers and buyers.

Crop Buyer.
Crop buyer is a company that buys crop or a grain from a farmer and sells it to a processor.

Processor.
The processor buys grain that does a moisture analysis to convert the raw grain to the final product. The processor is responsible for all operations in the blockchain where other players in the supply chain have access to this information.

Crop
Storage. The storing of crops or grains is an important and unavoidable part of the crop production process and supply chain process. In warehouse, grains or crops are stored, and information is recorded in the blockchain where supply chain stakeholders can view and exchange this information. IoT-based agriculture protocol Information management Figure 6: IoT and blockchain smart model.   Wireless Communications and Mobile Computing 3.2.6. Distributor. Distributors have a business arrangement with the suppliers or producers. Many distributors maintain exclusive purchasing agreements which limit or allow distributors to cover a certain area through the number of participants. The distributor is the producer's exclusive point of contact with prospective purchasers of those products. Distributors, though, seldom sell the goods of the manufacturer directly to the retailer. Distributors tend to work with wholesale agents who may buy large quantities of one commodity regardless of the very large quantity of one commodity they have on hand or can purchase from the manufacturer. The distributor is responsible for registering all food product information in the blockchain.
3.2.7. Retailer. Retailers are profit-making companies that directly sell products to consumers. Retailers search for products that suit their market objectives and find vendors at the most advantageous prices to make a profit. Generally, small quantities of an item can be ordered from a distributor by a retailer. In this setup, the retailer orders goods in batches of traceable identifiers which make it easy for the customer to verify product life cycle records.

Customer.
The customer is the final user of the food product who purchases the food product from the retailer. This research smart model provides full access to the customer to trace production information from the origin to the sale point. In this setup, all supply chain stakeholders are bound to digitally sign blockchain smart contracts and to record information fairly and in case of dishonest blockchain automatically configure the incident into smart contracts to fine the concerned party. Another option is to install cameras in the field to automatically capture and transfer images to the blockchain for preaudit. The advantage of using product traceability technology in the food supply chain is the availability of reliable and real-time information to all stakeholders.

3.3.
IoT-Based Agriculture Protocol for the Smart Model. IoT nodes are ideal for cluster farms because they consume less energy than WSN and can be further reduced through an efficient clustering protocol. Therefore, this research proposed a new clustering protocol IoT-based agriculture, as shown in Figure 8, based on the LEACH protocol, to reduce energy consumption and extend network life.

Assumption for Simulation.
Assumptions for simulation are given below.
(i) IoT nodes are installed on a cluster farm randomly (ii) IoT nodes send hello messages to the base station with local information (iii) The initial number of clusters is calculated by taking the optimal values to vary with the node density before the node starts to expire, and the smaller clusters become larger clusters (iv) The base station and sink are installed outside the cluster farm as presented in Figure 9 3.3.2. Initialization Phase. A cluster farm with a total area of 500 × 500 m 2 was chosen and distributed into clusters, with 100 IoT nodes placed in each cluster at random. The IoT nodes were chosen based on their capabilities, such as soil moisture monitoring, temperature monitoring, and crop disease tracking. Nodes in clusters are distributed in such a way that one cluster node does not communicate with other cluster nodes, but only with the cluster heads of their respective clusters. Each cluster's CH is in charge of sharing sensed data with the BS via the sink node. To achieve a satisfactory SNR, a widely used LEACH "First Order Radio Model" is used to transmit a small message over a distance of d. Figure 10 and Table 1, the first order radio model dissipates E elec = 50 nJ/bit to run the transmitter or receiver circuit system and E amp = 100 pJ/bit/m 2 for the transmit amplifier to achieve a satisfactory signal-to-noise ratio. These parameters are slightly better than the existing radio system second assumption that was an energy loss due to channel transmission. To transmit an m-bit message over a distance of d using a radio model, the radio dissipates as follows:

LEACH First Order Radio Model. As shown in
and to get this message, the radio expands With those parameters, transferring or receiving a packet is not a low-cost method; so, protocols must strive to reduce not only transmission distances but also the number of transmission and receiving operations per message.

Clustering Mechanism.
IoT nodes are divided into groups in a cluster farm, and these groups are known as clusters; each cluster is represented by G and has a head node. Each cluster's nodes sense data and send it to a single head node; they do not communicate with other head nodes.  (1) Cluster Head (CH) Selection. The CH is responsible for collecting data from member nodes and transmitting aggregated data to the base station, it requires a lot of energy to do so, and the transmission process must be boosted with high power amplification. Two parameters are considered in the CH selection process: the history of nodes acting as CH and the optimal percentage of a node. The generation of a random number is used to make each node decision (between 0 and 1). The node will be selected as CH if the generated random number is threshold (T n ) for that round.
The following formula is used to calculate the threshold (T n ): In equation (4), p represents the percentage of CH, r represents the number of rounds, and G represents the set of nodes that were not selected as CH in the previous 1/p rounds. Every node in the cluster has a 1/p chance of being a CH in each round in this situation. When a node is chosen as CH, it sends an advertisement message to its nearby nodes, inviting them to be CH. The advertisement message is accepted by the member nodes, and they enter the CH.
(2) Data Transmission. Following CH selection, the data transmission schedule kicks off, with member nodes sending data to their assigned CH during their designated transmission time. Low-energy transmission was required for this type of transmission. Before transmission time is allocated, the member node can be turned off to save energy. The CH must keep the receiver to receive the full data and then combine all of the data into a single signal before transmitting it to the base station via a sink node.
(3) Routing Phase. The way to pick a traffic route in a network is routing. The IoT agricultural network is comprised of numerous modes of communication and protocols in the long and short range, which form the backbone for these networks to gather information and exchange this data with the farmers for review and decision-making. The IoT-based agriculture protocol has three levels of data routing in the first stage member node sense data and transfer it to their CHs, while in the second stage, the CHs accumulate and transfer data to the nearest sink, and in the third and last stage, sink sends this data into the base station. In such data communication, the function of the sink minimizes CH's energy consumption and reduces packet losses, especially for long haul communication. Figure 8 demonstrates the full data routing method.
(4) Setup Phase. For the first round, CHs are generated using the standard LEACH algorithm, and the cluster heads are chosen using equation (4). After transferring data, each node in the network consumes a specific amount of energy, and each node has consumed a different amount of energy. The distance between the sending and receiving nodes, denoted   Figure 10: First order radio model.

Operations
Energy dissipated Transmitter electronics E T x−elec À Á 50 nJ/bit Transmit amplifier E amp 100 pJ/bit/m 2 9 Wireless Communications and Mobile Computing by "d," is an important factor in power consumption. As a result, the CH is chosen for the next round using an improved equation, as shown below.
In above equation (5), E residual represents the node remaining energy, and E initial is the initial energy assigned. Thus, m opt could be written as optimal number of clusters.
In the above equation (6), the m opt is the optimal number of clusters, X is the diameter of the network, whereas E 0 is the node initial energy. For data transmission, this research extended the first order radio model specified in equation (2) to compute the energy consumption where d o presents distance threshold while E elec and E f s are denoted as energy dissipation with 50 nJ/bit and 10 pJ/bit/m 2 accordingly. m represents the packet size, and E amp is the multipath model of transmitter amplifier with 0.0013 pJ/bit/m 4 . Thus, E RX can be determined as it represents the receiving energy Because all nodes in the farm were deployed at random with the same initial energy, the sink node is deployed without energy constraints outside of the cluster farm, and nodes are informed of its location. In the first round, nodes report their location to the sink based on their signal strength.
Those nodes that were chosen as grid heads (GH) begin performing their GH role and cease their previous role of data sensing during this process. Cluster heads are chosen as nodes with a high residual energy and a short Euclidean distance to sink and GH. The Euclidean distance between any two nodes a and b in the next two dimensions is calculated as follows: Transfer aggregated data to nearest sink S i 9. Transferring data from S i to BS 10. END Algorithm 1: The proposed scheme. 10 Wireless Communications and Mobile Computing WE consumed is calculated using equation by (6).
In the above equation, WE consumed is the amount of energy consumed in each round, and d o denotes the distance between two nodes. The consumption of energy is assumed as E TX and E RX , and their parameters can be determined by using (2) and (3). To meet the objective mentioned in (5), this research divides the total node energy into different equivalent parts and presented as "EL" and can be calculated from (7) In the equation (10), EL stands for energy level, Eo stands for initial static node, and TL stands for total energy, which is dependent on the amount of energy consumed by each node as well as network density and packet size. The relationship between EL and TL is inverse. When the TL value is low, the EL value is high. The node in the cluster farm performs the role of CH until the values of EL do not reduce the residual energy, at which point, a termination of CH selection message is sent to all nodes, and a new process for CH selection begins. Only those nodes that are supposed to transfer data remain active in this mechanism to reduce energy consumption. When member nodes finish their data sensing process, CH begins to collect data from all member nodes, aggregate the data to remove any duplication, combine data into a single signal to save bandwidth, and transmit data in a single hop to the sink, where it is then transferred to the base station. The flowchart is shown in Figure 11, and the algorithm for the entire process is shown below.

Simulation Results and Discussion
To test the efficiency of our proposed IoT-based agriculture protocol, the MATLAB simulation is compared with the current LEACH protocol. IoT nodes were installed randomly in each simulated technique in the simulation of 5000 rounds. In the farm of 500 × 500m 2 , all active IoT nodes transfer data to their respective cluster heads, and cluster heads transfer data to the base station via sink node. The simulation results are presented below.
4.1. Network Stability Period. The time it takes for the first node to die is known as the network stability period. Figure 12 depicts the LEACH network stability period and the proposed IoT-based agriculture protocol. LEACH has a shorter stability period than the proposed protocol. The reason for the improvement is that data is only transferred in the proposed protocol when there is a difference between previously taken data and current data. The results show that the LEACH first node dies after 168 rounds, while the proposed protocol first node dies after 463 rounds, indicating that the IoT-based agriculture protocol is 23% more efficient in terms of network stability.

Energy
Consumption. The energy consumed by the nodes during data transmission is referred to as energy consumption. Figure 13 shows the simulation results for both protocols. The energy consumption of the nodes in the IoTbased agriculture protocol is 68 percent lower than that of LEACH, which can extend network life.

Conclusions
The use of blockchain in the food supply chain has yielded various benefits, including the potential to expand and step towards the distributed network, as well as the ability to build a trustless environment for all processes. Despite the trustless existence of blockchain, it is difficult to completely establish trust between the agricultural product seller and buyer. Current blockchain-based food supply chain systems focus solely on the supply chain, with no choice to track food products back to their source to ensure product quality, while existing IoT-based agriculture systems are often isolated, with roles restricted to agriculture environment monitoring and farmers unable to directly communicate with market buyers. In this paper, we have provided complete solution for agriculture and food supply chain by integrating IoT with the blockchain. In addition, we have developed an energy efficient routing protocol for the proposed system to extend system life by reducing energy consumption. A novel approach has been applied in this research and developed a futuristic smart model for agriculture and the food supply chain, which offers an innovative way for farmers to acquire information on crops. IoT can provide farmers with information on crop yields, soil temperature, pest infestation, and soil quality that is essential for high crop production and provides precise data that can be used to improve farming techniques. Crop

12
Wireless Communications and Mobile Computing tracking can be performed effectively to track crop growth and record growth information. Another unique aspect of the smart model is blockchain, which offers real-time updates on the safety status of food items to all actors of the supply chain, significantly eliminates the vulnerability of centralized information networks, and makes them secure, more widely available, more accessible, and more interactive. The smart model will greatly boost the efficiency and reliability of the food supply chain, which will inevitably increase food safety and regain customer trust in the food industry.

Data Availability
Data is available upon requesting the corresponding author.

Conflicts of Interest
The authors declare no conflict of interest.