In recent years, food safety accidents have occurred frequently   . The white paper Food Security in China issued by the State Council of the People’s Republic of China highlights that “As food is essential to a nation’s prosperity and its people’s wellbeing, food security is a major prerequisite for national security” . Environmental factors, such as temperature and humidity, need to be strictly controlled throughout the many stages of the food supply chain. Inappropriate production or processing environments at any stage may result in adverse consequences, such as mildew and insect damage. Therefore, to minimize food safety issues, it is essential to collect data regarding the supply chain and control the environmental factors of the supply chain that may threaten food safety. In addition, it is necessary to establish a food traceability system whereby authentic, reliable traceability data are accessible and the food supply chain is more transparent to the consumer.
Most existing food traceability systems rely on centralized databases. In such a system, only basic place-of-origin data are uploaded to the database; key environmental factors that affect food quality are not considered. In addition, there are no mechanisms for mutual authentication among the stages of the supply chain, thereby causing information islands. Furthermore, data uploading is usually done manually. Therefore, only limited data are accessible to the consumer, and the authenticity of data is difficult to ensure.
RFID is a non-contact automatic identification technology, and rapid, efficient, and non-visualized object identification even in harsh environments makes it extremely suitable for food traceability applications. An RFID system usually consists of three parts: readers, tags, and backend servers. Readers and tags wirelessly exchange data. A reader can read data from and write data into a tag. Each tag has a unique identification number and is capable of storing a certain amount of data.
Blockchain is a decentralized, distributed database technology. Using rigorous cryptographic algorithms, blockchain connects data-storing blocks in a chain structure according to the order of the generation time of blocks. Therefore, data stored using blockchain technology have a time stamp that cannot be tampered with or manipulated. All transaction records in a blockchain are verified with a complete evidence chain and a highly reliable traceability link. Therefore, the application of blockchain technology in a food traceability system can effectively prevent data tampering and manipulation by any users. Ethereum is a blockchain-based platform featuring smart contracts. Different from Bitcoin applications, which are only for transactions, Ethereum is a brand new, open blockchain platform that allows any user to develop and use decentralized applications based on blockchain technology on the platform. Ganache, which is an in-memory blockchain designed for development and testing, simulates the function of the real Ethereum network. Providing users with a readily available in-memory blockchain, Ganache supports the query of transaction logs and the status monitoring of smart contracts. In this study, a food traceability model was developed and tested in an Ethereum testing environment provided by Ganache.
Owing to its distributed consensus and anti-tampering capabilities, blockchain technology can be used for various applications and provides the highest level of security and trustworthiness . Therefore, the application of blockchain technology to food traceability can effectively ensure the authenticity and reliability of the traceability data. Currently, there are few blockchain-based food traceability systems.
Fabian  assessed the feasibility of using blockchain technology to realize the accuracy and transparency of traceability systems. Feng  highlighted the substantial advantages of radio frequency identification (RFID) and blockchain-based agri-food traceability systems, particularly their high level of security. Mao  designed a novel food trading system with consortium blockchain (FTSCON). Casado-Vara  investigated how blockchain technology can improve the supply chain based on a case study of the food supply chain. Xu  applied blockchain application design approaches proposed in software architecture community in a real-world project called orginChain and found that the structural design of smart contracts has large impact on the quality of system. Behnke  used a template analysis of 16 interviews to inveigated four case in the food supply chain, and proposed eighteen boundary conditions that need to be met to apply the blockchain technology to the food supply chain. Caro  used two different blockchain platforms, Ethereum and Hyperledager, to achieve food traceability, and compared the performance of the two platforms. Galvez  pointed out that even though the use of blockchain technology to ensure the traceability of food safety seems promising, it still needs to use RFID tags or barcodes to scan food to track data, and then connect the sensor to the blockchain. Therefore, if the attacker tampers with the information collected by the sensor, the information uploaded to the blockchain has been faked.
The existing research on the application of blockchain in food traceability seldom focuses on data regarding environmental factors and their uploading to the blockchain in a tamper-proof manner. In addition, there are no reports on the realization of consumer direct access to data regarding the relevant environmental factors during food production and processing. Therefore, further research is required to realize the uploading of environmental data from sensors to the blockchain and the access of these data from a web page.
Considering the above issues, in this study, a food supply chain traceability model focusing on the traceability of data on the environmental factors during food production and processing was established by combining blockchain and RFID technologies. The model was verified in the testing environment of the blockchain-based Ethereum platform. In particular, environmental data collected by sensors during food production and processing were automatically uploaded to the Ethereum blockchain and were made accessible to the consumer on a web page. The model eliminated the possibility of data tampering by any entity of the supply chain and provided the consumer with direct access to factual environmental data about the various supply chain stages, thereby ensuring reliable and authentic traceability data.
2. Food Supply Chain Traceability Model
2.1. System Architecture Design
In this study, the food supply chain was divided into five stages: farming, storage, transportation, processing, and sales. In each stage, sensors are used to collect data on environmental factors that affect food quality. Foods are a bulk, low-value commodity, making accurate tracing of foods very difficult. Therefore, in the food traceability model proposed in this study, foods are labelled (lot number) at the farming stage. Each lot has an attached RFID tag. A traceability code is assigned to each lot at each stage and is written into the tag. The environmental data collected by sensors are tagged with the corresponding codes, thereby ensuring the accuracy and traceability of the data. At the processing stage, the traceability codes of the previous stage are encrypted to generate a final traceability code, which is printed in the form of two-dimensional barcodes (QR codes) on the outer packaging of the product. The consumer can use the QR code to access all information about the supply chain stages. Therefore, the system generates two types of data that are stored separately: 1) The stages of the supply chain jointly maintain a centralized database. At each stage, the corresponding traceability codes of each food lot are uploaded to the central database in batches, and the data are transparent to all the participating stages in the supply chain. 2) The environmental data of food in each processing stage are collected by sensors and directly uploaded to the blockchain. In each stage, the data collected by sensors are tagged with the corresponding traceability codes so that the environmental data from each stage of each food lot can be retrieved using the corresponding traceability codes. The overall architecture of the food traceability model is shown in Figure 1.
2.2. Centralized Database
At the farming stage, foods are identified by paddy field. That is, the food produced by a paddy field is represents a lot and has an RFID tag attached for storing the traceability codes assigned to the lot. The tag is permanently attached to
Figure 1. Overall architecture of food traceability model.
the lot throughout the following stages. In the case where the lot is subdivided into several sublots at a later stage, a new tag is generated and attached to each new sublot, and the lot subdivision is recorded by adding a leaf note in a tree structure. The traceability tree structure improves the accuracy of food traceability. Figure 2 illustrates the traceability tree structure.
As shown in Figure 2, Z represents the traceability code of the farming stage. Similarly, S represents the traceability code in the storage stage, T represents the traceability code in the transportation stage, and P represents the traceability code in the processing stage. Z1 is the farming-stage traceability code for the food lot produced by paddy field 001. In the storage stage, the food lot is subdivided into three sublots and stored in three warehouses. In addition to the original tag Z1, a new tag is added to each sublot (S1, S2, and S3) to identify the warehouse. The sublot stored in warehouse 001 is transported by three vehicles. The sublot transported by vehicle 001 is processed in workshop 001, and the food sublots transported by vehicles 002 and 003 are processed in workshop 004. The final traceability code is generated according to the traceability codes for the various stages and is printed in the form of a QR code on the outer packaging of the food product to facilitate query by the consumer.
2.3. Blockchain Database
The current blockchain can be categorized into three types: public, private, and consortium. In a public blockchain, all users can visit any notes and have the right to access data and submit transactions. For a public blockchain, the more the users there are, the more the decentralized and the more secure the blockchain is. However, this makes public blockchain slow in data processing. Bitcoin is a typical public blockchain. A private blockchain can be established by a company or a person who alone has the right to write data to the blockchain. Therefore, a private blockchain is not decentralized and is more like a centralized database. A consortium blockchain is established and managed jointly by several
Figure 2. Traceability tree structure.
entities or organizations. It has a processing speed higher than that of a public blockchain but is decentralized. After the establishment of a consortium blockchain jointly maintained by supply chain entities, the data on the environmental factors throughout the supply chain stages are uploaded to the consortium blockchain to realize mutual authentication and consensus among the users of the consortium blockchain. This design eliminates information islands, ensures the authenticity and validity of the uploaded data, and satisfies the required data processing speed.
Data on the environmental factors throughout the food supply chain are collected using sensors. The entities throughout the supply chain can monitor the environmental data and make the necessary adjustments in a timely manner by means of the cloud platform provided by the sensor supplier. In addition, the sensor data are uploaded automatically to the blockchain according to a pre-set frequency through the application programming interface (API) provided by the supplier, thereby preventing human tampering or errors associated with manual data uploading and providing consumers with authentic traceability data. Figure 3 illustrates the flow of sensor data.
3.1. Objective of Test
A test was conducted to verify the automatic uploading of temperature data collected by sensors to the blockchain and the access of the data stored in the blockchain on a web page.
3.2. Tseting Environment
Lenovo, Inter (R) Core (TM) i5-7300HQ CPU @2.5HZ, 8 GB RAM.
· Operating system:
Figure 3. Uploading of the sensor data to the blockchain.
Windows 10 64-bit.
Remix integrated development environment (IDE) for compiling and deploying smart contracts, located at http://remix.ethereum.org/;
Ganache for providing a testing environment of the Ethereum blockchain;
Web3.js for allowing the Ethereum blockchain to interact with the external environment;
HyperText Markup Language (HTML) for writing the visual interface;
JQuery for selecting and manipulating HTML elements;
3.3. Testing Procedure
To simplify the test, only temperature data uploaded via the sensor API were tested. The testing procedure is as follows:
1) Establish an Ethereum testing environment using Ganache. The testing environment was configured with 7545 ports and five initial accounts. Each account was allocated 100,000 Ethers for deploying contracts and verifying transactions.
2) Connect the Remix interface with the testing environment provided by Ganache. The Remix interface was configured with the same number of ports (7545) and connected with Ganache.
3) Write smart contracts using the Solidity.The contracts were configured with two methods: a) getData() for fetching data from the blockchain and b) setData() for uploading data to the blockchain.
4) Compile the contract in the Remix interface to get the ABI (application binary interface) of the contract and deploy it to the test environment provided by Ganache.
6) Upload the API data from the HTML interface to the blockchain.The interaction with the Ethereum blockchain was realized using the libraries of web3.js. The first step was to configure the provider. Next, the ABI data obtained from the contract compilation were initialized. Finally, the setData() of the contracts was called to upload the fetched API data to the blockchain.
3.4. Testing Results and Analysis
In the test, the API port provided by the sensor supplier was called to realize the automatic uploading of the sensor data to the blockchain. The automatic uploading of the data eliminated the possibility of data tampering through manual data uploading.
The temperature changes constantly, but it is not necessary to upload all the real-time temperature data to the blockchain. In addition, uploading all the real-time temperature data leads to a low data storage efficiency and a substantial waste of resources. Thus, at each stage, the frequency of temperature data uploading was different. For example, the frequency was three times a week for the farming stage and once every day for the transportation stage. In this way, not only can data authenticity and validity be ensured but also data storage resources can be saved.
The consumer can access the basic data and environment data of a food product by inputting the final traceability code at the traceability data query page. Figure 4 shows the traceability data query page.
The data regarding the supply chain stages of a food product can be accessed by inputting the traceability code and then clicking the Query button. The place-of-origin data are fetched from the centralized database, while the detailed environmental data are fetched from the blockchain. Figure 5 shows the temperature data obtained from the blockchain.
Figure 4. Traceability data query page.
Figure 5. Temperature data.
If an input traceability code does not exist, then an error message appears on the page, reminding the consumer to beware of counterfeiting，as shown in Figure 6.
The authenticity of the traceability data of existing food traceability systems is difficult to ensure. Blockchain technology is popular owing to its anti-tampering capabilities; however, its application in production and everyday life is difficult due to its inability to actively obtain external data. In this study, the traceability of a food supply chain was realized by automatically fetching data collected by sensors from an API and uploading them to a blockchain. With this traceability system, the consumer can access the data stored in the blockchain by inputting the traceability code on a web page, thereby realizing the interaction between the blockchain and the external environment. Our study has reference value for the application of blockchains.
Although assuring food traceability with blockchain and RFID technology looks promising, there remain some limits to be considered. One is that most of the current relevant research focuses on the technical level, and the reason why the research has been unable to be applied in real life may be the limitation of the supply chain organization. Therefore, we suggest that in the research process of applying blockchain technology to achieve food traceability, we should not be limited to technical research, and the supply chain itself should also make corresponding changes to achieve integration with blockchain technology. In addition, in the existing related research, when scholars design the system, because of the inherent security of blockchain technology, they default to the security of the designed system. This idea is biased. Therefore, the author suggests that when designing a food traceability system, a comprehensive analysis of the safety of the design architecture should be carried out, and corresponding defensive measures should be taken against components with potential safety hazards. For example,
Figure 6. Warning interface.
encrypt the communication process of RFID. The actual measures to be taken need to be decided according to the specific system.
Grateful acknowledgement is made to all the researchers mentioned in the references. And we would like to thank the anonymous reviewers and editors for the constructive and insightful comments for improving the quality of this paper.
 Wahyuni, H.C., Vanany, I. and Ciptomulyono, U. (2019) Application of Bayesian Network for Food Safety Risk in Cattle Slaugtering Industry. 2019 IEEE International Conference on Industrial Engineering and Engineering Management (IEEM), 450-454.
 Chousalkar, K., Gast, R.K., Martelli, F. and Pande, V.V. (2017) Review of Egg-Related Salmo nellosis and Reduction Strategies in United States, Australia, United Kingdom and New Zealand. Critical Reviews in Microbiology, 44, 290-303.
 Madumidha, S., Ranjani, P.S., Varsinee, S.S. and Sundari, P.S. (2019) Transparency and Traceability: In Food Supply Chain System using Blockchain Technology with Internet of Things. 2019 3rd International Conference on Trends in Electronics and Informatics (ICOEI), 983-987.
 Sander, F., Semeijn, J. and Mahr, D. (2018) The Acceptance of Blockchain Technology in Meat Traceability and Transparency. British Food Journal, 120, 2066-2079.
 Feng, T. (2016) An Agri-Food Supply Chain Traceability System for China Based on RFID & Blockchain Technology. 2016 13th International Conference on Service Systems and Service Management (ICSSSM), 1-6.
 Mao, D., Hao, Z., Wang, F. and Li, H. (2018) Innovative Block-chain-Based Approach for Sustainable and Credible Environment in Food Trade: A Case Study in Shandong Province, chiNa. Sustainability, 10, 3149.
 Casado-Vara, R., Prieto, J., De la Prieta, F. and Corchado, J.M. (2018) How Blockchain Improves the Supply Chain: Case Study Alimentary Supply Chain. Procedia Computer Science, 134, 393-398.
 Xu, X., Lu, Q., Liu, Y., Zhu, L., Yao, H. and Vasilakos, A.V. (2018) Designing Block Chain-Based Applications a Case Study for Imported Product Traceability. Future Generation Computer Systems, 92, 399-406.
 Behnke, K. and Janssen, M. (2020) Boundary Conditions for Traceability in Food Supply Chains Using Blockchain Technology. International Journal of Information Management, 52.
 Caro, M.P., Ali, M.S., Vecchio, M. and Giaffreda, R. (2018) Blockchain-Based Traceability in Agri-Food Supply Chain Management: A Practical Implementation. 2018 IoT Vertical and Topical Summit on Agriculture-Tuscany (IOT Tuscany), 1-4.
 Galvez, J.F., Mejuto, J.C. and Simal-Gandara, J. (2018) Future Challenges on the Use of Blockchain for Food Traceability Analysis. TrAC Trends in Analytical Chemistry, 107, 222-232.