A blockchain-based agricultural product whole-chain traceability method and system
By generating transport unit anchor transactions and Merkle trees on the blockchain, the problem of duplicate storage of environmental data for multiple batches of agricultural products in refrigerated transport units is solved, achieving efficient and reliable full-chain traceability and ensuring data consistency and immutability.
Patent Information
- Application Number
- CN202611332947.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-24
AI Technical Summary
When transporting multiple batches of agricultural products in the same refrigerated transport unit, the existing blockchain traceability system wastes storage resources due to the repeated uploading of shared environmental monitoring data to the chain, and it is difficult to guarantee the data consistency between multiple batches.
By generating transport unit anchor transactions, using Merkle trees and subset path proofs, transport units are established as anchor points to bind environmental data transactions, avoiding duplicate storage, and data consistency is guaranteed through cryptographic verification.
It achieves unique storage of shared environment data, avoids waste of storage resources, and ensures the integrity and consistency of data during traceability, thus ensuring the immutability and reliability of the blockchain.
Smart Images

Figure CN123159671A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain traceability technology, and in particular to a blockchain-based method and system for full-chain traceability of agricultural products. Background Technology
[0002] In cross-regional cold chain logistics collaborative traceability scenarios, existing blockchain traceability systems typically package traceability data from each stage of agricultural product production (such as planting records, processing parameters, and logistics environment data) into separate data transactions and record them on the blockchain. Each transaction payload records the batch ID of the agricultural product to which the data belongs as a field. Through this "one data bound to one batch" association method, the system can logically aggregate traceability transactions from various dimensions of the same batch of agricultural products, thereby achieving full-chain traceability from production to sales under normal circumstances.
[0003] However, when the same refrigerated transport unit (such as a refrigerated truck compartment or a cold chain container) simultaneously transports multiple batches of agricultural products from different sources, the environmental monitoring data collected by the onboard IoT sensors (such as temperature, humidity, and vibration inside the compartment) is objectively shared physical environmental data for all batches of agricultural products within the compartment. According to the existing technology's association method, if this shared environmental monitoring data is to be recorded on the blockchain as a traceability basis, since each data transaction can only be bound to one batch ID, the system can only create identical environmental data transactions for each batch of agricultural products within the compartment and record them independently on the blockchain. This results in a large amount of duplicate data being stored on the blockchain, leading to a serious waste of storage resources. Furthermore, because the same data has multiple scattered copies, when supplementary corrections to the original monitoring data are needed (such as data patches after sensor calibration or marking abnormal transport segments), it is difficult to guarantee synchronous updates between multiple copies, easily leading to data inconsistencies and undermining the data economy and maintainability expected under the blockchain's immutability.
[0004] Therefore, in scenarios where multiple batches of agricultural products are transported in the same refrigerated transport unit, how to avoid duplicate recording of shared environmental monitoring data on the blockchain due to multiple batch ownership, while ensuring the consistency of the shared data and its association with multiple batches, is a technical problem that needs to be solved.
[0005] In view of the above, this application is hereby submitted. Summary of the Invention
[0006] The purpose of this application is to propose a blockchain-based method and system for full-chain traceability of agricultural products. The aim is to avoid duplicate recording of shared environmental monitoring data on the blockchain due to multiple batches of agricultural products being transported in the same refrigerated transport unit, while ensuring the consistency of the shared data and its association with multiple batches.
[0007] To address the aforementioned technical problems, this application provides a blockchain-based method for full-chain traceability of agricultural products, employing the following technical solution: Obtain batch information of multiple agricultural product batches loaded in the same transport unit, generate transport unit anchoring transactions that associate multiple agricultural product batches, record the transport unit anchoring transactions to the blockchain, and obtain the transport unit identifier used to identify the transport unit. Based on the transportation unit identifier and the environmental data collected by the transportation unit during transportation, an environmental data transaction is constructed and recorded on the blockchain; A Merkle tree is constructed based on the hash of environmental data transactions, and the resulting Merkle root is associated with the transport unit anchoring transaction. Generate a batch traceability transaction for each of multiple agricultural product batches. The batch traceability transaction contains a subset of path proofs used to verify the integrity of the environmental data transactions associated with that batch. In response to a traceability request for a target batch, the environmental data associated with the target batch is obtained by utilizing the subset path proof in the batch traceability transaction of the target batch and the Merkle root in the transport unit anchoring transaction.
[0008] To address the aforementioned technical problems, this application also provides a blockchain-based full-chain traceability system for agricultural products, employing the following technical solution: A blockchain-based full-chain traceability system for agricultural products includes: The anchoring module is used to obtain batch information of multiple agricultural product batches loaded in the same transport unit, generate transport unit anchoring transactions that associate multiple agricultural product batches, record the transport unit anchoring transactions to the blockchain, and obtain a transport unit identifier used to identify the transport unit. The module is used to construct environmental data transactions based on the transport unit identifier and the environmental data collected by the transport unit during the transport process, and record the environmental data transactions to the blockchain; The computation module is used to construct a Merkle tree based on the hash of environmental data transactions and associate the obtained Merkle root with the transport unit anchor transaction; The proof module is used to generate batch traceability transactions for each batch in multiple agricultural product batches. Each batch traceability transaction contains a subset of path proofs used to verify the integrity of the environmental data transactions associated with that batch. The query module is used to respond to a traceability request for a target batch by using the subset path proof in the batch traceability transaction of the target batch and the Merkle root in the transport unit anchoring transaction to obtain the environmental data content associated with the target batch.
[0009] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution: A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the blockchain-based agricultural product full-chain traceability method as described above.
[0010] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below: A computer-readable storage medium storing computer-readable instructions, which, when executed by a processor, implement the steps of the blockchain-based agricultural product full-chain traceability method as described above.
[0011] Compared with the prior art, this application has the following main advantages: The blockchain-based method for full-chain traceability of agricultural products disclosed in this application obtains batch information of multiple agricultural product batches loaded in the same transport unit, generates transport unit anchor transactions that link multiple agricultural product batches, records the transport unit anchor transactions on the blockchain, and obtains a transport unit identifier to identify the transport unit. By using the transport unit as the anchor object, a unified anchor point aggregating multiple batches is established on the blockchain, enabling subsequent environmental data to be stored and linked around this anchor point, avoiding the redundancy of establishing separate data organization units for each batch.
[0012] Based on the transport unit identifier and the environmental data collected during transport, an environmental data transaction is constructed and recorded on the blockchain. Shared environmental data is bound to the transport unit identifier, but not to any batch identifier, achieving decoupled storage of environmental data and batch identity. Only one copy of the same set of environmental data needs to be stored on the blockchain, fundamentally eliminating the waste of storage resources caused by duplicate recording due to multiple batch ownership.
[0013] A Merkle tree is constructed based on the hash of environmental data transactions, and the resulting Merkle root is associated with the transport unit anchor transaction. Organizing the dispersed environmental data transactions into a Merkle tree and anchoring the root hash to the transport unit anchor transaction provides a unified integrity fingerprint for all environmental data. This ensures data immutability and provides a unique root of trust for subsequent subset verification and data correction. Data correction only requires updating the Merkle root without modifying individual batch records, thus avoiding inconsistencies between multiple copies of data.
[0014] For each batch of multiple agricultural product batches, a batch traceability transaction is generated. This transaction includes a subset of path proofs used to verify the integrity of the associated environmental data transaction. By generating a cryptographic subset of path proofs for each batch, a verifiable association is established between the batch and the shared data. Each batch stores only the proof and not a copy of the environmental data, eliminating the need for multiple copies and ensuring data consistency by automatically associating each batch with the updated data using the existing proofs when the shared data is corrected.
[0015] In response to a traceability request for a target batch, the system utilizes a subset path proof from the batch traceability transaction and a Merkle root from the transport unit anchoring transaction to obtain the environmental data associated with the target batch. During traceability, cryptographic verification using the subset path proof and the Merkle root ensures the integrity and tamper-proof nature of the obtained environmental data, thereby achieving reliable end-to-end traceability and avoiding inconsistencies in verification results caused by multiple data copies. Attached Figure Description
[0016] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is an exemplary system architecture diagram to which this application can be applied; Figure 2 This is a flowchart of an embodiment of the blockchain-based agricultural product full-chain traceability method according to this application; Figure 3 This is a schematic diagram of the structure of an embodiment of the blockchain-based agricultural product full-chain traceability system according to this application; Figure 4 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0019] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0021] like Figure 1 As shown, the system architecture 100 may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0022] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0023] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, e-book readers, MP3 (Moving Picture Experts Group Audio Layer III) players, MP4 (Moving Picture Experts Group Audio Layer IV) players, laptops, and desktop computers, etc.
[0024] Server 105 can be a server that provides various services, such as a backend server that supports the pages displayed on the first terminal device 101, the second terminal device 102, and the third terminal device 103.
[0025] It should be noted that the blockchain-based agricultural product full-chain traceability method provided in this application embodiment is generally executed by terminal devices, and correspondingly, the blockchain-based agricultural product full-chain traceability system is generally set up in the terminal devices.
[0026] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0027] Continue to refer to Figure 2 The diagram illustrates a flowchart of an embodiment of a blockchain-based agricultural product full-chain traceability method according to this application. The blockchain-based agricultural product full-chain traceability method includes the following steps: Step S201: Obtain batch information of multiple agricultural product batches loaded in the same transport unit, generate transport unit anchoring transactions associated with multiple agricultural product batches, record the transport unit anchoring transactions to the blockchain, and obtain a transport unit identifier used to identify the transport unit.
[0028] In this embodiment, the blockchain-based agricultural product full-chain traceability method operates on electronic devices (e.g., Figure 1 The terminal device shown can send or receive data via wired or wireless connection. It should be noted that the aforementioned wireless connection methods may include, but are not limited to, 3G / 4G / 5G connections, Wi-Fi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra-wide band) connections, and other currently known or future wireless connection methods.
[0029] A Logistics Unit Anchoring Transaction (LUAT) is an anchoring transaction created on the blockchain for a physical transport unit. This transaction logically aggregates all shared environmental data generated by the transport unit within a single transport cycle. The transport unit identifier is the transaction hash value obtained after the LUAT is uploaded to the blockchain, serving as a unique identity for the transport unit. Batch information refers to the identification information of multiple agricultural product batches loaded within the same transport unit, which can be obtained from the loading manifest provided by the logistics management system.
[0030] In this embodiment, when refrigerated transport is initiated, the system obtains batch information for multiple agricultural product batches loaded into the same transport unit (e.g., refrigerated truck number CX001) based on the loading list provided by the logistics system. This includes batch A, batch B, etc. A transport unit anchoring transaction is generated, logically linking the aforementioned multiple agricultural product batches. For example, its transaction payload includes a list of batch identifiers consisting of these batch identifiers, a transport start timestamp, a vehicle identifier, and an initial Merkle root (which can be initially set to null). The transport unit anchoring transaction is broadcast to the blockchain network, packaged after consensus, and recorded on the blockchain. The hash value of this transaction is obtained as the transport unit identifier (e.g., the LUAT transaction hash), thereby establishing an anchor point representing this transport unit on the chain.
[0031] Step S202: Based on the transport unit identifier and the environmental data collected by the transport unit during the transport process, construct an environmental data transaction and record the environmental data transaction to the blockchain.
[0032] Environmental data transaction (Shared Dimension Transaction, SDT) refers to a transaction that packages environmental monitoring data shared by all batches within a transport unit into time slices. It uses the transport unit identifier as the data ownership identifier, without being bound to any specific batch identifier.
[0033] In this embodiment, during transportation, onboard IoT sensors continuously collect environmental monitoring data such as temperature, humidity, vibration, and door opening events within the vehicle compartment. This data is physically shared by all batches within the compartment. After acquiring this environmental monitoring data from the sensor system, the system divides the environmental data into multiple data slices. The division method can be based on equal time intervals, such as one slice every 5 minutes, or it can be based on event triggers, such as generating a slice when a door opening event is detected. For each data slice, an environmental data transaction is constructed. The transaction payload includes the transportation unit identifier (LUAT transaction hash), the data collection time period corresponding to the data slice (e.g., T1 to T2), and the environmental data content within that time period, such as temperature and humidity values. The transportation unit identifier is used as the data ownership identifier in the payload, and no batch identifier for any agricultural product batch is written. Each environmental data transaction is recorded on the blockchain in chronological order. Data for the same data slice is stored in only one transaction on the chain, without having to generate the same transaction for each batch.
[0034] Step S203: Construct a Merkle tree based on the hash of the environmental data transaction, and associate the obtained Merkle root with the transport unit anchor transaction.
[0035] A Merkle tree is a type of hash binary tree where the leaf nodes are the hash values of data blocks, and each non-leaf node is the hash of the combination of the hash values of its two child nodes. The hash value of the root is called the Merkle root. The Merkle root can uniquely represent the integrity of all data segments contained in the entire tree.
[0036] In this embodiment, using the transport unit identifier as an index, the transaction hashes of all environmental data transactions corresponding to the transport unit anchored transaction recorded on the blockchain are collected, such as the transaction hashes of SDT1 and SDT2. These transaction hashes are used as leaf nodes, and upper-level nodes are generated according to a Merkle tree construction algorithm (such as pairwise recursive hashing) to construct a Merkle tree. The root hash of this tree is calculated as the Merkle root. The calculated Merkle root is associated with the corresponding transport unit anchored transaction. If an old Merkle root already exists in the transport unit anchored transaction, the old value is replaced with the newly calculated Merkle root; if it has not yet been written, it is written directly. In this way, the transport unit anchored transaction holds the integrity fingerprint of all current environmental data transactions.
[0037] Step S204: Generate a batch traceability transaction for each of the multiple agricultural product batches. The batch traceability transaction contains a subset of path proofs used to verify the integrity of the environmental data transaction associated with that batch.
[0038] Sub-Merkle Proof refers to a cryptographic proof path extracted from a Merkle tree that proves a specific set of leaf nodes is indeed contained within the Merkle tree and that the data is complete. It includes a series of sibling node hashes required to reach the Merkle root from these leaf nodes. Batch traceability transactions are anchored transactions on the blockchain for each agricultural product batch, containing shared data association fields to establish a cryptographic association with the batch's shared environmental data.
[0039] In this embodiment, for each batch within a transport unit, the corresponding transport time period within that transport unit is first obtained; for example, batch A runs from loading time T0 to unloading time T5. Based on this transport time period, environmental data transactions whose data collection time period overlaps with this transport time period are selected from all environmental data transactions covered by the Merkle tree, such as SDT1 and SDT2. For the leaf nodes of these selected environmental data transactions, the Merkle proof generation algorithm is executed to extract the hashes of all sibling nodes required on the path from these leaf nodes to the root of the tree, and these hashes are combined to form the subset path proof corresponding to that batch. Subsequently, a batch tracing transaction for that batch is generated. The transaction payload includes a shared data association field, which may contain the transport unit identifier, the index code of the batch in the batch identifier list, and the aforementioned subset path proof. After this transaction is recorded on the blockchain, a cryptographic association from the batch to the shared environmental data is established without storing an actual copy of the environmental data in the batch tracing transaction.
[0040] Step S205: In response to the traceability request for the target batch, the environmental data content associated with the target batch is obtained by using the subset path proof in the batch traceability transaction of the target batch and the Merkle root in the transport unit anchoring transaction.
[0041] When a consumer, regulator, or other system initiates a traceability request for a specific batch, the system responds by retrieving the batch traceability transaction for that batch from the blockchain. It extracts the shared data association field to obtain the referenced transport unit identifier and subset path proof. Then, it retrieves the transport unit anchoring transaction corresponding to that transport unit identifier and reads the latest Merkle root. Cryptographic verification is performed using the subset path proof and the Merkle root: the root hash is recalculated using the subset path proof and compared with the Merkle root. If they match, it confirms that the associated environmental data transaction is complete and has not been tampered with. After successful verification, environmental data content, such as temperature and humidity values, can be extracted from these environmental data transactions. Combined with the data collection time period, the complete environmental curve experienced by the batch during transportation is reconstructed, ultimately outputting the traceability result containing the environmental data content.
[0042] To improve the efficiency of cross-block queries, as an optional implementation, a Logistics Unit Association Field can be added to the block header of the blockchain. When packaging a block, a node scans all transactions within the block, extracts the LUAT transaction hash values contained therein, arranges these LUAT transaction hash values in lexicographical or chronological order, concatenates the sorted hash values, performs a secondary hash operation, generates the "logistic unit association hash within the block," and writes it to this field. When querying data related to a specific transportation unit, only the block headers of each block need to be scanned to quickly filter out candidate blocks where the logistics unit association hash contains the target LUAT transaction hash. The transportation time period is then matched with the data collection time period of each environmental data transaction within the candidate blocks to filter out environmental data transactions whose data collection time period overlaps with the transportation time period. Environmental data transactions belonging to that batch are accurately extracted from the candidate blocks without traversing all block data, thus significantly improving query efficiency.
[0043] This application obtains batch information from multiple agricultural product batches loaded into the same transport unit, generates transport unit anchoring transactions linking these batches, records these transactions on the blockchain, and obtains a transport unit identifier to identify the transport unit. By using the transport unit as the anchoring object, a unified anchor point aggregating multiple batches is established on the blockchain, enabling subsequent environmental data to be stored and linked around this anchor point, avoiding the redundancy of establishing separate data organization units for each batch.
[0044] Based on the transport unit identifier and the environmental data collected during transport, an environmental data transaction is constructed and recorded on the blockchain. Shared environmental data is bound to the transport unit identifier, but not to any batch identifier, achieving decoupled storage of environmental data and batch identity. Only one copy of the same set of environmental data needs to be stored on the blockchain, fundamentally eliminating the waste of storage resources caused by duplicate recording due to multiple batch ownership.
[0045] A Merkle tree is constructed based on the hash of environmental data transactions, and the resulting Merkle root is associated with the transport unit anchor transaction. Organizing the dispersed environmental data transactions into a Merkle tree and anchoring the root hash to the transport unit anchor transaction provides a unified integrity fingerprint for all environmental data. This ensures data immutability and provides a unique root of trust for subsequent subset verification and data correction. Data correction only requires updating the Merkle root without modifying individual batch records, thus avoiding inconsistencies between multiple copies of data.
[0046] For each batch of multiple agricultural product batches, a batch traceability transaction is generated. This transaction includes a subset of path proofs used to verify the integrity of the associated environmental data transaction. By generating a cryptographic subset of path proofs for each batch, a verifiable association is established between the batch and the shared data. Each batch stores only the proof and not a copy of the environmental data, eliminating the need for multiple copies and ensuring data consistency by automatically associating each batch with the updated data using the existing proofs when the shared data is corrected.
[0047] In response to a traceability request for a target batch, the system utilizes a subset path proof from the batch traceability transaction and a Merkle root from the transport unit anchoring transaction to obtain the environmental data associated with the target batch. During traceability, cryptographic verification using the subset path proof and the Merkle root ensures the integrity and tamper-proof nature of the obtained environmental data, thereby achieving reliable end-to-end traceability and avoiding inconsistencies in verification results caused by multiple data copies.
[0048] In some optional implementations of this embodiment, the step of constructing an environmental data transaction based on the transport unit identifier and the environmental data collected by the transport unit during transport includes: Acquire environmental monitoring data collected by the transportation unit during transportation. The environmental monitoring data is physical environmental data shared by all agricultural product batches within the transportation unit. Environmental monitoring data is divided into time slices to generate environmental data transactions. Each environmental data transaction includes a transport unit identifier and the environmental data content corresponding to that time slice. The transport unit identifier is used as the data ownership identifier for each environmental data transaction.
[0049] Environmental monitoring data refers to the physical environment data shared by all batches of agricultural products within a transport unit. This includes parameters such as temperature, humidity, and vibration collected by sensors inside the carriage, reflecting the overall environmental conditions of the carriage. These parameters are not generated individually for a specific batch, but rather represent the environmental conditions experienced by all batches within the same carriage space. Data attribution identifiers are fields used in environmental data transactions to indicate which transport unit the data belongs to.
[0050] In this embodiment, after obtaining the raw environmental data collected by the sensors, it is marked as transport unit-level data rather than batch-level data. When constructing environmental data transactions, only the transport unit identifier field is set in the transaction payload structure as the basis for data ownership; no batch identifier field is set. The resulting environmental data transaction exists only once on the blockchain, serving all batches within that transport unit.
[0051] This application eliminates the mandatory binding between shared environment data and a single batch by severing the data model, so that the same set of environment data only needs to be uploaded to the chain once, fundamentally eliminating the redundancy of blockchain storage resources caused by multiple batch ownership.
[0052] In some optional implementations of this embodiment, the step of generating environmental data transactions by dividing environmental monitoring data into time slices includes: The environmental monitoring data is divided into multiple data slices; An environmental data transaction is generated for each data slice. Each environmental data transaction includes the transport unit identifier, the data collection time period corresponding to the data slice, and the environmental data content in the data slice. Each environmental data transaction is recorded on the blockchain separately, and the environmental data transaction corresponding to the same data slice is recorded only once.
[0053] Data slicing refers to dividing continuously collected environmental monitoring data into independent data units according to certain rules. The division rules can be fixed time intervals or event triggers.
[0054] In this embodiment, temperature and humidity records collected within the most recent time period can be packaged into a data slice at preset intervals (e.g., every 5 minutes); or when an opening event of a refrigerated truck door is detected, monitoring data for a period of time before and after the door opening is collected as a slice. For each data slice, an environmental data transaction is generated, which includes the transportation unit identifier, the time period corresponding to the slice, and the environmental data content, and is then sent to the blockchain network. For data slices of the same transportation unit within the same time period, regardless of the number of batches loaded in the truck, only one environmental data transaction is generated and uploaded to the blockchain.
[0055] This application ensures the unique storage of shared environmental data by dividing environmental monitoring data into multiple data slices and generating only one environmental data transaction for each data slice. This ensures that data is not duplicated on the blockchain from the execution level, further saving blockchain storage resources and maintaining data consistency.
[0056] In some optional implementations of this embodiment, the steps of constructing a Merkle tree based on the hash of environmental data transactions include: Obtain the transaction hash of the environmental data transaction corresponding to the transport unit anchoring transaction that has been recorded on the blockchain; Construct a Merkle tree using each transaction hash as a leaf node; Calculate the root hash of the Merkle tree as the Merkle root.
[0057] A transaction hash is a unique identifier generated by the blockchain network after each environmental data transaction is recorded on the chain, and it can immutably represent the content of the transaction.
[0058] In this embodiment, using the transport unit identifier as the query condition, all environmental data transactions referencing the transport unit identifier are retrieved from the blockchain ledger, and their transaction hash values are extracted. Then, these hash values are used as leaf nodes of a Merkle tree, and upper-level nodes are generated according to a Merkle tree construction algorithm (such as pairwise recursive hashing) until a unique root hash value, i.e., the Merkle root, is obtained.
[0059] This application provides an efficient cryptographic digest structure by constructing a Merkle tree using the transaction hashes of environmental data transactions as leaf nodes. This structure allows the integrity of any number of environmental data transactions to be compressed into a single hash value of fixed length, laying a mathematical foundation for subsequent subset verification.
[0060] In some optional implementations of this embodiment, the step of constructing a Merkle tree based on the hash of environmental data transactions and associating the obtained Merkle root with the transport unit anchoring transaction includes: Write the initial Merkle root in the transport unit anchoring transaction; When a new environmental data transaction is recorded on the blockchain, the Merkle root is recalculated based on the hash of the updated environmental data transaction to obtain the updated Merkle root; Replace the initial Merkle root in the transport unit anchoring transaction with the updated Merkle root.
[0061] The initial Merkle root refers to the initial value written when the transport unit anchor transaction is created. It can be empty, such as a zero hash, indicating that no environmental data has been added to the chain yet. The updated Merkle root refers to the Merkle root recalculated after new environmental data transactions are added to the chain.
[0062] In this embodiment, an initial Merkle root is written when the transport unit anchor transaction is created. As transport proceeds, environmental data transactions are continuously uploaded to the blockchain. After each new environmental data transaction or periodically, the hashes of all environmental data transactions under that transport unit are retrieved again, the Merkle tree is reconstructed, a new Merkle root is calculated, and an update transaction is generated to replace the old Merkle root in the transport unit anchor transaction with the new value.
[0063] This application achieves the dynamic evolution of the Merkle root as the transportation process progresses by writing an initial Merkle root in the transportation unit anchoring transaction and dynamically updating the Merkle root after adding new environmental data transactions. This provides a trust anchor point update mechanism for the addition and correction of environmental data. When data corrections such as sensor calibration occur, it is only necessary to add a corrected environmental data transaction and update the Merkle root. All batches referencing this transportation unit can be automatically associated with the corrected data state through their respective stored subset path proofs, without the need to modify each batch transaction individually. This solves the data consistency maintenance problem in multi-replica scenarios.
[0064] In some optional implementations of this embodiment, the steps of generating batch traceability transactions for each batch among multiple agricultural product batches include: Obtain the corresponding transportation time period for the batch within the transportation unit; Based on Merkle trees, a subset path proof is generated for environmental data transactions corresponding to transportation time periods; Generate batch traceability transactions, which include transport unit identifiers and subset path proofs.
[0065] The transportation time period refers to the time interval from when a batch of goods is loaded into the transportation unit to when it is unloaded from the transportation unit, which can be obtained through the logistics management system or smart contract records.
[0066] In this embodiment, the loading and unloading times of batch A on refrigerated truck CX001, such as T0 to T5, are determined from the logistics events. Based on this time period, leaf nodes of environmental data transactions whose data collection time periods intersect with T0 to T5 are located in the constructed Merkle tree. For these leaf nodes, the Merkle proof generation algorithm is executed to extract the hashes of all sibling nodes required on the path from these leaf nodes to the root of the tree, and these hashes are combined to form a subset path proof. Subsequently, the transport unit identifier (LUAT transaction hash) and the subset path proof are written into the batch traceability transaction payload of this batch.
[0067] This application generates a subset path proof for the environmental data transactions associated with the transportation time period corresponding to the batch, enabling the batch to cryptographically verify the integrity of its associated environmental data without carrying a copy of the actual environmental data. This achieves complete decoupling of shared data and batch identity, while ensuring that the association relationship cannot be forged.
[0068] In some optional implementations of this embodiment, generating batch traceability transactions for each batch among multiple agricultural product batches includes generating a shared data association field. The steps for generating the shared data association field include: Obtain the transport unit identifier; Obtain the index code of the batch in the multiple agricultural product batches associated with the shipping unit anchored by the exchange; Combine the transport unit identifier, index code, and subset path proof into a shared data association field.
[0069] The index code refers to the position number of the batch in the batch identifier list of the transport unit anchoring transaction.
[0070] In this embodiment, when constructing a batch traceability transaction, the transport unit identifier to which the batch belongs is first obtained; then, a list of batch identifiers, such as A and B, is parsed from the transport unit anchoring transaction payload, and the index position of the current batch in the list is determined, such as 0 for batch A and 1 for batch B, and this value is used as the index code; finally, the transport unit identifier, the index code, and the generated subset path proof are packaged into a structure, namely the shared data association field, and placed into the batch traceability transaction.
[0071] This application constructs a complete verification link from batch to shared environment data by combining transport unit identifier, index code, and subset path proof into a shared data association field. The transport unit identifier provides anchor point positioning, the index code enables rapid identity verification in the batch list, and the subset path proof provides cryptographic data integrity protection. The three work together to achieve efficient and reliable data association.
[0072] In some optional implementations of this embodiment, the step of obtaining the index code of a batch among multiple agricultural product batches associated with a transport unit anchored exchange includes: Obtain a list of batch identifiers associated with the transport unit's anchored transaction. The list of batch identifiers consists of the batch identifiers of multiple agricultural product batches loaded into the transport unit, arranged in sequence. Determine the sequence number of the batch in the batch identifier list, and use the sequence number as the index code.
[0073] The batch identifier list is an ordered sequence of batch identifiers generated from the loading manifest when a transport unit anchoring transaction is created. The sequence number refers to the position number of the batch in the list.
[0074] In this embodiment, the content of the transport unit anchoring transaction is read from the blockchain, and the batch identifier list, such as (B, A, C), is extracted. For batch A, the list is traversed to find the position of A. If the list uses a zero-based index, its sequence number is 1; this sequence number is the index code. This index code is used in the shared data association field.
[0075] This application provides a deterministic method for identifying batches within a transportation unit by obtaining a list of batch identifiers associated with the anchored transaction of the transportation unit and determining the order number of the batches within it as an index code. It also provides a data structure foundation for possible subsequent cross-validation.
[0076] In some optional implementations of this embodiment, the steps following the generation of batch traceability transactions for each batch of multiple agricultural product batches include: When a batch of agricultural products undergoes multiple transit transports, obtain the transport unit identifiers corresponding to the multiple transport units that the batch passes through in sequence, as well as the transport time periods within each transport unit; Generate a corresponding subset path proof for each transportation unit; Multiple transport unit identifiers and their corresponding subset path proofs are recorded sequentially in the batch traceability transaction of that batch according to the transport order.
[0077] Multi-segment transportation refers to the transportation of goods in segments via different transport units from the place of origin to the place of sale, such as refrigerated shipping containers, refrigerated trucks on roads, and refrigerated trucks for last-mile delivery.
[0078] In this embodiment, for batch A, its logistics path is: port cold storage (container), regional distribution center (refrigerated truck CX002), retail store (refrigerated truck CX003). A transport unit anchoring transaction LUAT1 is generated for the first transport segment, LUAT2 for the second segment, and LUAT3 for the third segment. Environmental data transactions and Merkle trees are generated for each transport segment according to the aforementioned method. In the batch traceability transaction for batch A, the shared data association field no longer contains only a reference to a single transport unit, but includes three associated sub-segments. Each sub-segment records the corresponding transport unit identifier (LUAT transaction hash of the first transport segment, LUAT transaction hash of the second transport segment, and LUAT transaction hash of the third transport segment), the time period of each transport segment, and the subset path proof generated for each segment, arranged in transport order.
[0079] This application achieves full coverage of complex multi-segment transportation scenarios by recording the transportation unit identifiers and subset path proofs corresponding to multiple transportation units that a batch sequentially passes through in the batch traceability transaction in the transportation order. This enables continuous traceability of shared environmental data of each segment of the entire cold chain, maintaining the integrity and consistency of data association, without having to create an independent batch identity for each segment of transportation.
[0080] In addition to the methods described in the preceding claims, a cross-validation mechanism for detecting cross-selling and mixed loading based on batch lists and batch traceability transactions may also be included. The batch identifier list of the transport unit anchoring transaction records all batches that the transport unit should load, while the transport unit to which it belongs is declared in each batch traceability transaction through the transport unit identifier and index code. Cross-validation can be performed periodically or at key nodes. This cross-validation can be performed in real time during transport or in batches after transport is completed: checking whether the transport unit referenced by a batch traceability transaction actually exists in the batch identifier list of that transport unit; simultaneously checking whether each batch in the batch identifier list of the transport unit has a legitimate batch traceability transaction referencing that transport unit. If a mismatch is found, for example, a batch traceability transaction references a transport unit but the batch of that transport unit is not in the batch list, it may mean that goods have been switched or recorded incorrectly; conversely, if a batch exists in the batch list but no traceability transaction references that transport unit, it indicates that there may be unrecorded mixed loading or incorrect batch identifiers. If an anomaly is determined, an alarm record is generated and stored on the blockchain. This mechanism further enhances the ability to automatically monitor compliance during the transportation process.
[0081] The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0082] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0083] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0084] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0085] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0086] Further reference Figure 3 As a response to the above Figure 2 The implementation of the method shown in this application provides an embodiment of a blockchain-based full-chain traceability system for agricultural products. This device embodiment is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0087] like Figure 3 As shown, the blockchain-based agricultural product full-chain traceability system 300 described in this embodiment includes: an anchoring module 301, a construction module 302, a calculation module 303, a proof module 304, and a query module 305. Wherein: Anchoring module 301 is used to obtain batch information of multiple agricultural product batches loaded in the same transport unit, generate transport unit anchoring transactions associated with multiple agricultural product batches, record the transport unit anchoring transactions to the blockchain, and obtain a transport unit identifier used to identify the transport unit. Module 302 is used to construct an environmental data transaction based on the transport unit identifier and the environmental data content collected by the transport unit during the transport process, and record the environmental data transaction to the blockchain. Calculation module 303 is used to construct a Merkle tree based on the hash of environmental data transactions and associate the obtained Merkle root with the transport unit anchor transaction; The proof module 304 is used to generate a batch traceability transaction for each of multiple agricultural product batches. The batch traceability transaction contains a subset of path proofs used to verify the integrity of the environmental data transaction associated with the batch. The query module 305 is used to respond to the traceability request for the target batch by using the subset path proof in the batch traceability transaction of the target batch and the Merkle root in the transport unit anchoring transaction to obtain the environmental data content associated with the target batch.
[0088] The blockchain-based agricultural product full-chain traceability system provided in this application obtains batch information of multiple agricultural product batches loaded into the same transport unit, generates transport unit anchoring transactions that link multiple agricultural product batches, records the transport unit anchoring transactions on the blockchain, and obtains a transport unit identifier to identify the transport unit. By using the transport unit as the anchoring object, a unified anchor point aggregating multiple batches is established on the blockchain, enabling subsequent environmental data to be stored and linked around this anchor point, avoiding the redundancy of establishing separate data organization units for each batch.
[0089] Based on the transport unit identifier and the environmental data collected during transport, an environmental data transaction is constructed and recorded on the blockchain. Shared environmental data is bound to the transport unit identifier, but not to any batch identifier, achieving decoupled storage of environmental data and batch identity. Only one copy of the same set of environmental data needs to be stored on the blockchain, fundamentally eliminating the waste of storage resources caused by duplicate recording due to multiple batch ownership.
[0090] A Merkle tree is constructed based on the hash of environmental data transactions, and the resulting Merkle root is associated with the transport unit anchor transaction. Organizing the dispersed environmental data transactions into a Merkle tree and anchoring the root hash to the transport unit anchor transaction provides a unified integrity fingerprint for all environmental data. This ensures data immutability and provides a unique root of trust for subsequent subset verification and data correction. Data correction only requires updating the Merkle root without modifying individual batch records, thus avoiding inconsistencies between multiple copies of data.
[0091] For each batch of multiple agricultural product batches, a batch traceability transaction is generated. This transaction includes a subset of path proofs used to verify the integrity of the associated environmental data transaction. By generating a cryptographic subset of path proofs for each batch, a verifiable association is established between the batch and the shared data. Each batch stores only the proof and not a copy of the environmental data, eliminating the need for multiple copies and ensuring data consistency by automatically associating each batch with the updated data using the existing proofs when the shared data is corrected.
[0092] In response to a traceability request for a target batch, the system utilizes a subset path proof from the batch traceability transaction and a Merkle root from the transport unit anchoring transaction to obtain the environmental data associated with the target batch. During traceability, cryptographic verification using the subset path proof and the Merkle root ensures the integrity and tamper-proof nature of the obtained environmental data, thereby achieving reliable end-to-end traceability and avoiding inconsistencies in verification results caused by multiple data copies.
[0093] In some optional implementations of this embodiment, the construction module 302 is further configured to: Acquire environmental monitoring data collected by the transportation unit during transportation. The environmental monitoring data is physical environmental data shared by all agricultural product batches within the transportation unit. Environmental monitoring data is divided into time slices to generate environmental data transactions. Each environmental data transaction includes a transport unit identifier and the environmental data content corresponding to that time slice. The transport unit identifier is used as the data ownership identifier for each environmental data transaction.
[0094] The blockchain-based agricultural product traceability system provided in this application severs the mandatory binding between shared environmental data and a single batch from the data model, so that the same set of environmental data only needs to be uploaded to the chain once, fundamentally eliminating the redundancy of blockchain storage resources caused by multiple batch ownership.
[0095] In some optional implementations of this embodiment, the construction module 302 is further configured to: The environmental monitoring data is divided into multiple data slices; An environmental data transaction is generated for each data slice. Each environmental data transaction includes the transport unit identifier, the data collection time period corresponding to the data slice, and the environmental data content in the data slice. Each environmental data transaction is recorded on the blockchain separately, and the environmental data transaction corresponding to the same data slice is recorded only once.
[0096] The blockchain-based agricultural product traceability system provided in this application divides environmental monitoring data into multiple data slices and generates only one environmental data transaction for each data slice, ensuring the unique storage of shared environmental data. From the execution level, it ensures that data is not duplicated on the chain, further saving blockchain storage resources and maintaining data consistency.
[0097] In some optional implementations of this embodiment, the calculation module 303 is further configured to: Obtain the transaction hash of the environmental data transaction corresponding to the transport unit anchoring transaction that has been recorded on the blockchain; Construct a Merkle tree using each transaction hash as a leaf node; Calculate the root hash of the Merkle tree as the Merkle root.
[0098] The blockchain-based agricultural product full-chain traceability system provided in this application offers an efficient cryptographic digest structure by constructing a Merkle tree using the transaction hashes of environmental data transactions as leaf nodes. This structure allows the integrity of any number of environmental data transactions to be compressed into a fixed-length hash value, laying a mathematical foundation for subsequent subset verification.
[0099] In some optional implementations of this embodiment, the calculation module 303 is further configured to: Write the initial Merkle root in the transport unit anchoring transaction; When a new environmental data transaction is recorded on the blockchain, the Merkle root is recalculated based on the hash of the updated environmental data transaction to obtain the updated Merkle root; Replace the initial Merkle root in the transport unit anchoring transaction with the updated Merkle root.
[0100] The blockchain-based agricultural product full-chain traceability system provided in this application realizes the dynamic evolution of the Merkle root as the transportation process is carried out by writing the initial Merkle root in the transportation unit anchor transaction and dynamically updating the Merkle root after adding new environmental data transactions. This provides a trust anchor point update mechanism for the addition and correction of environmental data. When data corrections such as sensor calibration occur, it is only necessary to add the corrected environmental data transaction and update the Merkle root. All batches referencing the transportation unit can be automatically associated with the corrected data state through their respective stored subset path proofs, without the need to modify each batch transaction one by one, thus solving the data consistency maintenance problem in multi-replica scenarios.
[0101] In some optional implementations of this embodiment, the proof module 304 is further configured to: Obtain the corresponding transportation time period for the batch within the transportation unit; Based on Merkle trees, a subset path proof is generated for environmental data transactions corresponding to transportation time periods; Generate batch traceability transactions, which include transport unit identifiers and subset path proofs.
[0102] The blockchain-based agricultural product full-chain traceability system provided in this application generates subset path proofs for environmental data transactions associated with the transportation time period corresponding to a batch. This allows the integrity of the associated environmental data to be cryptographically verified without the batch carrying an actual copy of the environmental data. This achieves complete decoupling of shared data and batch identity, while ensuring that the association relationship cannot be forged.
[0103] In some optional implementations of this embodiment, the proof module 304 is further configured to: Obtain the transport unit identifier; Obtain the index code of the batch in the multiple agricultural product batches associated with the shipping unit anchored by the exchange; Combine the transport unit identifier, index code, and subset path proof into a shared data association field.
[0104] The blockchain-based agricultural product traceability system provided in this application constructs a complete verification link from batch to shared environment data by combining transport unit identifiers, index codes, and subset path proofs into shared data association fields. The transport unit identifier provides anchor point positioning, the index code enables rapid identity verification in the batch list, and the subset path proof provides cryptographic data integrity protection. The three work together to achieve efficient and reliable data association.
[0105] In some optional implementations of this embodiment, the proof module 304 is further configured to: Obtain a list of batch identifiers associated with the transport unit's anchored transaction. The list of batch identifiers consists of the batch identifiers of multiple agricultural product batches loaded into the transport unit, arranged in sequence. Determine the sequence number of the batch in the batch identifier list, and use the sequence number as the index code.
[0106] The blockchain-based agricultural product full-chain traceability system provided in this application obtains a list of batch identifiers associated with transactions anchored to transportation units and determines the order number of the batches as an index code. This provides a deterministic method for locating the identity of batches within transportation units and also provides a data structure foundation for possible subsequent cross-validation.
[0107] In some optional implementations of this embodiment, the proof module 304 is further configured to: When a batch of agricultural products undergoes multiple transit transports, obtain the transport unit identifiers corresponding to the multiple transport units that the batch passes through in sequence, as well as the transport time periods within each transport unit; Generate a corresponding subset path proof for each transportation unit; Multiple transport unit identifiers and their corresponding subset path proofs are recorded sequentially in the batch traceability transaction of that batch according to the transport order.
[0108] The blockchain-based agricultural product full-chain traceability system provided in this application records the transportation unit identifiers and subset path proofs corresponding to multiple transportation units that a batch sequentially passes through in the batch traceability transaction in the transportation order. This achieves full coverage of complex multi-segment transportation scenarios, enabling continuous traceability of shared environmental data for each segment of the entire cold chain, maintaining the integrity and consistency of data association, without having to create an independent batch identity for each segment of transportation.
[0109] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0110] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected via a system bus. It should be noted that only the computer device 4 with components 41, 42, and 43 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0111] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0112] The memory 41 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 4. Of course, the memory 41 may also include both the internal storage unit and its external storage device of the computer device 4. In this embodiment, the memory 41 is typically used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for a blockchain-based agricultural product full-chain traceability method. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or will be output.
[0113] In some embodiments, the processor 42 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to execute computer-readable instructions stored in the memory 41 or to process data, for example, to execute computer-readable instructions for the blockchain-based agricultural product full-chain traceability method.
[0114] The network interface 43 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 4 and other electronic devices.
[0115] This application also provides another implementation, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the blockchain-based agricultural product full-chain traceability method described above.
[0116] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0117] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, these embodiments are provided to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A blockchain-based method for tracing agricultural products in a whole chain, characterized in that, include: Obtain batch information of multiple agricultural product batches loaded in the same transport unit, generate transport unit anchoring transactions associated with the multiple agricultural product batches, record the transport unit anchoring transactions to the blockchain, and obtain a transport unit identifier for identifying the transport unit. Based on the transportation unit identifier and the environmental data collected by the transportation unit during transportation, an environmental data transaction is constructed and recorded on the blockchain; A Merkle tree is constructed based on the hash of the environmental data transaction, and the obtained Merkle root is associated with the transport unit anchoring transaction. A batch traceability transaction is generated for each of the plurality of agricultural product batches, the batch traceability transaction containing a subset path proof for verifying the integrity of the environmental data transaction associated with that batch; In response to a traceability request for a target batch, the environmental data associated with the target batch is obtained by utilizing the subset path proof in the batch traceability transaction of the target batch and the Merkle root in the transport unit anchoring transaction. 2.The blockchain-based agricultural product whole-chain traceability method according to claim 1, characterized in that, The step of constructing an environmental data transaction based on the transportation unit identifier and the environmental data collected by the transportation unit during transportation includes: The environmental monitoring data collected by the transportation unit during transportation is obtained, and the environmental monitoring data is the physical environment data shared by all agricultural product batches within the transportation unit; The environmental monitoring data is divided into time slices to generate environmental data transactions. Each environmental data transaction includes the transportation unit identifier and the environmental data content corresponding to the time slice. The transportation unit identifier is used as the data ownership identifier for each environmental data transaction. 3.The blockchain-based agricultural product whole-chain traceability method according to claim 2, characterized in that, The step of generating environmental data transactions by dividing the environmental monitoring data into time slices includes: The environmental monitoring data is divided into multiple data slices; An environmental data transaction is generated for each data slice. Each environmental data transaction includes the transportation unit identifier, the data collection time period corresponding to the data slice, and the environmental data content in the data slice. Each environmental data transaction is recorded on the blockchain separately, and the environmental data transaction corresponding to the same data slice is recorded only once.
4. The blockchain based agricultural commodity whole chain traceability method according to claim 1, characterized in that, The construction of the Merkle tree based on the hash of the environmental data transaction includes: Obtain the transaction hash of the environmental data transaction that has been recorded on the blockchain and corresponds to the transport unit anchoring transaction; Construct a Merkle tree using the transaction hashes as leaf nodes; Calculate the root hash of the Merkle tree as the Merkle root. 5.The blockchain-based agricultural product whole-chain traceability method according to claim 1, characterized in that, The process of constructing a Merkle tree based on the hash of the environmental data transaction and associating the resulting Merkle root with the transport unit anchoring transaction includes: The initial Merkle root is written into the anchoring transaction of the transport unit; When a new environmental data transaction is recorded on the blockchain, the Merkle root is recalculated based on the hash of the updated environmental data transaction to obtain the updated Merkle root; Replace the initial Merkle root in the transport unit anchoring transaction with the updated Merkle root.
6. The blockchain based agricultural commodity whole chain traceability method according to claim 1, characterized in that, The process of generating batch traceability transactions for each of the multiple agricultural product batches includes: Obtain the transportation time period corresponding to the batch within the transportation unit; Based on the Merkle tree, a subset path proof is generated for the environmental data transactions corresponding to the transportation time period; Generate the batch traceability transaction, which includes the transport unit identifier and the subset path proof.
7. The blockchain based agricultural commodity whole chain traceability method according to claim 1, characterized in that, The process of generating batch traceability transactions for each of the multiple agricultural product batches includes generating shared data association fields, which include: Obtain the transport unit identifier; Obtain the index code of the batch in the multiple agricultural product batches associated with the transport unit anchored exchange; The transport unit identifier, the index code, and the subset path proof are combined into the shared data association field.
8. The blockchain-based method for full-chain traceability of agricultural products according to claim 7, characterized in that, Obtaining the index code of the batch among multiple agricultural product batches associated with the shipping unit's anchor exchange includes: Obtain a list of batch identifiers associated with the transaction anchored by the transportation unit. The list of batch identifiers consists of batch identifiers of multiple agricultural product batches loaded into the transportation unit arranged in order. Determine the sequence number of the batch in the batch identifier list, and use the sequence number as the index code.
9. The blockchain-based method for full-chain traceability of agricultural products according to claim 1, characterized in that, After generating batch traceability transactions for each of the multiple agricultural product batches, the process includes: When the agricultural product batch undergoes multiple transit transportations, the transportation unit identifiers and transportation time periods within each transportation unit are obtained for the multiple transportation units that the batch successively passes through. Generate a corresponding subset path proof for each transportation unit; Multiple transport unit identifiers and their corresponding subset path proofs are recorded sequentially in the batch traceability transaction of that batch according to the transport order.
10. A blockchain-based full-chain traceability system for agricultural products, characterized in that, include: An anchoring module is used to obtain batch information of multiple agricultural product batches loaded in the same transport unit, generate transport unit anchoring transactions associated with the multiple agricultural product batches, record the transport unit anchoring transactions to the blockchain, and obtain a transport unit identifier for identifying the transport unit. The construction module is used to construct an environmental data transaction based on the transportation unit identifier and the environmental data collected by the transportation unit during transportation, and record the environmental data transaction to the blockchain; The calculation module is used to construct a Merkle tree based on the hash of the environmental data transaction and associate the obtained Merkle root with the transport unit anchor transaction; The proof module is used to generate a batch traceability transaction for each of the multiple agricultural product batches, wherein the batch traceability transaction includes a subset path proof for verifying the integrity of the environmental data transaction associated with the batch; The query module is used to respond to a traceability request for a target batch by using the subset path proof in the batch traceability transaction of the target batch and the Merkle root in the transport unit anchoring transaction to obtain the environmental data content associated with the target batch.
