Design and Implementation of Traceability System Based On Blockchain
Design and Implementation of Traceability System Based On Blockchain
Abstract: The fifth Plenary Session of the 19th CPC Central Committee included poverty alleviation and rural revitalization
as the main goals of economic and social development during the 14th Five-Year Plan period. Moreover, it has created a new
situation of digital sales of poverty alleviation and helps agricultural products such as "agriculture + e-commerce" and
"agriculture + live streaming", and the traceability of agricultural products has attracted much attention. Com14bining the current
social environment background and the investigation and understanding of the existing agricultural product sales mode of poverty
alleviation, we found that the existing sales model chain and the traditional traceability system model have many shortcomings,
such as unclear information sources and easy tampering. Based on this design, the idea of constructing a traceability system
based on blockchain is proposed, and the required technical and economic feasibility is analyzed to confirm the realization of
the idea. It is intended to meet the needs of agricultural product information management, poverty alleviation farmer information
management, product traceability, etc. And through the web page and mobile terminal information interaction, the realization of
agricultural products at any time, mobile, portable query. The final system test can ensure the normal operation of functions and
the security, credibility, and transparency of information, provide new ideas and solutions for the field of targeted poverty
alleviation, and help rural revitalization.
Keywords: Blockchain, Agricultural products traceability, Poverty alleviation and agriculture.
53
The characteristics of blockchain also include the market (from the whole process of production to
decentralization, openness, independence, security, and circulation), and involves multiple links such as the origin,
anonymity. (1) Decentralization of power. Blockchain does processing, transportation, wholesale and sales of agricultural
not rely on a third manager or hardware, nor does it have a products, which is conducive to quality control and product
central server. Each node implements self-verification of data, recall when necessary. The adoption of the agricultural
transmission, and management through distributed products traceability system can realize the traceability of the
computing and storage. (2) Open-minded. Blockchain product source to the processing and circulation process,
technology is open source. In addition to the private ensure that the end users can buy the assured products, and
information kept confidential, the data within the blockchain prevent fake and shoddy agricultural products from entering
is open to everyone, and everyone can enter the blockchain the market [4].
through an open interface for query and development[4]. (3) Throughout the agricultural supply chain, each level of
Security. As long as 51% of all the nodes are not mastered, participation can be classified as producer, processor, carrier,
the data can not be casually tampered with, which makes the regional seller, and retailer. At present, the mainstream
blockchain avoid artificial malicious tampering[4]. (4) agricultural product traceability system is mainly double-
Anonymous nature. The identity information of any node layer traceability combining internal traceability and external
does not need to be disclosed and verified, and the data traceability (Figure 2). This traditional way of traceability has
transfer can be sent anonymously[5]. (5) Traceability. The exposed a variety of problems, such as (1) information is easy
information is uploaded to each block in the blockchain. Each to be tampered with, lost, regional agricultural information
block has the hash value of the previous block. Only by sharing is difficult, low data transmission efficiency, the first
identifying the correct hash block can you get the chain level of agricultural products (crops) traceability difficulty; (2)
connected (Figure 1), which ensures the traceability of the complex system, regulatory information overlap or
informationuse. contradiction, regulatory pressure; (3) users at all levels are
difficult to trust the authenticity of the data [6].
54
process of data collection of breeding. india has established is an important means to guarantee the quality of agricultural
GrapeNet, a traceability platform, to ensure the safety and products. The traditional agricultural supply chain traceability
quality of exported grapes. system is highly dependent on the centralized server. Once the
China has been late to the party on the traceability of server operation fails, the stored data will be lost. In addition,
agricultural products, but it has also been making progress. In in the process of agricultural product industry chain
2004, the former Ministry of Agriculture took the lead in circulation, data sharing is not timely, which easily leads to
starting the pilot traceability system in Beijing and Hebei and the updating speed of traceability information can not keep up
implementing the "pilot project of vegetable product quality with the speed of data query. As a result, traditional
traceability system in Beijing"[12]. In 2008, the state agricultural supply chain traceability systems need to seek
proposed establishing and improving the labeling of new technological solutions to address the aforementioned
agricultural products and establishing and implementing issues.
traceability of agricultural product safety systems. In addition, Because of its own characteristics, blockchain has great
the national vegetable quality and safety traceability system advantages over traditional traceability methods (such as
and other traceability systems are also under construction and Table 1). Compared with the traditional traceability method,
piloted. In 2017, the National Agricultural product quality and the data collection work at the front end of the traceability
safety traceability management information platform was method based on blockchain technology is not very different
officially launched, first launched in Sichuan, Guangdong, from the traditional method, and the huge difference lies in
Shandong, and other places to pilot[13]. the back end. Blockchain technology can provide new
traceability tools that make it easy for consumers to query
4. The Application of Blockchain in agricultural product safety information. In addition, the
blockchain has the characteristics of decentralization, so that
Agricultural Product Traceability each node can share data in real-time through the chain, and
The quality and safety of agricultural products is the all nodes must also fulfill the obligation of jointly maintaining
fundamental guarantee of people's healthy life. The data reliability [21-24].
traceability system of the agricultural products supply chain
Therefore, in view of the problems existing in the current and providing a new idea and approach for the
poverty alleviation system, such as excessive power, lack of implementation of targeted poverty alleviation efforts.
mutual trust, and insufficient sales of agricultural products,
this paper proposes a traceability system for poverty 5. Summary Design of the Traceability
alleviation agricultural products based on blockchain System
technology. In order to solve the storage problem of large text
data, this paper proposes a way to combine blockchain with 5.1. System design ideas
the interstellar Archival System (IPFS) to realize the retrieval The system adopts the construction mode of front-rear-end
and storage of large text data. separation and back-end three-layer architecture. The Web
Through the construction of a traceability system for main interface sets multiple functional modules such as
poverty alleviation agricultural products based on blockchain agricultural products management, poverty alleviation farmer
technology, the poverty problem in the current poverty- management, file management, and traceability coding query
stricken areas is analyzed and the overall plan is implemented. to realize accurate data query and management, and realizes
In this article, we address the need for a blockchain-based the portable query of small programs through data interaction
agri-product traceability system for poverty alleviation from with the client. The back end realizes on-chain data
the point of view of system account management, poverty management, file upload management, data interaction, and
alleviation management and agri-product traceability. Based other functions through the three-tier architecture mode of
on this approach, a traceability system for poverty alleviation blockchain technology, IPFS, and MySQL, as shown in
agricultural products based on blockchain technology ensures Figure 3.
decentralized storage, anti-counterfeiting, and traceability of
data, thus effectively improving the security of system data
55
Figure 3. Overall architecture diagram
5.2. System technical characteristics the exposed RPC interface to communicate with the local
Ethereum nodes and add other nodes to the supply chain.
The system is mainly supported by Ethereum, smart After the successful addition, the nodes will participate in the
contracts, database technology, and other technologies. consensus mechanism of the blockchain system. The
5.2.1. Ethereum Technology transaction information and mining information of each node
As a mature and stable blockchain platform with active on the blockchain will be synchronized to all other nodes, and
updates and development and rich SDK interfaces, Ethereum the traceability query can be carried out at any node, which is
is one of the most important components of the system. also the basis for the system to realize multi-node
By creating genesis. The JSON file, the blockchain on synchronous traceability.
which the system depends, is set as a private chain, so as to The system realizes the interaction with the Ethereum
distinguish it from the main chain on the public network and blockchain platform through the SDK interface, as shown in
enhance the stability and maintainability of the system. Using Figure 4.
the official Ethereum Lightweight SDKweb3.js, you can call
5.2.2. Smart contract writing Using Solidity's online compiler Remix, pre-written smart
A Smart contract is the source code written in the Solidity contracts can be compiled with ABI, files, and bin files. ABI
language. A contract means a set of code (its functions) and files expose all the construction parameters of the contract
data (its status), located on a specific address of the Ethereum and require Java classes based on ABI files.
blockchain. With smart contracts, we can do the functions on web3j provides the packaging of Solidity smart contracts,
Ethereum without third-party involvement. For example, which can directly interact with all smart contracts through
transfers or contracts between users are automatically the resulting packaging objects. After executing commands
executed when certain conditions are not satisfied by the from the command-line tool provided on GitHub via web3j,
actions of the users. the tool is under the specified file path.
56
5.2.3. Database technology products are dependent on most of the data tables of the
Use the relational database MySql to provide the storage of system, and the data on the blockchain is the relevant
basic information, maintain various kinds of data generated information from the agricultural products. Therefore,
during the management and operation of the system, and agricultural product management is the key and difficult point
provide data support for traceability query. of the agricultural products traceability system for poverty
alleviation. The poverty alleviation agricultural products
5.3. System function design traceability system uses Web3J to operate Ethereum smart
According to the functional requirements of the system, the contracts. Web3J enables Java to operate our deployed
main modules of the system are the agricultural product Ethereum private chain and call the smart contract deployed
management module, document management module, above in the form of RPC communication. After the
poverty alleviation farmers management module, traceability administrator links the information related to agricultural
code data tracking, query module, etc. The functions of the products, he returns the block hash corresponding to the
main modules are introduced below. agricultural product information, and then the system will
generate the corresponding traceability QR code and
5.3.1. Agricultural Products Management Module
traceability code of the agricultural product according to the
Agricultural product management is an important module
hash (see Figure 6).
of the system. According to the database design, agricultural
5.3.2. File management module addressing features, every time upload a file, it will generate
The File management module provides the upload files, a unique hash. The corresponding files can be viewed and
modify file information and delete file information function, downloaded on the IPFS through the hash. The traceable two-
upload files and add agricultural products generated dimensional code is stored on the IPFS, ensuring that the
traceability QR code will be saved in IPFS. IPFS is a peer- poverty-alleviation agricultural products are "one thing, one
distributed file system and has a permanent, decentralized code, anti-counterfeiting, and true authentication" (as shown
save and sharing files, point-to-point super media, and content in Figure 7).
5.3.3. Management module for poverty alleviation of poverty alleviation needs the administrator to evaluate
farmers according to their materials and documents and upload the
The peasant household module registers the information of peasant household information. Administrators can also
the poor farmers so that relevant information about the distribute funds to poor households, which will be distributed
farmers can be obtained when tracing the source of the to the farmers' Ethereum accounts. Figure 8 fund distribution
agricultural products. Whether the farmers meet the standard transaction, Figure 9 Ethereum account balance for poor
households.
57
Figure 8. Fund issuance and transaction
5.3.4. Traceability module characters to randomly produce a 32-bit UUID. The UUID is
The traceability module mainly includes two aspects, a 16-decimal number, which is divided into 8 groups of 4 each,
namely the generation of traceability code and traceability QR and the number of repetitions is greatly reduced by using
code. Traceability coding adopts the idea of 8-bit UUID, module 62 to remove characters as indices.
which refers to the generation method of a microblog short The trace QR codes were generated using the ZXing API,
domain name. However, the repetition probability is too high, the implementation principle of this QR code is relatively
and four codes are generated each time, and one code needs simple, according to the height and width of the QR code, and
to be randomly selected. The method uses 62 printable then according to the algorithm in the ZXing, divide it into
one pixel, and fill them with black and white (see Figure 10).
The traceability coding query module obtains the information stored on the blockchain, so as to achieve the
associated block Hash through the traceability coding, and function of the traceability of agricultural products (as shown
through the block Hash obtains the agricultural products in Figure 11).
58
Table 2. Tracetable encoding query test table
test function Test description test result
Enter the correct traceability encoding query to return the correct query result (use case: pass through
Source coding query backtracking
Source code: GKgMsUZg.)
Enter the incorrect traceability code to give the incorrect response prompt pass through
6.2. Test of agricultural product management a breeding address, processing plants, etc. The block hash,
traceability QR code, and traceability code of each poverty
module alleviation product are displayed on this page. When the
This module contains a list of poverty alleviation products administrator adds a poverty alleviation product, the system
and new poverty alleviation products. This page can view will chain the information of the poverty alleviation product,
detailed information on poverty alleviation products, such as and generate the traceability QR code and traceability code.
6.3. Test of the management module of farmers information of farmers. Farmers' information is processed on
the chain when added, and farmers' information is stored in
and processing plants the blockchain. Relevant poverty alleviation materials are
The farmer management module includes the management uploaded and stored in the IPFS. The processing factory
of poverty alleviation farmers, the display of detailed module is the management module of the processing factory
information, and the uploading of related poverty alleviation in the traceability information of poverty alleviation products.
6.4. Document management module test given. Next, test the user interface. Through testing, after
many attempts to modify, and finally, to make the system
This module is the centralized management of the achieve the best efficiency.
documents required by the whole system, such as the QR code The test results confirm that the system basically meets the
of poverty alleviation products, block hash, farmer poverty original design requirements, and the software has full
alleviation materials, etc. The module also records the functionality and a good user interface. The interface
system's operation log and related files uploaded to the IPFS. basically realizes multiple functional modules, including
traceability coding and query module, poverty alleviation
Table 5. File Management Test Table product management module, file management module,
test function Test description test peasant household management module, and so on. The
result system realizes the registration and management of the name,
file Enter the file management page, pass type, planting (breeding) address, and other information about
management can normally upload the file to the through agricultural products, and the function of adding and deleting
IPFS, and generate the types of agricultural products. It has realized the
The file Hash is recorded, and it information registration management of poverty alleviation
can view its contents online farmers and the flow direction management of poverty
alleviation funds.
6.5. Test results
According to the test requirements, the relevant test cases
7. System test
are designed, and the problems in the system are analyzed and This project by analyzing the current poverty alleviation
tested. First, from the perspective of function, the functions of agricultural products sales chain, fund distribution
each module are tested in detail, and specific test cases are mechanism, reference to the traditional product traceability
59
system and information management system, found that the [11] Paulavius R,Grigaitis S,Igumencw A,et al.A decade
existing product traceability system and based on traditional afblockchain:Review of the curent status,challenges,and
software development technology "centralized" information futuredirections[J].Infomatica,2019,30(4):729-748.
management system has some personnel can tamper with [12] Yli-Huumo J,Ko D,Chai S,et al.Where is curent research
poverty alleviation data, agricultural information is difficult cmblackchain technolagy?-Asystematic review[J].PLaS
to verify the root cause, poor fraud, poverty alleviation funds One,2016,11(10):e0163477.
is not transparent, in order to solve the above problems, puts [13] Sai A R, Buckley J,Fitzgerald B,et al.Taxonamy of
forward the chain based on blocks. Based on blockchain and centralizationin public blockchain systens:A systematic
interstellar file system (IPFS) technology of agricultural lierature review[J].Information Processing
products traceability system for demand analysis, mainly &Management,2021,58(4):102584.
including agricultural products management, poverty [14] Yuan Yong, Wang Feiyue, the development status and prospect
alleviation, poor information management, system file of blockchain technology [J]. Journal of Automation, 2016,42
management four modules, and the overall design of the (4): 481-494.
whole system, user interface design, smart contract design, [15] Gearge R V,Harsh H O,Ray P,et al.Foad quality
and the design of the core class. Based on the demand analysis, traceabilityprotatype for restaurants using blockchain and food
the development environment required for the poverty quality dataindex[J].Journal af Cleamer Praduction, 2019,
alleviation product traceability system, including the 240:118021.
operating environment and Ethereum platform, a complete [16] Ali S,Wang G J,Bhuiyan M Z A,et al.Secure data provenance
poverty alleviation system has been constructed, tested, and incloud-eentric Internet of Things via backchain smart
analyzed to ensure the complete operation of various contracts[C]//2018 IEEE SmanWarld, Ubiquitons Intelligence
functions. I believe that the future and prospects of this &Computing,Advanced& Trusted Computing, Scalable
project are also worth looking forward to. Computing &Communications, Cloud& Big Data Computing,
Intemet of Peopleand Smart City Innovation. Guangzhou,
2018:991-998.
References
[17] Bardel B,Lebigot P,Alcamia R,et al.Digital food
[1] Opinions of The General Office of the State Council and The producttraceability: using blockchain in the international
State Council on Accelerating the construction of the tracking commerce [C]// Digital Scienoe,2019.
and testing system for important products [EB / OL]. (2016-01-
12)[2020-11-12]. [18] Li Mingjia, Wang Deng, Zeng Xiaoshan, et al., blockchain-
based food safety traceability system design [J]. Food Science,
[2] Wang Jianzuo, based on the blockchain technology applied to 2019,40 (3): 279-285.
the green organic food traceability system exploration [J].
Rural practical Technology, 2019 (8): 58-59. [19] Shi Liang, Zhang Fuhong, Liu Wenjun, research on fruit and
vegetable agricultural products traceability system based on
[3] Xiao Jing, Luo Hongwei, talk about the implantation of blockchain [J]. Rural economy and Technology, 2019,30 (15):
blockchain technology in food information traceability work 166-169.
[J]. Research on Market Regulation in China, 2019(7): 14-16.
[20] Stamatellis C,Papadopeulos P,Pitrapakis N,et al.A privacy-
[4] Liu Xiuping, Zhao Ming. Theoretical Research and Practice of preserving healthcare framework using hyperledger fabrie [J].
Tracing Management System of Agricultural Product Quality Sensors, 2020, 20(22):6587.
and Safety [J]. Chinese vegetables, 20110 (7): 1-3.
[21] Zhu Xiyong, Li Meng, Ru Chengjian, blockchain-based
[5] Li Wei, food traceability system construction in developed clothing supply chain information traceability research [J].
countries and its enlightenment to China [J]. China security Logistics Engineering and Management, 2021,43 (3): 87-91.
protection report, 2012 (9): 26-29.
[22] Casino F,Kanakaris V,Dasaklis T K,et al.Blockchain-based
[6] Tong LAN, Hu Qiuguang. Comparison of the quality and foodsupply chain traceability:A case study in the dairy
safety system of agricultural products in home and abroad [J]. sector[J].International Journal of Production Research, 2021,
Operation and Management, 2012 (11):94-98. 59(19): 5758-5770.
[7] Zhang Mei. Analysis and comparison of agricultural products [23] Mahamed A,Chantal T,Mahamed O,et al.IoT data qualification
logistics traceability systems in the European Union, USA and fora lagisie chain traceability smant contract [J]. Sensas, 2021,
Japan [J]. World Agriculture, 2014 (4): 136-141. 21(6): 2239.
[8] Li Ying, Zhang Yuejie, Nie Ying. The enlightenment of the [24] Ge Yan, Huang Chaoliang, Chen Ming, et al., and implement
Japanese rice traceability system establishment for China [J]. the HACCP quality traceability model and system
World Agriculture, 2017 (11): 40-46. implementation based on blockchain [J]. Journal of
[9] Chen Jie, Yang Jun, Wu Junhui, et al. Development status and Agricultural Machinery, 2021,52 (6): 369-375.
trend of agricultural product safety traceability system [J]. [25] Yin L H, Feng J Y, Lin S X, e al.A blockchain -
Journal of Agriculture, 2018,8(9):89-94. basedcollabarative training methad for muhi-party data
[10] Meng Decai, scan the code to trace into a habit of how many sharing[J].Computer Communikations,2021(173):70-78.
ways to go?[J]. Agricultural Products Market Weekly, 2018 [26] Wang Hongmei, Yu Yuecheng, food safety traceability
(13): 24-25. research based on blockchain technology [J]. Electronic Design
Engineering, 2019,27 (13): 16-20,25.
60