IoT-GChain: Internet of Things-Assisted Secure and Tractable Grain Supply Chain Framework Leveraging Blockchain
Abstract
:1. Introduction
- Governing authority: As the central authority overseeing food distribution, it plays a pivotal role in the grain supply chain traceability system. It orchestrates the entire process by registering each level. It ensures adherence to regulations, assigns blockchain addresses, and manages permissions to ensure transparency and accountability in grain distribution.
- Level 1 tier: This level collaborates closely with the governing authority to ensure effective implementation of the traceability process. It provides overarching guidance and regulatory framework and, through the governing authority, ensures that stakeholders are registered and operate within established protocols.
- Level 2 tier: Level 2 works in tandem with the governing authority to ensure region-specific grain distribution. It facilitates the registration of level 2 and level 3 tiers within its jurisdictions, enhancing localized management and coordination.
- Level 3 tier: Level 3, under the oversight of the governing authority, manages the distribution of grains within its respective sub-area. It is responsible for registering and supervising the level 4 tier, ensuring efficient and equitable access to essential commodities.
- Level 4 tier: This level acts as the final point of contact with consumers. It provides grains to end-users, adhering to the regulations and maintaining grain quality and authenticity. Through the traceability system, the level 4 tier upholds the integrity of distributed grains.
- An Internet of Things-enabled circuit is designed to capture the real-time humidity and temperature of grain across the supply chain and continuously update it on blockchain so it can be monitored by all stakeholders.
- A non-fungible token-based system is created to verify grain quality and its ownership, which enhances the transparency of grains to consumers.
- We ensure grain traceability through each level using blockchain technology and an NFT-QR-based traceable mechanism for real-time monitoring and discrepancy detection.
- The proposed framework is implemented, Remix Ide is used for building smart contracts, and EtherScan is used for transaction monitoring.
- Security and threat analysis of smart contracts is conducted using the Solidity Scan tool.
2. Existing Systems
- Identification of beneficiaries: Governments or relevant authorities identify individuals or households eligible for subsidized food based on socio-economic indicators, income levels, or specific criteria.
- Allocation of food resources: Governments allocate essential food resources, including grains like rice and wheat, to regions or states based on population size, socio-economic factors, and nutritional needs. The quantity and types of allocated food resources may vary to align with regional preferences and dietary requirements.
- Distribution points: Authorized distribution points, which may include government-operated stores, local markets, or community centers, facilitate the distribution of subsidized food items.
- Distribution process: Beneficiaries visit designated distribution points to collect their allocated food resources. Transactions may involve manual or digital record-keeping, depending on the technological infrastructure of the region.
- Monitoring and evaluation: Governments and relevant agencies monitor the distribution process to ensure fair and effective delivery of food resources to beneficiaries. Regular evaluations may be conducted to assess the performance of the distribution system and identify opportunities for improvement.
Limitations of Existing Systems
- Lack of traceability: Traditional systems often lack robust mechanisms for tracing the journey of grains from farm to fork. This absence of traceability makes it difficult to identify the origin of grains, track their movement through the supply chain, or ascertain their quality and safety status accurately.
- Limited transparency: Centralized systems typically offer limited transparency regarding grain transactions and movement. Stakeholders may not have access to real-time information about inventory levels, pricing, or quality checks, leading to opacity in the supply chain and potential opportunities for fraud or malpractice.
- Vulnerability to fraud and counterfeiting: Manual record-keeping and paper-based documentation systems are susceptible to errors, tampering, and fraudulent activities. Without robust authentication mechanisms, such as digital signatures or unique identifiers, there is a heightened risk of counterfeit products entering the supply chain, compromising food safety and integrity.
- Inefficiencies in record-keeping: Paperwork-intensive processes are inherently inefficient and prone to delays, inaccuracies, and data discrepancies. Manual record-keeping not only consumes time and resources but also increases the likelihood of human errors, leading to inefficiencies in inventory management, order processing, and regulatory compliance.
- Limited accountability and compliance: Traditional systems may lack mechanisms to hold stakeholders accountable for their actions or ensure compliance with regulatory standards and industry best practices. Without transparent audit trails or mechanisms for verifying the authenticity of data, it becomes challenging to enforce accountability or address non-compliance issues effectively.
- Fragmented information silos: Grain supply chains often involve multiple stakeholders, including farmers, distributors, retailers, and regulatory authorities. In traditional systems, information may be siloed within individual organizations or departments, leading to fragmentation and duplication of efforts. This lack of data interoperability and collaboration impedes the seamless flow of information across the supply chain, hindering decision-making and coordination efforts.
- Susceptibility to contamination and quality issues: Inadequate monitoring and oversight in traditional systems can exacerbate the risk of grain contamination or quality degradation during storage, handling, or transportation. Without real-time visibility into environmental conditions or quality control measures, it is challenging to prevent or mitigate contamination incidents effectively.
- High operational costs: The manual nature of traditional systems often results in high operational costs associated with labor, paperwork, and administrative overheads. Moreover, inefficiencies in inventory management, order fulfilment, and compliance management can further inflate operational expenses, reducing profitability and competitiveness in the market.
3. Preliminaries
3.1. Blockchain
3.2. Smart Contracts
3.3. Types of Blockchain-Based Solutions
- Public blockchain: A public blockchain is an open network that allows anyone to set up a node for the blockchain. There is no restriction on joining the blockchain, and every transaction is visible on the ledger (the users are anonymous), thus making it transparent. It is decentralized and easy to set up [18]. An Ethereum blockchain is a commonly used public blockchain. Currently, the Ethereum blockchain is the most prevalent and established smart contract provider. It uses the Ether cryptocurrency and works on the proof of stake consensus mechanism. Every time a transaction occurs, a reward (in terms of Ether) is given to the validator of the transaction. This provides an incentive for people to set up nodes and has greatly increased outreach. Public blockchains are easy to set up and open for all, due to which they are difficult to regulate and often slower.
- Private blockchain: A private blockchain can be considered a blockchain network that is owned by a particular entity or authority and is directly managed by it. It can be considered a special type of private networking solution that is decentralized [14]. A private blockchain network requires an invitation and must be validated by either the network starter or by a set of rules by the network starter. It is not fully transparent, as only the nodes on the network may view the transactions, and it is not open to everyone. The managing authority may perform relevant changes, albeit not that easily. This can be considered a partially decentralized system.Several companies offer private blockchain solutions to make businesses more secure. Private blockchains usually require low costs to set up and are more efficient due to less network congestion. A private blockchain is easier to manage but may not necessarily be immutable, as the whole network may be updated, which may be possible depending on the size of the network and is an inescapable drawback to private blockchains. The issuing authority has to ensure trust; thus, it makes it similar to traditional centralized systems but with distributed nodes acting as servers.
- Hybrid blockchain: This blockchain aims to combine both public and private blockchains by offering a solution that is open for all but reserves some permissions and activities for a selected group of nodes in the network. This is made possible by using a permission-based system within the permission-less system of a public blockchain. This may largely help to reduce fraud, as only verified users may be allowed to use the blockchain. This makes it a permissioned blockchain, which is also open to the public, ensuring better decentralization of the system.
- Consortium blockchain: Consortium and hybrid blockchains are similar as they both have a public and private blockchain component. The difference lies in the structure of the organization’s management of the permissioned part. For a consortium blockchain, multiple entities govern the platform. The entities also define the roles of nodes and the permissions granted to each.
4. The Proposed Framework
Algorithm 1 Farmer registration and verification |
Input: Farmer’s Ethereum address . Output: Farmer successfully registered and verified.
|
Algorithm 2 Mint NFT of grain sack |
Input: , , , , , Output: NFT for
|
Algorithm 3 Grain sack NFT update |
Input: Output: Returns true if update is successful.
|
Algorithm 4 Buying grains |
Input: Grain Sack Id and buyer address . Output: Grain purchased successfully.
|
5. Implementation
5.1. Experimental Setup
5.1.1. InterPlanetary File System (IPFS)
5.1.2. Remix IDE
5.1.3. EtherScan for Transaction Monitoring
- Contract deployment: After deploying the ‘GrainChain’ smart contract to the Ethereum testnet, the contract address is obtained and entered into EtherScan.
- Transaction tracking: EtherScan is used to monitor all transactions related to the smart contract, including NFT creation, state updates, and event emissions.
- Verification: The details of each transaction are verified on EtherScan to ensure that the contract functions behaves as expected and that state changes are accurately recorded on the blockchain.
- Event logs: EtherScan provides access to event logs, which are crucial for tracking the ‘NFTCreated’ event and other significant state changes within the contract.
5.1.4. SolidityScan
- Code upload: The ‘GrainChain’ smart contract code is uploaded to SolidityScan’s cloud-based platform.
- Automated scanning: SolidityScan performs a comprehensive scan of the code, using both automated detection methods and predefined rules for identifying vulnerabilities.
- Report generation: The scanner generates a detailed audit report outlining the identified issues, their severities, and recommendations for remediation.
5.2. Architecture of the Proposed Scheme
- Data collection: Information on grain transactions can be held at this state, i.e., warehouse logs, a description of the grain, data from its sensors, temperature and humidity from the DHT22 sensor, geolocation coordinates from the GPS module, grain lot, among others, as depicted in Figure 8. This phase uses distributed ledger technology to safeguard information in a decentralized manner, thus ensuring transparency and security.
- Smart contract: Next, intelligent contracts are used to facilitate the various transactions in the grain chain. Smart contracts refer to self-executing contracts in which the agreement terms between two parties are directly written into the software. For example, in the grain chain, smart contracts are used to automate the transfer of ownership of a grain lot from the level 1 to level 2 tier.
- Consensus mechanism: Afterwards, a consensus mechanism between the nodes of the network is employed. Consensus is vital to ensure all network nodes agree on the state of the blockchain. This layer might be materialized with a consensus algorithm, such as proof-of-work or proof-of-stake.
- User interaction: The Farmer/retailer/agency interacts with the blockchain environment at this stage, along with the user interface. For instance, the applications could be a create lot portal, a transfer lot portal, an update lot portal, and a sell portal. It uses RESTful APIs to interact with the blockchain.
5.3. Designing the Smart Contract
- Inheritance and Imports
- The contract is inherited from ERC-721 URIStorage, which is part of the OpenZeppelin library for ERC-721 token standards [18]
- It also implements the ERC-721 Supply interface, indicating that it adheres to the ERC-721 token standard with additional supply-related functions.
- State Variables
- ‘tokenIdCounter’ tracks the unique identifier for each NFT token.
- ‘allLots’ uses mapping to store information about each grain lot, indexed by their token IDs.
- ‘ownerOfToken’ uses mapping to track the owner of each token.
- Structs
- Locate represents the geographical location with latitude and longitude coordinates.
- State defines the state of a grain lot, including ownership, description, timestamp, weight, certificate URL, temperature, humidity, location, and exceeded temperature.
- Constructor
- The initializes the contract with the name “GrainNFT” and symbol “GNFT” upon deployment.
- Functions:
- ‘getLot’ retrieves information about a specific grain lot based on its token ID.
- ‘totalSupply’ returns the total number of NFT tokens minted.
- ‘createLotNFT’ creates a new grain lot NFT, mints it to the caller, and stores relevant information about the lot.
- ‘updateLotNFT’ updates information about an existing grain lot based on its token ID.
- ‘publishNFT’ sets the token URI for a specific NFT, essentially linking it to off-chain metadata such as descriptions or images.
- Helper Function
- ‘uintToString’ converts a uint256 value to its string representation.
- Design Considerations
- Efficiency: The contract design appears efficient, with minimal gas usage for common operations like creating and updating grain lots.
- Security: The contract should be audited for potential vulnerabilities, especially regarding access control and input validation to prevent unauthorized operations or data manipulation.
- Scalability: While the current design can handle a moderate number of grain lots, considerations for scaling, such as gas optimization and data storage efficiency, should be taken into account for large-scale adoption.
- Interoperability: The contract should conform to relevant standards like ERC721 to ensure compatibility with existing NFT marketplaces and infrastructure.
- User Experience: User interaction with the contract should be intuitive and well-documented to facilitate adoption by stakeholders in the grain supply chain.
5.4. Integration
- Setting up MetaMask
- Users install the MetaMask browser extension or mobile app and create or import their Ethereum wallet.
- They connect MetaMask to the Sepolia test network to interact with smart contracts deployed on this test chain.
- Deploying the Smart Contract
- The developer compiles the smart contract code using a Solidity compiler like Remix or Truffle.
- Using MetaMask version 11.0.0 the developer selects the Sepolia test network and deploys the compiled contract to this network.
- Upon deployment, MetaMask prompts the developer to confirm the transaction and pay the gas fee using test Ether (ETH) from their MetaMask wallet.
- Interacting with the Contract
- After deployment, users can interact with the smart contract through a decentralized application (dApp) interface connected to MetaMask.
- They can view existing grain lots, create new grain lots, update information about existing lots, and perform other permitted actions defined by the contract’s functions.
- Minting Procedures
- To mint a new grain lot NFT, users initiate the minting process through the dApp interface.
- They specify details such as grain type, description, weight, certificate URL, location coordinates, temperature, humidity, and any other relevant information required by the contract.
- Upon confirmation, MetaMask prompts the user to sign the transaction and pay the gas fee for minting the NFT.
- Once the transaction is confirmed and included in a block on the Sepolia test chain, the new grain lot NFT is minted, and its details are recorded on the blockchain.
- Transaction Confirmation
- Users can monitor the status of their transactions on MetaMask, which provides real-time updates on transaction confirmations, gas fees, and network activity.
- Once the transaction is confirmed, users can view the newly minted grain lot NFT in their MetaMask wallet or explore its details through the dApp interface.
- Testing and Debugging
- Developers and users can test the functionality of the smart contract on the Sepolia test chain without incurring any actual Ether transactions or gas fees.
- They can simulate various scenarios, such as creating multiple grain lots, updating information, and transferring ownership, to ensure the contract behaves as expected.
5.5. Feature Analysis
- Decentralization: We have created a system that significantly enhances transparency and decentralization compared to conventional practices. This decentralization not only provides clarity for end-users but also streamlines processing tasks during the product’s production life cycle.
- Reliable metadata handling: The proposed scheme has effectively published NFT metadata on IPFS and retrieved grain status information, showcasing its robust integration into the InterPlanetary File System (IPFS). The system’s ability to store and retrieve decentralized and tamper-resistant metadata on IPFS has been validated.
- Accurate real-time data handling: The logging and real-time exchange of sensor data with Firebase have been thoroughly tested and proven accurate. This ensures that the system precisely captures sensor inputs and updates the Firebase real-time database, establishing a reliable mechanism for data collection. This is critical for maintaining transparency and traceability in the grain distribution process.
- Efficient grain status retrieval: The get lot function, designed to retrieve grain status information based on the grain ID, has successfully returned the expected grain info object. This functionality demonstrates the system’s precision in retrieving and presenting detailed information about specific grain lots, contributing significantly to transparency and traceability.
- User-friendly transaction facilitation: The generation of QR-CODEs during lot NFT creation has passed testing, highlighting the user-friendly nature of the system. The successful generation of QR codes is crucial for facilitating seamless transactions and interactions within the platform, ultimately enhancing the overall user experience.
5.6. Security and Threat Analysis
5.6.1. Security and Threat Scores Explanation
- Lines of code (136): A relatively moderate codebase size, which typically helps in maintaining readability and manageability.
- Issues count (15): The number of identified issues impacts the score, with each issue’s severity contributing to the overall reduction of the score.
- Severity and confidence: Issues with higher severity and detection confidence weigh more heavily against the security score.
5.6.2. Threat Score
6. Conclusions and Future Work
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Zhang, X.; Sun, P.; Xu, J.; Wang, X.; Yu, J.; Zhao, Z.; Dong, Y. Blockchain-based safety management system for the grain supply chain. IEEE Access 2020, 8, 36398–36410. [Google Scholar] [CrossRef]
- Zhang, X.; Li, Y.; Peng, X.; Zhao, Z.; Han, J.; Xu, J. Information traceability model for the grain and oil food supply chain based on trusted identification and trusted blockchain. Int. J. Environ. Res. Public Health 2022, 19, 6594. [Google Scholar] [CrossRef] [PubMed]
- Lucena, P.; Binotto, A.P.; Momo, F.D.S.; Kim, H. A case study for grain quality assurance tracking based on a Blockchain business network. arXiv 2018, arXiv:1803.07877. [Google Scholar]
- Zhang, Y.; Wu, X.; Ge, H.; Jiang, Y.; Sun, Z.; Ji, X.; Jia, Z.; Cui, G. A blockchain-based traceability model for grain and oil food supply chain. Foods 2023, 12, 3235. [Google Scholar] [CrossRef] [PubMed]
- Thakur, K.S.; Ahuja, R. Empowering Fast-Moving Consumer Goods Supply Chain Leveraging Blockchain. In International Conference on Recent Trends in Machine Learning, IOT, Smart Cities & Applications; Springer Nature Singapore: Singapore, 2023; pp. 729–740. [Google Scholar]
- Albaaji, G.F.; Chandra, S.V. Blockchain technology in agriculture: Digitizing the Iraqi agricultural environment. Environ. Dev. Sustain. 2024, 1–12. [Google Scholar] [CrossRef]
- Farooq, M.S.; Ansari, Z.K.; Alvi, A.; Rustam, F.; Díez, I.D.L.T.; Mazón, J.L.V.; Rodríguez, C.L.; Ashraf, I. Blockchain based transparent and reliable framework for wheat crop supply chain. PLoS ONE 2024, 19, e0295036. [Google Scholar] [CrossRef] [PubMed]
- Balamurugan, S.; Ayyasamy, A.; Joseph, K.S. IoT-Blockchain driven traceability techniques for improved safety measures in food supply chain. Int. J. Inf. Technol. 2022, 14, 1087–1098. [Google Scholar] [CrossRef]
- Caro, M.P.; Ali, M.S.; Vecchio, M.; Giaffreda, R. Blockchain-based traceability in Agri-Food supply chain management: A practical implementation. In Proceedings of the 2018 IoT Vertical and Topical Summit on Agriculture-Tuscany (IOT Tuscany), Tuscany, Italy, 8–9 May 2018; pp. 1–4. [Google Scholar]
- Chang, A.; El-Rayes, N.; Shi, J. Blockchain Technology for Supply Chain Management: A Comprehensive Review. J. Supply Chain Manag. 2022, 1, 191–205. [Google Scholar] [CrossRef]
- Patel, H.; Shrimali, B. AgriOnBlock: Secured data harvesting for agriculture sector using blockchain technology. ICT Express 2023, 9, 150–159. [Google Scholar] [CrossRef]
- Zeng, H.; Dhiman, G.; Sharma, A.; Sharma, A.; Tselykh, A. An IoT and Blockchain-based approach for the smart water management system in agriculture. Expert Syst. 2023, 40, e12892. [Google Scholar] [CrossRef]
- Ahuja, R.; Chugh, S.; Singh, R. SeedChain: A secure and transparent blockchain-driven framework to revolutionize the seed supply chain. Future Internet 2024, 16, 132. [Google Scholar] [CrossRef]
- Devrani, S.; Ahuja, R.; Goel, A.; Kharbanda, S.S. A blockchain-driven framework for issuance of NFT-based warranty to customers on E-commerce. In International Conference on Multi-Disciplinary Trends in Artificial Intelligence; Springer Nature Switzerland: Cham, Switzerland, 2023; pp. 265–276. [Google Scholar]
- Gervais, A.; Karame, G.O.; Wüst, K.; Glykantzis, V.; Ritzdorf, H.; Capkun, S. On the security and performance of proof of work blockchains. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, Vienna, Austria, 24–28 October 2016; pp. 3–16. [Google Scholar]
- Lim, M.K.; Li, Y.; Wang, C.; Tseng, M.L. A literature review of blockchain technology applications in supply chains: A comprehensive analysis of themes, methodologies and industries. Comput. Ind. Eng. 2021, 154, 107133. [Google Scholar] [CrossRef]
- Yan, Z.; Gan, G.; Riad, K. BC-PDS: Protecting Privacy and Self-Sovereignty through BlockChains for OpenPDS. In Proceedings of the 2017 IEEE Symposium on Service-Oriented System Engineering (SOSE), San Francisco, CA, USA, 6–9 April 2017; pp. 138–144. [Google Scholar]
- Lai, R.; Chuen, D.L.K. Blockchain–from public to private. In Handbook of Blockchain, Digital Finance, and Inclusion; Academic Press: Cambridge, MA, USA, 2018; Volume 2, pp. 145–177. [Google Scholar]
- Patidar, A.; Sharma, M.; Agrawal, R.; Sangwan, K.S. A Smart Contracts and Tokenization Enabled Permissioned Blockchain Framework for the Food Supply Chain. In IFIP International Conference on Advances in Production Management Systems; Springer International Publishing: Cham, Switzerland, 2021; pp. 228–235. [Google Scholar]
- Mishra, H.; Maheshwari, P. Blockchain in Indian Public Distribution System: A conceptual framework to prevent leakage of the supplies and its enablers and disablers. J. Glob. Oper. Strateg. Sourc. 2021, 14, 312–335. [Google Scholar] [CrossRef]
- Menon, S.; Jain, K. Blockchain Technology for Transparency in Agri-Food Supply Chain: Use Cases, Limitations, and Future Directions. J. Distrib. Ledger Traceability Transpar. 2024, 71, 106–120. [Google Scholar] [CrossRef]
- Ellahi, R.M.; Wood, L.C.; Bekhit, A.E.-D.A. Blockchain-Based Frameworks for Food Traceability: A Systematic Review. Foods 2023, 12, 3026. [Google Scholar] [CrossRef] [PubMed]
- Mekkouri, M.; Hennebert, C. Practices for Assessing the Security Level of Solidity Smart Contracts. In International Symposium on Foundations and Practice of Security; Springer Nature Switzerland: Cham, Switzerland, 2023; pp. 71–86. [Google Scholar]
- Bhat, S.A.; Huang, N.-F.; Sofi, I.B.; Sultan, M. Agriculture-Food Supply Chain Management Based on Blockchain and IoT: A Narrative on Enterprise Blockchain Interoperability. Agriculture 2022, 12, 40. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Thakur, K.S.; Ahuja, R.; Singh, R. IoT-GChain: Internet of Things-Assisted Secure and Tractable Grain Supply Chain Framework Leveraging Blockchain. Electronics 2024, 13, 3740. https://doi.org/10.3390/electronics13183740
Thakur KS, Ahuja R, Singh R. IoT-GChain: Internet of Things-Assisted Secure and Tractable Grain Supply Chain Framework Leveraging Blockchain. Electronics. 2024; 13(18):3740. https://doi.org/10.3390/electronics13183740
Chicago/Turabian StyleThakur, Karan Singh, Rohit Ahuja, and Raman Singh. 2024. "IoT-GChain: Internet of Things-Assisted Secure and Tractable Grain Supply Chain Framework Leveraging Blockchain" Electronics 13, no. 18: 3740. https://doi.org/10.3390/electronics13183740
APA StyleThakur, K. S., Ahuja, R., & Singh, R. (2024). IoT-GChain: Internet of Things-Assisted Secure and Tractable Grain Supply Chain Framework Leveraging Blockchain. Electronics, 13(18), 3740. https://doi.org/10.3390/electronics13183740