Blockchain-based traceability system for pig operations
By using a blockchain-based traceability system, each pig is bound with a unique identifier. By combining data collection from IoT devices with the decentralized nature of blockchain, the problems of data centralization and low traceability efficiency in traditional pig traceability systems are solved. This achieves reliable data collection, secure storage, and efficient traceability, thereby enhancing food safety trust and promoting the standardized development of the industry.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUJIAN YONGCHENG AGRI & ANIMAL HUSBANDRY TECH GRP CO LTD
- Filing Date
- 2026-03-04
- Publication Date
- 2026-05-26
AI Technical Summary
Traditional pig traceability systems suffer from problems such as data centralization, susceptibility to tampering, low data collection efficiency, large differences in data formats, severe information silos, broken traceability chains, and inability to quickly and accurately locate problematic links, leading to a crisis of trust in food safety and economic losses.
A blockchain-based traceability system is adopted, which binds a unique individual identifier to each pig and collects structured data by combining IoT devices. By leveraging the decentralized and tamper-proof characteristics of blockchain, the system achieves reliable data collection, secure storage, and efficient sharing. The system uses a storage architecture that separates the main chain and side chains and a smart contract module for data classification and storage, and combines a lightweight index structure for traceability queries.
Ensuring the authenticity and uniqueness of traceability data, improving data storage and transfer efficiency, enabling efficient and accurate traceability queries, promoting collaboration among all parties in the supply chain, enhancing trust, supporting regulatory authorities in rapid verification and enabling consumers to understand the origin of products, and contributing to the standardized management of the pig industry.
Smart Images

Figure CN121767007B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of supply chain management technology, specifically to a blockchain-based traceability system for pig operations. Background Technology
[0002] Traditional pig traceability models often suffer from centralized data storage. Most traceability systems rely on a single organization's server for data management, making the data susceptible to tampering or falsification. The authenticity of crucial information such as quarantine results and feed administration records is difficult to guarantee, leaving consumers and regulatory authorities unable to verify data credibility, potentially triggering a crisis of trust in food safety.
[0003] Meanwhile, traditional traceability systems rely heavily on manual data entry for each stage of the process. This is not only inefficient but also prone to data omissions and errors. The lack of unified data standards among different stakeholders, coupled with significant differences in data formats, creates severe information silos. This hinders efficient data sharing and collaborative verification among farms, transportation companies, and slaughterhouses, leading to breaks in the traceability chain and preventing the formation of a complete data loop covering the entire lifecycle of pigs.
[0004] When pork products experience quality and safety issues, traditional traceability systems are unable to quickly and accurately pinpoint the source of the problem. The traceability process requires significant time to coordinate data retrieval from multiple parties, making it difficult for regulatory authorities to implement swift control measures. This not only results in economic losses but also threatens consumers' health and rights, hindering the standardized development of the pork industry.
[0005] With the continuous maturation of blockchain technology, its decentralized, immutable, and distributed storage characteristics offer a novel approach to solving the challenges of pig traceability. Therefore, developing a pig operation traceability system capable of reliable data collection, secure storage, efficient sharing, and accurate traceability has become an urgent need for the industry. Summary of the Invention
[0006] The purpose of this invention is to provide a blockchain-based traceability system for pig operations to solve the problems mentioned in the background section.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] A blockchain-based traceability system for pig operations includes:
[0009] The data acquisition module is used to collect structured operational event data at each node of the pig's supply chain and bind a unique individual identifier code to each pig.
[0010] The blockchain network consists of multiple supply chain participant nodes that act as consensus nodes. In the data layer of the blockchain network, a main chain for individual traceability is maintained for each pig's individual identifier code to record key status events, and at least one process data side chain is maintained to record related process data.
[0011] The smart contract module, deployed on the blockchain network, includes:
[0012] Data verification contracts are used to verify the data structure of operational event data and the legality of its individual identifier codes;
[0013] Data routing contracts are used to classify verified operational event data into critical state events that require consensus or detailed process data that do not require immediate consensus, based on pre-defined judgment rules corresponding to the business logic of the pig supply chain.
[0014] The consensus triggering and storage contract is used to submit data classified as key state events to participating nodes for consensus, and after consensus is passed, it is stored as a new block in the individual traceability main chain corresponding to the pig individual; at the same time, data classified as detailed process data is stored directly or after lightweight verification in the corresponding process data side chain; each data block stored in the process data side chain contains the association information pointing to the corresponding key state event in the individual traceability main chain;
[0015] The traceability query engine is used to retrieve the key state event sequence sorted by time from the corresponding individual traceability main chain based on the input pig individual identification code, and extract relevant detailed process data from the process data side chain based on the association information, and integrate them to generate a complete traceability file.
[0016] As a preferred option, the data acquisition module specifically includes:
[0017] The pig identification information acquisition unit is used to acquire the breed, date of birth, and initial farm information of the pig to be entered.
[0018] The individual identification code generation unit generates a globally unique individual identification code based on the identity information output by the pig identity information acquisition unit and a cryptographic random number algorithm, and then physically binds the individual identification code to the corresponding pig individual.
[0019] The multi-stage data acquisition unit deploys information acquisition equipment at each node of the supply chain to collect structured operational event data of pigs in the stages of feeding, transportation, slaughtering and distribution. The structured operational event data includes environmental parameters, feed feeding records, disease prevention and control information, location trajectory and quarantine results.
[0020] The data association and encapsulation unit receives operational event data output from the multi-stage data acquisition unit, associates and encapsulates each event data with the corresponding pig individual identifier code, and forms a structured data packet with time sequence markers.
[0021] The local storage and encryption unit performs lightweight encryption on the structured data packets output by the data association and encapsulation unit and temporarily stores them locally on the acquisition node until they are uploaded to the blockchain network for verification and storage.
[0022] As a preferred approach, the construction and data organization process of a blockchain network specifically includes:
[0023] Each participant node in the supply chain submits its identity credentials to the blockchain network's authentication center. After verification, it obtains a unique node identity and key pair. The registered participant node becomes a consensus node with the authority to submit data and vote on consensus.
[0024] When the data collection module generates an individual identifier code for a pig and uploads its initial identity information for the first time, the smart contract module is triggered to call the data verification contract and the data routing contract. The initial identity information is identified as the first critical state event, and all participating nodes vote on this event for consensus. After the vote passes, a new individual traceability main chain is created in the blockchain network data layer for the individual identifier code, and the block containing the initial identity information is used as the genesis block of the main chain.
[0025] After the genesis of the individual traceability main chain, the chain management contract deployed on the consensus node automatically generates at least one process data side chain associated with the individual identifier code; the genesis block of the process data side chain contains the individual identifier code to which it belongs and a reference to the hash value of the genesis block of the individual traceability main chain, thus completing the anchoring between the main chain and the side chain.
[0026] For operational event data that is subsequently collected and verified, the data routing contract classifies it according to preset business rules. Data packets classified as key state events are submitted to participating nodes for multiple rounds of consensus voting. Data packets that pass the vote are packaged into new blocks by the consensus trigger and storage contract and appended to the corresponding individual traceability main chain in chronological order. Data packets classified as detailed process data are directly packaged into data blocks and stored in the corresponding process data side chain by the consensus trigger and storage contract after completing lightweight verification of format and signature.
[0027] When storing detailed process data in the process data sidechain, the consensus trigger and storage contract automatically retrieves the most recent key state event block that is logically related to the process data from the individual traceability main chain, and writes the hash value of the main chain block as the association information into the data block header of the process data sidechain, forming a one-way verifiable reference from the sidechain data to the main chain event;
[0028] The blockchain network maintains an independent lightweight index structure for each individual traceability main chain. This index structure records the individual identifier code, the latest block hash of the main chain, and the identifiers of all associated process data side chains. After receiving a query request, the traceability query engine first accesses this index structure to locate the target main chain and side chain.
[0029] As a preferred solution, the data verification contract is used to verify the data structure of operational event data and the legitimacy of its individual identifiers. The verification process includes:
[0030] Receive the raw data packet of operational events associated with individual pig identification codes submitted by the data acquisition module, parse and extract the individual identification codes; query the individual traceability main chain index maintained in the blockchain network data layer to determine whether the individual identification code already exists in the corresponding main chain, and generate and output the identification code validity verification result;
[0031] Based on the validity verification result of the identification code, when the verification result is valid, the submitter's digital signature of the original package of operational event data is extracted; the current supply chain link to which the individual belongs is determined according to the individual identification code, and the list of authorized node identities corresponding to the link is retrieved from the pre-installed contract; the submitter's digital signature is verified to match any authorized node in the list of authorized node identities, and the node permission verification result is generated and output.
[0032] Based on the node permission verification result, when the verification result indicates that the permissions are granted, the data content fields in the original package of operational event data are parsed; the structure of the data content fields is compared with the predefined standardized data template corresponding to the current supply chain link to check whether the field integrity, data type and numerical range conform to the specifications, and a structured data package is generated and output;
[0033] Calculate the hash value of the structured data packet and compare it with the original hash value carried in the original operational event data packet. If they match, generate a validity verification report containing the structured data packet, the corresponding individual identifier code, and the verification timestamp, and output the report to the data routing contract.
[0034] As a preferred approach, data routing contracts are used to classify verified operational event data into critical state events requiring consensus or detailed process data that does not require immediate consensus, based on pre-defined judgment rules corresponding to the business logic of the pig supply chain; including:
[0035] Receive and parse the legality verification report output from the data verification contract, and extract the structured data packet, individual identifier code and verification timestamp from it;
[0036] Based on the extracted individual identifier, the current supply chain status of the individual pig can be queried from the data layer of the blockchain network;
[0037] Based on the status of the supply chain links, retrieve the preset judgment rule set corresponding to the current link; the judgment rule set defines the conditions for judging different types of event data as critical status events or detailed process data;
[0038] Match the data content fields in the structured data packet with the set of rules for judgment:
[0039] If the data content field represents any of the event types in the establishment of the individual pig's identity, the transformation of the core link of the supply chain, the completion of official quarantine, or the generation of the final product form, then it is classified as a key state event that requires consensus.
[0040] If the data content field represents any of the event types such as periodic records of environmental parameters, routine records of feeding behavior, or continuous status monitoring records during transportation, then it is classified as detailed process data that does not require immediate consensus.
[0041] The output includes data routing instructions containing classification results, individual identifiers, and structured data packets, which are sent to the consensus triggering and storage contract.
[0042] As a preferred approach, consensus triggering and storage contracts are used to perform the following operations:
[0043] Receive data routing instructions from the data routing contract. The data routing instructions include classification results, individual identifiers, and structured data packets.
[0044] When the classification result is a critical state event, the structured data packet is encapsulated into a consensus proposal and broadcast to all participating nodes in the blockchain network to trigger a consensus process based on multiple rounds of voting;
[0045] After the consensus process is completed, when the consensus vote passes, the structured data package and the consensus pass proof are packaged into a new block of key state events, and this new block of key state events is appended to the individual traceability main chain corresponding to the individual identifier code in chronological order;
[0046] When the classification result is detailed process data, lightweight verification is performed on the structured data packet. Lightweight verification includes data format compliance checks and submitter digital signature verification.
[0047] After the lightweight verification is passed, the corresponding individual traceability main chain is queried from the data layer of the blockchain network based on the individual identifier code, and the hash value of the most recent key state event block in the main chain is retrieved based on the business logic time correlation.
[0048] The structured data packet and hash value are encapsulated together into a process data sidechain block, and the process data sidechain block is stored in the process data sidechain corresponding to the individual identifier code;
[0049] Each process data sidechain block stored in the process data sidechain points to the corresponding key state event block in the individual traceability main chain through a hash value, forming a verifiable data association.
[0050] As a preferred solution, source tracing query engines include:
[0051] The query receiving and parsing unit is used to receive traceability query requests submitted by users, parse and extract the individual pig identification code and query range parameters;
[0052] The main chain positioning and traversal unit, based on the extracted individual pig identification code, accesses the lightweight index structure maintained in the blockchain network data layer to quickly locate the corresponding individual traceability main chain; and starting from the genesis block, it traverses the main chain in chronological order, extracts the data content from all key state event blocks, and generates a key state event sequence sorted by timestamp.
[0053] The sidechain association retrieval unit locates all associated process data sidechains for each event in the key state event sequence based on the index structure; by reading the association information recorded in the data block header of the process data sidechain, which is the hash value of the main chain block, it retrieves and filters all detailed process data blocks related to the business logic of the key state event and extracts the structured process data stored inside them.
[0054] The data integration and verification unit associates and integrates the key state event sequence with the relevant detailed process data extracted from the process data sidechain according to the timeline and business logic; at the same time, based on the hash reference relationship of the blockchain, it verifies the integrity of the association between the detailed process data extracted from the sidechain and the key state events of the main chain and whether the data has been tampered with.
[0055] The traceability archive generation and output unit organizes the integrated data into a structured and complete traceability archive based on the verification results and query scope parameters. The complete traceability archive uses key status events as the main timeline and attaches or links corresponding detailed process data to form a visualized pig life cycle operation report, which is then output to query users through API interface or visualization interface.
[0056] As can be seen from the technical solution provided by the present invention above, the beneficial effects of the blockchain-based pig operation traceability system provided by the present invention are:
[0057] Ensuring the authenticity, reliability, and unique traceability of traceability data: The system generates a globally unique individual identifier for each pig and completes physical binding. Combined with structured operational data collected from all links of the supply chain by IoT devices, invalid data is filtered out through encrypted temporary storage and multi-dimensional verification, ensuring the uniqueness, integrity, and security of the data from the source. The immutability of blockchain further prevents data from being tampered with, providing reliable data support for the traceability of pigs throughout their entire life cycle.
[0058] Improve data storage and transfer efficiency: Adopt a storage architecture that separates the main chain and side chains. Key state events are stored on the main chain after consensus among multiple parties, while detailed process data is stored on the side chain after lightweight verification. This ensures the authority of core data while avoiding a large amount of redundant data occupying main chain resources. Smart contracts enable the full automation of data verification, classification, and storage without human intervention, reducing human error and improving the efficiency and standardization of data transfer.
[0059] Achieve efficient and accurate traceability query services: Relying on a lightweight index structure, the traceability query engine can quickly locate the main chain and side chain of the target pig, accurately match key events and detailed process data through hash association technology, and integrate and generate a visualized full life cycle operation report; the query process does not need to traverse the entire blockchain network, greatly shortening the response time and meeting the diverse query needs of regulatory authorities, enterprises and consumers;
[0060] Promoting multi-party collaboration and standardized development of the supply chain: All participants in the supply chain act as consensus nodes in data verification and storage, achieving transparent data sharing, breaking down information barriers, and enhancing trust among all parties; regulatory authorities can quickly verify pig quarantine and circulation through the system, enterprises can trace problematic links in the supply chain in a timely manner, and consumers can clearly understand the source of products, thus helping to standardize the management of the pig industry and improve food safety levels. Attached Figure Description
[0061] Figure 1 This is a schematic diagram of the structure of a blockchain-based traceability system for pig operations according to the present invention. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0063] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific embodiments.
[0064] like Figure 1 As shown, this embodiment of the invention provides a blockchain-based traceability system for pig operations, comprising:
[0065] The data acquisition module is used to collect structured operational event data at each node of the pig's supply chain and bind a unique individual identifier code to each pig.
[0066] The blockchain network consists of multiple supply chain participant nodes that act as consensus nodes. In the data layer of the blockchain network, a main chain for individual traceability is maintained for each pig's individual identifier code to record key status events, and at least one process data side chain is maintained to record related process data.
[0067] The smart contract module, deployed on the blockchain network, includes:
[0068] Data verification contracts are used to verify the data structure of operational event data and the legality of its individual identifier codes;
[0069] Data routing contracts are used to classify verified operational event data into critical state events that require consensus or detailed process data that do not require immediate consensus, based on pre-defined judgment rules corresponding to the business logic of the pig supply chain.
[0070] The consensus triggering and storage contract is used to submit data classified as key state events to participating nodes for consensus, and after consensus is passed, it is stored as a new block in the individual traceability main chain corresponding to the pig individual; at the same time, data classified as detailed process data is stored directly or after lightweight verification in the corresponding process data side chain; each data block stored in the process data side chain contains the association information pointing to the corresponding key state event in the individual traceability main chain;
[0071] The traceability query engine is used to retrieve the key state event sequence sorted by time from the corresponding individual traceability main chain based on the input pig individual identification code, and extract relevant detailed process data from the process data side chain based on the association information, and integrate them to generate a complete traceability file.
[0072] In this embodiment, the data acquisition module is the core data entry point of the blockchain-based pig operation traceability system. It runs through the entire supply chain of individual pigs, and is responsible for accurately collecting structured operational event data. It binds a globally unique individual identifier code to each individual pig and ensures the uniqueness, timeliness, integrity and security of the data through a series of operations such as data association and encrypted temporary storage. This provides high-quality raw data support for subsequent data verification, classification storage and traceability query of the blockchain network.
[0073] The core function of the data acquisition module focuses on data acquisition and preprocessing throughout the entire pig traceability process. Through multi-unit collaboration, it achieves full coverage from initial pig identification information collection to the capture of operational data at each stage of the supply chain. It not only generates a unique identifier for each pig and completes physical binding to ensure the uniqueness of individual traceability, but also performs correlation encapsulation, time-series tagging, and lightweight encryption on the collected multi-dimensional data, ensuring the integrity and security of the data before it is uploaded to the blockchain network. Simultaneously, it prevents data loss through a local temporary storage mechanism, providing the blockchain network with structured data packets that are structurally sound, reliable in origin, and clearly time-seriesed. This is the fundamental guarantee for the data flow of the entire traceability system. The data acquisition module specifically includes:
[0074] Pig identification information acquisition unit:
[0075] This unit is specifically responsible for collecting core basic information about the pigs to be entered, providing raw data support for the generation of individual identification codes and the establishment of pig identities. This unit accurately obtains the pig's breed information, date of birth, and initial farm information through a combination of manual input and data integration with the farm management system. The initial farm information includes key details such as farm name, geographical location, and breeding batch. The collected information must undergo dual verification by both manual verification and system validation to ensure its accuracy and establish a basic identity file for subsequent traceability of the pig throughout its entire life cycle.
[0076] Individual Identifier Code Generation Unit:
[0077] Based on the basic identity information output by the pig identity information acquisition unit, a globally unique individual identifier code is generated using a cryptographic random number algorithm, and this identifier code is then physically bound to the corresponding pig individual. The core algorithm is as follows:
[0078] ,in, This is the globally unique individual identifier (i.e., the pig individual identifier). This is the set of identity information output by the pig identity information acquisition unit. The random numbers are generated using a cryptographic random number algorithm. This algorithm ensures the global uniqueness of the generated individual identification code by hashing the identity information set with the random number, thus avoiding duplicate identification codes for different pig individuals. In the physical binding stage, physical carriers such as ear tags and electronic tags that are not easy to fall off and are tamper-proof are used. The individual identification code is written into the carrier and fixed to the pig individual, realizing a one-to-one correspondence between the identification code and the pig, ensuring that the data in each subsequent stage can be accurately associated with the corresponding individual.
[0079] Multi-stage data acquisition unit:
[0080] Information collection equipment is deployed across the four core stages of the pig supply chain: feeding, transportation, slaughtering, and distribution. This constructs a comprehensive data collection network to automatically capture structured operational event data at each stage. The deployed equipment includes environmental sensors, feed recorders, disease prevention data collection terminals, GPS positioning modules, and quarantine and testing equipment. The collected data covers environmental parameters, feed records, disease prevention information, location trajectories, and quarantine results. Environmental parameters include temperature and humidity, ventilation volume, and ammonia concentration during feeding; and temperature and humidity and ventilation status of the transport compartment during transportation. Feed records include feeding time, feed type, and amount. Disease prevention information includes vaccination time, vaccine type, medication records, and disease testing results. Location trajectories provide real-time location and path information for transportation and distribution. Quarantine results include pre-slaughter quarantine, post-slaughter quarantine, and sampling results during distribution, ensuring that no key operational data is missed in any stage.
[0081] Data association and encapsulation unit:
[0082] This unit receives distributed operational event data from multiple data acquisition units. Following the principle of "individual identifier as the core," it associates each event data with its corresponding pig individual identifier and adds precise time-series markers to each data entry, ultimately encapsulating it into a structured data packet. This unit receives data transmitted from acquisition devices at each stage in real time via a data interface, automatically identifies the corresponding pig individual identifier, and establishes a mapping between data and individuals. The time-series markers use high-precision timestamps, accurate to the second, ensuring the data's temporal order is traceable. The structured encapsulation follows a predefined unified data format, standardizing fields and types to give the data packet a unified structural specification, facilitating subsequent data verification contract validation and blockchain network storage.
[0083] Local temporary storage and encryption unit:
[0084] The structured data packets output by the data association and encapsulation unit undergo lightweight encryption and are temporarily stored on the local storage device of the acquisition node until the data upload conditions are met before being uploaded to the blockchain network. The encryption process uses a lightweight symmetric encryption algorithm, and the encryption formula is as follows:
[0085] ,in, For encrypted structured data packets, The preset encryption key, This is the original structured data packet output by the data association and encapsulation unit. This encryption method ensures data security while avoiding excessive resource consumption by complex encryption algorithms, ensuring efficient operation of the data acquisition and encryption process. Local temporary storage employs a circular storage mechanism; when storage capacity reaches a threshold, the latest data is retained first, while a data verification mechanism ensures that the temporary data is not tampered with or damaged. When communication between the acquisition node and the blockchain network resumes or the preset upload cycle is met, the temporary data will be automatically uploaded to the blockchain network, ensuring no data loss.
[0086] Furthermore, the individual identifier generation is based on a combination of cryptographic random number algorithms and hash operations; cryptographic random number algorithms can generate random numbers with high randomness and unpredictability. This avoids identifier collisions caused by duplicate random numbers; hash operations, on the other hand, process the set of identity information. With random numbers Perform an irreversible transformation to generate a fixed-length individual identifier code. This process ensures that even slight changes in the input information will result in a significant difference in the output identification code, while guaranteeing the uniqueness and unforgeability of the identification code. Through this combination of technologies, each individual pig can obtain a unique identification, providing core evidence for full-process traceability.
[0087] The multi-stage data acquisition unit is based on the principle of collaborative networking of IoT devices. The acquisition devices deployed in each stage establish communication connections with the acquisition nodes through wireless communication technologies (such as LoRa and NB-IoT) to form a distributed acquisition network. Different types of IoT devices collect data according to their functional positioning and preset acquisition frequencies or triggering conditions. For example, environmental sensors collect temperature and humidity data at a frequency of minutes, feed feeding recorders trigger acquisition when feeding occurs, and quarantine equipment automatically uploads results after testing. The acquisition nodes, as data aggregation centers, receive and preliminarily screen the data transmitted by each device in real time to ensure the real-time nature and relevance of data acquisition, and achieve seamless data collection across the entire supply chain.
[0088] The local storage and encryption unit employs lightweight symmetric encryption technology based on a simplified AES encryption algorithm. While retaining the core encryption logic, it optimizes the encryption operation process and reduces the hardware resource requirements of the acquisition nodes; encryption key. The keys are allocated through a blockchain network authentication center and bound to the identity identifier of the data collection node to ensure the security and uniqueness of the keys; during the encryption process, structured data packets... Data packets are divided into fixed-length blocks and accessed via a key. Each data block is encrypted and then concatenated to form an encrypted data packet. Decryption only requires the same key. This allows for the restoration of the original data, ensuring data transmission and temporary storage security while also maintaining data processing efficiency.
[0089] Data association is based on the unique mapping principle of individual identifier codes. Each piece of operational event data collected contains implicit individual association clues (such as the pig identifier bound to the device, or manually entered individual information). The data association and encapsulation unit identifies these clues and associates the data with the corresponding individual identifier codes. A one-to-one mapping relationship is established to ensure clear data ownership; the time stamp is implemented based on the Network Time Protocol (NTP), with the collection node synchronized with the standard time server to add a precise timestamp to each piece of data. This timestamp serves as the core basis for data time-series sorting, ensuring that the pig's operational trajectory can be restored in chronological order during subsequent traceability processes.
[0090] In this embodiment, the blockchain network is the core support architecture of the blockchain-based pig operation traceability system, which is a distributed network jointly composed of nodes from all participants in the supply chain. Through the data organization mode of separating the main chain and side chains, the strict node identity authentication mechanism and consensus mechanism, it realizes the trusted storage, tamper-proof traceability and efficient collaborative management of key status events and detailed process data throughout the pig's life cycle, providing a secure, transparent and verifiable data storage and circulation environment for the entire traceability system.
[0091] The core functions of the blockchain network focus on the distributed storage, consensus verification, and association management of traceability data. It builds a decentralized trust network by accepting nodes from supply chain participants as consensus nodes. It maintains an independent individual traceability main chain and process data side chain for each pig's individual identifier, achieving classified storage of key and detailed data while balancing data security and storage efficiency. Through a consensus mechanism, it ensures the authenticity and consistency of key state event data, and uses hash referencing technology to establish the association between the main chain and side chains, guaranteeing data traceability. Simultaneously, it maintains a lightweight index structure to provide rapid location support for traceability queries, ultimately achieving trusted, searchable, and verifiable traceability data throughout the entire process from collection to storage. The blockchain network includes:
[0092] Certification Center:
[0093] As the core of identity management in the blockchain network, it is responsible for the identity verification, registration, and authorization management of participating nodes. It receives identity credentials submitted by participating nodes in the supply chain, including participant qualification certificates, organization codes, business scope, and other information. It verifies the authenticity and legality of identity credentials through a combination of manual review and system verification. After the review is passed, it assigns a unique node identity identifier and key pair to the participating node. The key pair includes a private key and a public key. The private key is kept by the node for digital signatures, and the public key is stored in the identity database of the certification center for verification. Participating nodes that have completed registration obtain data submission and consensus voting rights and become consensus nodes of the blockchain network. Nodes that have not passed certification or have not registered cannot participate in the data submission and consensus process, ensuring the credibility of network participants.
[0094] Consensus Node:
[0095] Composed of registered and certified supply chain participants, consensus nodes are the core execution units for data submission, consensus voting, and data storage in the blockchain network. Each consensus node stores a complete or lightweight copy of the blockchain network's data and has functions for data reception, consensus voting, block storage, and synchronization. During the processing of critical state event data, consensus nodes receive consensus proposals and participate in multiple rounds of voting, determining the legality and validity of the data based on the voting results. In the data storage phase, consensus nodes write the consensus-reached critical state event blocks and verified detailed process data blocks to their local storage and synchronize them to the entire blockchain network, ensuring data consistency across all nodes. Simultaneously, consensus nodes have the right to report abnormal data or violating nodes in the network to maintain its normal operation.
[0096] Chain management unit:
[0097] Deployed across consensus nodes, the chain management unit is responsible for the creation, maintenance, and anchoring management of the individual traceability main chain and the process data side chain. When the data collection module uploads initial identity information for an individual pig and triggers the main chain creation instruction, the chain management unit calls the relevant contract of the smart contract module to initiate a consensus vote. After the vote passes, an individual traceability main chain is created for the individual's identifier code, and the initial identity information block is used as the genesis block. Subsequently, at least one process data side chain is automatically generated. By writing the individual identifier code and the hash value of the main chain's genesis block into the side chain's genesis block, the anchoring of the main chain and the side chain is completed. During subsequent data storage, the chain management unit monitors the block appending status of the main chain and the side chain in real time to ensure that the blocks are stored in chronological order, while maintaining the association between the main chain and the side chain to ensure the stability and verifiability of the data association.
[0098] Data storage unit:
[0099] It is responsible for the persistent storage and management of various data blocks in the blockchain network, adopting a storage architecture that separates the main chain and side chains. The individual traceability main chain stores key state event blocks that have passed consensus, including key event data such as the establishment of pig identity, the transformation of core links in the supply chain, the completion of official quarantine, and the generation of the final product form. The blocks form a chain structure in chronological order, and each block contains the hash value of the previous block to ensure the immutability of the main chain data. The process data side chain stores detailed process data blocks that have undergone lightweight verification, including data such as periodic records of environmental parameters and routine records of feeding behavior. Each data block contains hash reference information pointing to the corresponding key state event block in the main chain. The data storage unit adopts a distributed storage method, and each consensus node stores a complete or redundant copy of the data to ensure that the data is not lost due to the failure of a single node.
[0100] Lightweight index maintenance unit:
[0101] Each individual traceability main chain maintains an independent lightweight index structure. This index structure records the individual identifier code, the latest block hash value of the main chain, and the identifiers of all associated process data side chains. The lightweight index maintenance unit monitors the block update status of the individual traceability main chain and associated side chains in real time. When a new key state event block is added to the main chain, the latest block hash value of the main chain in the index is updated in a timely manner. When process data side chains are added or adjusted, the side chain identifier information is updated synchronously. This index structure provides a fast location entry point for the traceability query engine, enabling it to quickly find the main chain and side chains corresponding to the target pig individual without traversing the entire blockchain network, greatly improving the efficiency of traceability queries.
[0102] Furthermore, the node identity authentication technology is based on an asymmetric encryption algorithm and an identity credential verification mechanism. After the identity credentials submitted by the participating nodes are verified by the authentication center, the authentication center generates a key pair using an asymmetric encryption algorithm. The core formula is as follows:
[0103] ,in, For public keys, For private keys, It is an asymmetric encryption key generation algorithm. The encryption parameters for the authentication center; the node uses a private key. The submitted data is digitally signed, and other nodes or certification authorities can access it via the public key. Verifying the validity of the signature confirms the legitimate identity of the data submitter; this technology ensures that only authorized consensus nodes can participate in the data submission and consensus process, preventing unauthorized node intrusion and injection of false data;
[0104] The main-sidechain anchoring technology achieves a strong association between the main chain and the sidechain through hash references. When a process data sidechain is created, its genesis block will write the identifier of the pig individual to which it belongs, as well as the hash value of the genesis block of the individual's tracing main chain, forming an anchoring relationship. The core formula is:
[0105] ,in, The genesis block hash of the process data sidechain. For hash operation functions, For individual pig identification codes, This formula traces the origin of each sidechain's genesis block to its hash value. Through this formula, a unique association is formed between the sidechain's genesis block and the main chain's genesis block. Subsequent sidechain data blocks are all based on this anchoring relationship. By referencing the hash values of the corresponding key state event blocks in the main chain, a one-way verifiable link is constructed from the sidechain to the main chain, ensuring the correlation and traceability between sidechain data and main chain events.
[0106] The consensus mechanism employs a multi-round voting consensus model to verify the legitimacy and consistency of key state event data. Once key state event data is submitted to the blockchain network, the consensus triggering and storage contract encapsulates it into a consensus proposal and broadcasts it to all consensus nodes. Each consensus node verifies the authenticity and legitimacy of the proposal based on its stored data and preset rules, and then votes. The voting process must meet a preset pass rate threshold; the core formula is:
[0107] ,in, To increase the vote pass rate, The number of consensus nodes that agree to the vote. The total number of consensus nodes participating in the vote; when When the preset threshold is reached or exceeded, the consensus proposal is approved, and the data is packaged into a new block and added to the individual LakeSource main chain; if the threshold is not reached, the proposal is rejected; this mechanism ensures that key state event data is verified by multiple nodes, guaranteeing the authenticity of the data and consistency with the entire network.
[0108] Hash referencing technology is used to establish the association between the process data sidechain and key state events in the individual traceability main chain. When detailed process data is stored on the sidechain, consensus triggers the storage contract to retrieve the most recent key state event block related to the business logic of that process data from the main chain, calculates the hash value of that block, and writes it into the sidechain data block header. The core formula is:
[0109] ,in, The referenced main chain block hash value, This technology traces the key state event blocks in the main chain corresponding to each individual. Through this technology, each sidechain data block forms a unique reference relationship with a specific block in the main chain. During tracing queries, the key state event corresponding to the main chain can be quickly located through this hash value. At the same time, based on the uniqueness and irreversibility of the hash value, it verifies that the sidechain data has not been tampered with, ensuring the integrity and credibility of the data association.
[0110] Lightweight indexing technology employs a key-value pair storage structure, using the pig's individual identifier as the core key, and associating the latest block hash value of the main chain with the identifiers of all associated process data sidechains; its index structure can be represented as:
[0111] ,in, It is a lightweight index structure. For individual pig identification codes, The latest block hash value on the main chain. to This index identifies all process data sidechains associated with the individual identifier; the index structure is small in size and fast in query speed. The traceability query engine can directly locate the index entry through the individual identifier, quickly obtain the target main chain and sidechain information, avoid traversing the entire blockchain network, and greatly improve data retrieval efficiency.
[0112] In this embodiment, the smart contract module is the core logic execution layer of the blockchain-based pig operation traceability system, deployed in the distributed nodes of the blockchain network. Through the coordinated operation of the three core contracts, it realizes the legality verification, accurate classification and routing, consensus triggering and targeted storage of operational event data at each stage of the pig supply chain. The entire process is automated without human intervention, ensuring the efficiency, standardization and reliability of data flow, and providing solid logical support for data storage and traceability query of the blockchain network.
[0113] The core functionality of the smart contract module focuses on the automated processing of the entire "verification-classification-storage" process for traceability data. The data verification contract is responsible for multi-dimensional legality verification of uploaded operational event data, filtering out invalid and illegal data. The data routing contract, based on pre-defined supply chain business logic rules, accurately classifies verified data into key state events and detailed process data. The consensus triggering and storage contract, based on the classification results, triggers a network-wide consensus process for key state events, storing them on the individual traceability main chain after successful verification. Detailed process data, after lightweight verification, is stored on the process data side chain, establishing a link between side chain data and main chain events. These three contracts seamlessly connect, constructing a standardized processing channel for data from entering the blockchain network to final storage, ensuring data legality, accurate classification, and standardized storage. The smart contract module includes:
[0114] Data Validation Contract:
[0115] This system is specifically responsible for verifying the data structure and the legality of individual identifier codes for operational event data. It employs a four-step verification process to ensure the authenticity, validity, and standardization of data input into the blockchain network. The first step involves receiving the raw operational event data package submitted by the data acquisition module, parsing and extracting the individual identifier code, querying the individual traceability main chain index in the blockchain network's data layer to determine if the identifier code already exists on the corresponding main chain, and generating an identifier code validity verification result. The second step, if the identifier code is valid, extracts the submitter's digital signature from the raw package, determines the pig's current supply chain stage based on the individual identifier code, and retrieves the corresponding authorized node for that stage. The process involves four steps: First, verifying the identity list and confirming that the submitter's digital signature matches any authorized node in the list, generating a node permission verification result. Second, if the submitter has the necessary permissions, parsing the data content fields in the original packet, comparing its structure with the standardized data template corresponding to the current supply chain link, checking the field integrity, data type, and numerical range for compliance with specifications, and generating a structured data packet. Third, calculating the hash value of the structured data packet and comparing it with the original hash value carried in the original packet. If they match, generating a legality verification report containing the structured data packet, individual identifier code, and verification timestamp, and outputting it to the data routing contract.
[0116] Data routing contract:
[0117] Based on pre-defined business logic rules for the pig supply chain, the legitimate data output by the data verification contract is classified into critical state events requiring consensus or detailed process data that does not require immediate consensus. First, the legitimacy verification report is received and parsed, extracting structured data packets, individual identifiers, and verification timestamps. Second, the blockchain network data layer is queried based on the individual identifier to obtain the current supply chain stage status of the pig. Then, the corresponding pre-defined set of judgment rules is retrieved according to the stage status, which clarifies the classification conditions for different event data. Finally, the data content fields of the structured data packets are matched with the set of judgment rules. If the data represents any of the following event types: establishment of individual pig identity, transformation of core supply chain stages, completion of official quarantine, or generation of the final product form, it is classified as a critical state event. If the data represents any of the following event types: periodic recording of environmental parameters, routine recording of feeding behavior, or continuous state monitoring recording during transportation, it is classified as detailed process data. Subsequently, a data routing instruction containing the classification results, individual identifier, and structured data packets is output to the consensus triggering and storage contract.
[0118] Consensus Triggering and Storage Contracts:
[0119] Based on the classification results of the data routing contract, consensus triggering for key state events, data packaging and storage, and lightweight verification and storage operations for detailed process data are performed. When the classification result is a key state event, the structured data packet is encapsulated into a consensus proposal and broadcast to all participating nodes in the blockchain network, triggering a multi-round voting consensus process. After consensus is passed, the structured data packet and the consensus proof are packaged into a new block for the key state event and appended to the corresponding individual traceability main chain in chronological order. When the classification result is detailed process data, lightweight verification is first performed on the structured data packet, including data format compliance checks and submitter digital signature verification. After verification, the corresponding individual traceability main chain is queried based on the individual identifier code to retrieve the hash value of the most recent key state event block related to the business logic of the process data. The structured data packet and the hash value are jointly encapsulated into a process data sidechain block and stored in the corresponding process data sidechain, so that the sidechain block points to the corresponding key state event block in the main chain through the hash value, forming a verifiable data association.
[0120] Furthermore, the core technology of the data verification contract is based on a fusion mechanism of identity authentication, data structure verification, and hash consistency verification; identity authentication adopts digital signature verification technology, and the core formula is:
[0121] ,in, For signature verification results, Public key for authorized nodes, Digital signature for the submitter, The original data package for operational events; the validity of the digital signature is verified using a public key to ensure that the data submitter is an authorized node; the hash consistency verification formula is:
[0122] ,in, For the hash consistency check result, For hash operation functions, For structured data packets, This is the original hash value carried in the original packet; by comparing the two hash values, it is ensured that the data has not been tampered with during transmission.
[0123] The data routing contract employs a precise matching technology between a pre-defined rule set and data content fields. The rule set is stored in a structured format and includes event type determination conditions for each link in the supply chain. Its matching logic can be expressed as:
[0124] in, For the classification results, This is the set of pre-defined judgment rules corresponding to the current supply chain link. This is the data content field of the structured data packet; the function compares the judgment conditions in the rule set with the event type of the data content field, and automatically outputs the corresponding classification result, ensuring that the classification logic is highly consistent with the supply chain business logic and the classification result is accurate.
[0125] Consensus triggering technology is based on a multi-round voting consensus mechanism, and its core formula is:
[0126] ,in, As a consensus outcome, The number of nodes that agree to the vote. The total number of nodes participating in the vote. Set a preset vote pass rate threshold; when When consensus is reached, a new block storage operation is triggered; the associative storage technology is implemented through hash references, and the core formula is:
[0127] ,in, For process data sidechain blocks, Structured data packets for detailed process data. The hash value of the corresponding key state event block in the main chain is used for individual traceability; the hash value of the main chain block is written into the side chain block to establish a one-way verifiable reference from the side chain to the main chain, ensuring the traceability of data association;
[0128] This lightweight verification technology for detailed process data focuses on two core dimensions: data format and digital signature. It improves verification efficiency while ensuring basic data legitimacy. Data format verification quickly determines field integrity and data type compliance by comparing the data packet structure with a preset format template. Digital signature verification adopts the digital signature verification technology used in identity authentication, through formulas... It quickly verifies the legitimacy of the submitter's identity without complex calculations, balancing data security and verification efficiency.
[0129] In this embodiment, the traceability query engine is the "data retrieval and integration core" of the blockchain-based pig operation traceability system. It provides users with a reliable traceability file for the entire life cycle of pigs by accurately locating the target data chain, associating and extracting multi-dimensional data, and verifying and integrating it.
[0130] The traceability query engine is primarily responsible for receiving user traceability query requests, parsing core query parameters, quickly locating the main chain and side chains of the target pig individual using the lightweight index structure of the blockchain network, extracting key state event sequences sorted by time and associated detailed process data, verifying data integrity and correlation through hash references, and finally integrating and generating a structured and visualized full-process traceability archive. This enables the data to be searchable, verifiable, and traceable at all stages of pig breeding and distribution, providing users with efficient, accurate, and reliable traceability services. The traceability query engine includes:
[0131] Query receiving and parsing unit:
[0132] Receive traceability query requests submitted by users through API interface or visual interface. The request content includes the pig individual identification code and optional query range parameters, including time interval, supply chain links, etc.
[0133] The received query requests are format-validated to check whether they contain a valid individual identifier field and to ensure that the request format conforms to the system specifications. If the format does not conform, a standardized error message is returned.
[0134] The core information in the query request is analyzed, and the individual pig identification code is extracted as the core keyword for data retrieval. At the same time, the query range parameters are extracted and standardized to form a structured query instruction, which provides a basis for subsequent data location and filtering.
[0135] Main chain location and traversal unit:
[0136] Based on the extracted individual pig identifier, the lightweight index structure maintained in the blockchain network data layer is accessed. Through the mapping relationship between the identifier and the index, the individual traceability main chain identifier and the associated process data side chain identifier set corresponding to the pig can be quickly located.
[0137] Based on the identified individual traceability main chain identifier, the complete data of the main chain is retrieved from the blockchain network. Starting from the genesis block, all blocks on the main chain are traversed in timestamp order, and key state event data stored in each block are extracted, including information such as event type, occurrence time, participating nodes, and core results.
[0138] The extracted key status event data is sorted by timestamp to generate an ordered sequence of key status events. Each event in the sequence contains a unique block hash value and a business attribute tag, providing an anchor point for subsequent sidechain data association.
[0139] Side-chain related retrieval unit:
[0140] For each event in the sequence of critical state events, locate all process data sidechains associated with that event based on the set of sidechain identifiers recorded in the lightweight index structure;
[0141] Traverse the target process data sidechain, read the associated information recorded in the header of each data block, i.e. the main chain block hash value, and compare the hash value with the main chain block hash value corresponding to the current key state event;
[0142] Select process data blocks that match the hash values, and extract the structured process data stored in the data blocks, including detailed information such as environmental parameters, feed feeding records, and location trajectories, to ensure that the extracted data is highly relevant to the current key status events in terms of business logic;
[0143] Data integration and verification unit:
[0144] Using the key state event sequence as the timeline backbone, the detailed process data extracted by the side chain association retrieval unit is associated and mounted with the corresponding key state events according to the timeline and business logic, forming a hierarchical data structure of "main chain event - side chain data".
[0145] Based on the hash reference relationship of the blockchain, the formula is used to verify whether the hash value of the main chain block in the sidechain data block header is consistent with the hash value of the corresponding event block in the main chain. ,in, For hash verification results, For hash operation functions, For the sidechain data block to be verified, This is the key state event block for the main chain; this verification ensures that the sidechain data has not been tampered with and is validly associated with the main chain events.
[0146] Check the integrated data for any missing, conflicting or other anomalies, mark data with logical conflicts in the timeline and correct them based on consensus records to ensure the consistency and accuracy of the integrated data;
[0147] Source tracing archive generation and output unit:
[0148] Based on the data integration and verification results, and combined with the query range parameters submitted by the user, the data content that meets the conditions is filtered out, and redundant information that exceeds the query range is removed.
[0149] The filtered and integrated data is organized into a structured traceability archive. The archive is based on key status events as the core of the timeline and divided into sub-modules according to the supply chain links. Each key event is attached with corresponding detailed process data, forming a clear hierarchical data structure.
[0150] The structured traceability files are transformed into a visual report on the entire life cycle of pigs. The report includes timeline charts, stage data statistics, key event annotations, and other presentation formats. It is output to users through API interfaces or visual interfaces, and users can view, download, or print it online.
[0151] Furthermore, the lightweight indexing and locating technology is based on a key-value pair storage model, using the pig individual identifier as the core key, and associating it with the latest block hash value of the main chain and the identifiers of all process data sidechains. The index structure expression is as follows: Here, Index is a lightweight index structure. For individual pig identification codes, The latest block hash value on the main chain. to This technology identifies the sidechains used for associated process data. By simplifying index fields and reducing index storage, it enables direct location of the target main chain and sidechains through individual identifiers, avoiding traversing the entire blockchain network and significantly improving data retrieval efficiency.
[0152] Hash association retrieval technology is based on the uniqueness and irreversibility of blockchain hash values. It establishes a mapping between sidechain data and main chain events by recording the hash value of the main chain block in the sidechain data block header. During retrieval, data association is filtered by comparing the hash reference of the sidechain data block with the hash value of the main chain event block. Since hash values are highly sensitive to even small changes in the original data, once the data is tampered with, the hash value will change significantly, thus ensuring that the retrieved sidechain data is authentic and has not been tampered with, and guaranteeing the credibility of the traceability data.
[0153] Data integration technology is based on a dual association rule of timeline and business logic. It uses the timestamps of key status events as the core sorting criterion to bind detailed process data within the same time interval or business process with key events, forming a complete operational trajectory. Data verification technology relies on the hash chain structure of blockchain to verify the hash reference relationship between sidechain data and main chain events, ensuring that the data has not been tampered with during storage and transmission. At the same time, business logic verification checks whether the data conforms to the normal flow pattern of the supply chain and eliminates data conflicts and anomalies.
[0154] The visualization archive generation technology is based on structured data organization and visualization presentation rules. It organizes the integrated traceability data into a hierarchical structure of "timeline-stage-event-details" and presents it in a variety of forms such as charts and lists. By using key status events as core nodes and attaching detailed process data as supplementary information, it forms an intuitive full lifecycle trajectory map. At the same time, it supports users to filter and view by stages, time and other dimensions, reducing the cost of data interpretation for users and improving the traceability experience.
[0155] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A blockchain-based traceability system for pig operations, characterized in that: include: The data acquisition module is used to collect structured operational event data at each node of the pig's supply chain and bind a unique individual identifier code to each pig. The blockchain network consists of multiple supply chain participant nodes that act as consensus nodes. In the data layer of the blockchain network, a main chain is maintained for each individual pig's identification code to record key status events, and at least one process data side chain is maintained to record related process data. The construction and data organization process of the blockchain network specifically includes: Each participant node in the supply chain submits its identity credentials to the blockchain network's authentication center. After verification, it obtains a unique node identity and key pair. The registered participant node becomes a consensus node with the authority to submit data and vote on consensus. When the data collection module generates an individual identifier code for a pig and uploads its initial identity information for the first time, the smart contract module is triggered to call the data verification contract and the data routing contract. The initial identity information is identified as the first critical state event, and all participating nodes vote on this event for consensus. After the vote passes, a new individual traceability main chain is created in the blockchain network data layer for the individual identifier code, and the block containing the initial identity information is used as the genesis block of the main chain. After the genesis of the individual traceability main chain, the chain management contract deployed on the consensus node automatically generates at least one process data side chain associated with the individual identifier code; the genesis block of the process data side chain contains the individual identifier code to which it belongs and a reference to the hash value of the genesis block of the individual traceability main chain, thus completing the anchoring between the main chain and the side chain. For operational event data that is subsequently collected and verified, the data routing contract classifies it according to preset business rules. Data packets classified as key state events are submitted to participating nodes for multiple rounds of consensus voting. Data packets that pass the vote are packaged into new blocks by the consensus trigger and storage contract and appended to the corresponding individual traceability main chain in chronological order. Data packets classified as detailed process data are directly packaged into data blocks and stored in the corresponding process data side chain by the consensus trigger and storage contract after completing lightweight verification of format and signature. When storing detailed process data in the process data sidechain, the consensus trigger and storage contract automatically retrieves the most recent key state event block that is logically related to the process data from the individual traceability main chain, and writes the hash value of the main chain block as the association information into the data block header of the process data sidechain, forming a one-way verifiable reference from the sidechain data to the main chain event; The blockchain network maintains an independent lightweight index structure for each individual traceability main chain. This index structure records the individual identifier code, the latest block hash of the main chain, and the identifiers of all associated process data side chains. After receiving a query request, the traceability query engine first accesses this index structure to locate the target main chain and side chain. The smart contract module, deployed on the blockchain network, includes: Data verification contracts are used to verify the data structure of operational event data and the legality of its individual identifier codes; Data routing contracts are used to classify verified operational event data into critical state events that require consensus or detailed process data that do not require immediate consensus, based on pre-defined judgment rules corresponding to the business logic of the pig supply chain. The consensus triggering and storage contract is used to submit data classified as key state events to participating nodes for consensus, and after consensus is passed, it is stored as a new block in the individual traceability main chain corresponding to the pig individual; at the same time, data classified as detailed process data is stored directly or after lightweight verification in the corresponding process data side chain; each data block stored in the process data side chain contains the association information pointing to the corresponding key state event in the individual traceability main chain; The traceability query engine is used to retrieve the key state event sequence sorted by time from the corresponding individual traceability main chain based on the input pig individual identification code, and extract relevant detailed process data from the process data side chain based on the association information, and integrate them to generate a complete traceability file.
2. The blockchain-based pig operation traceability system according to claim 1, characterized in that: The data acquisition module specifically includes: The pig identification information acquisition unit is used to acquire the breed, date of birth, and initial farm information of the pig to be entered. The individual identification code generation unit generates a globally unique individual identification code based on the identity information output by the pig identity information acquisition unit and a cryptographic random number algorithm, and then physically binds the individual identification code to the corresponding pig individual. The multi-stage data acquisition unit deploys information acquisition equipment at each node of the supply chain to collect structured operational event data of pigs in the stages of feeding, transportation, slaughtering and circulation. The structured operational event data includes environmental parameters, feed feeding records, disease prevention and control information, location trajectory and quarantine results. The data association and encapsulation unit receives operational event data output from the multi-stage data acquisition unit, associates and encapsulates each event data with the corresponding pig individual identifier code, and forms a structured data packet with time sequence markers. The local storage and encryption unit performs lightweight encryption on the structured data packets output by the data association and encapsulation unit and temporarily stores them locally on the acquisition node until they are uploaded to the blockchain network for verification and storage.
3. The blockchain-based pig operation traceability system according to claim 1, characterized in that: The data verification contract is used to verify the data structure of operational event data and the legality of its individual identifier code. The verification process includes: Receive the raw data packet of operational events associated with individual pig identification codes submitted by the data acquisition module, parse and extract the individual identification codes; query the individual traceability main chain index maintained in the blockchain network data layer to determine whether the individual identification code already exists in the corresponding main chain, and generate and output the identification code validity verification result; Based on the validity verification result of the identification code, when the verification result is valid, the submitter's digital signature of the original package of operational event data is extracted; the current supply chain link to which the individual belongs is determined according to the individual identification code, and the list of authorized node identities corresponding to the link is retrieved from the pre-installed contract; the submitter's digital signature is verified to match any authorized node in the list of authorized node identities, and the node permission verification result is generated and output. Based on the node permission verification result, when the verification result indicates that the permissions are granted, the data content fields in the original package of operational event data are parsed; the structure of the data content fields is compared with the predefined standardized data template corresponding to the current supply chain link to check whether the field integrity, data type and numerical range conform to the specifications, and a structured data package is generated and output; Calculate the hash value of the structured data packet and compare it with the original hash value carried in the original operational event data packet. If they match, generate a validity verification report containing the structured data packet, the corresponding individual identifier code, and the verification timestamp, and output the report to the data routing contract.
4. The blockchain-based pig operation traceability system according to claim 3, characterized in that: The data routing contract is used to classify verified operational event data into critical state events requiring consensus or detailed process data that does not require immediate consensus, based on pre-defined judgment rules corresponding to the business logic of the pig supply chain; including: Receive and parse the legality verification report output from the data verification contract, and extract the structured data packet, individual identifier code and verification timestamp from it; Based on the extracted individual identifier, the current supply chain status of the individual pig can be queried from the data layer of the blockchain network; Based on the status of the supply chain links, retrieve the preset judgment rule set corresponding to the current link; the judgment rule set defines the conditions for judging different types of event data as critical status events or detailed process data; Match the data content fields in the structured data packet with the set of rules for judgment: If the data content field represents any of the event types in the establishment of the individual pig's identity, the transformation of the core link of the supply chain, the completion of official quarantine, or the generation of the final product form, then it is classified as a key state event that requires consensus. If the data content field represents any of the event types such as periodic records of environmental parameters, routine records of feeding behavior, or continuous status monitoring records during transportation, then it is classified as detailed process data that does not require immediate consensus. The output includes data routing instructions containing classification results, individual identifiers, and structured data packets, which are sent to the consensus triggering and storage contract.
5. The blockchain-based pig operation traceability system according to claim 4, characterized in that: The consensus triggering and storage contract is used to perform the following operations: Receive data routing instructions from the data routing contract. The data routing instructions include classification results, individual identifiers, and structured data packets. When the classification result is a critical state event, the structured data packet is encapsulated into a consensus proposal and broadcast to all participating nodes in the blockchain network to trigger a consensus process based on multiple rounds of voting; After the consensus process is completed, when the consensus vote passes, the structured data package and the consensus pass proof are packaged into a new block of key state events, and this new block of key state events is appended to the individual traceability main chain corresponding to the individual identifier code in chronological order; When the classification result is detailed process data, lightweight verification is performed on the structured data packet. Lightweight verification includes data format compliance checks and submitter digital signature verification. After the lightweight verification is passed, the corresponding individual traceability main chain is queried from the data layer of the blockchain network based on the individual identifier code, and the hash value of the most recent key state event block in the main chain is retrieved based on the business logic time correlation. The structured data packet and hash value are encapsulated together into a process data sidechain block, and the process data sidechain block is stored in the process data sidechain corresponding to the individual identifier code; Each process data sidechain block stored in the process data sidechain points to the corresponding key state event block in the individual traceability main chain through a hash value, forming a verifiable data association.
6. The blockchain-based pig operation traceability system according to claim 1, characterized in that: The source tracing query engine includes: The query receiving and parsing unit is used to receive traceability query requests submitted by users, parse and extract the individual pig identification code and query range parameters; The main chain positioning and traversal unit, based on the extracted individual pig identification code, accesses the lightweight index structure maintained in the blockchain network data layer to quickly locate the corresponding individual traceability main chain; and starting from the genesis block, it traverses the main chain in chronological order, extracts the data content from all key state event blocks, and generates a key state event sequence sorted by timestamp. The sidechain association retrieval unit locates all associated process data sidechains for each event in the key state event sequence based on the index structure; by reading the association information recorded in the data block header of the process data sidechain, which is the hash value of the main chain block, it retrieves and filters all detailed process data blocks related to the business logic of the key state event and extracts the structured process data stored inside them. The data integration and verification unit associates and integrates the key state event sequence with the relevant detailed process data extracted from the process data sidechain according to the timeline and business logic; at the same time, based on the hash reference relationship of the blockchain, it verifies the integrity of the association between the detailed process data extracted from the sidechain and the key state events of the main chain and whether the data has been tampered with. The traceability archive generation and output unit organizes the integrated data into a structured and complete traceability archive based on the verification results and query scope parameters. The complete traceability archive uses key status events as the main timeline and attaches or links corresponding detailed process data to form a visualized pig life cycle operation report, which is then output to query users through API interface or visualization interface.