Supply chain tracing method and system based on block chain

Through the feature learning and smart contract verification of supply chain nodes, combined with Merkle tree structure and weighted voting mechanism, the problem of missing data silos and trust mechanisms in the traditional supply chain traceability system is solved, and efficient and secure supply chain data traceability and traceability are achieved.

CN120235530AInactive Publication Date: 2025-07-01CHENGTIAN INT SUPPLY CHAIN (SHENZHEN) CO LTD
View PDF 0 Cites 17 Cited by

Patent Information

Application Number
CN202510713856.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-07-01
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional supply chain traceability systems have data silos, information opaqueness, and lack of trust mechanisms in the global cross-border logistics network, resulting in low traceability efficiency and difficult to guarantee authenticity. Blockchain technology has low computing efficiency, insufficient storage redundancy and insufficient privacy protection when processing large-scale supply chain data.

Method used

By learning the product identification information and transaction records of supply chain nodes, a dual hash Merkle tree structure is built, combining smart contract verification and weighted voting mechanisms, a two-layer feedforward neural network and graph convolutional network are used for feature extraction, and a local anomaly factor algorithm and digital signature are introduced to ensure data integrity and optimize the storage and verification process.

Benefits of technology

It improves the objectivity and efficiency of supply chain traceability, reduces the number of verification nodes and network communication overhead, realizes lightweight verification and incremental updates, provides differentiated traceability services, generates intuitive visual traceability reports, and meets the traceability needs of different users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120235530A_ABST
    Figure CN120235530A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of block chains, and discloses a supply chain tracing method and system based on a block chain, and the method comprises the steps: carrying out the collection and feature learning of the product identification information and transaction records of a supply chain node, and obtaining a supply chain transaction feature vector; based on the supply chain transaction feature vector, executing intelligent contract verification strategy confirmation and weighted voting verification on a transaction group to obtain a consensus confirmation block; extracting transaction data from the consensus confirmation block, constructing a double-Hash Merkle tree structure and generating supply chain traceability features; and executing a commodity tracing contract, a quality verification contract and a responsibility judgment contract according to the supply chain tracing characteristics, and generating an execution log and a visual tracing report, thereby reducing the number of verification nodes and network communication overhead while ensuring the block verification reliability, improving the consensus efficiency, and improving the objectivity and efficiency of the tracing process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular, to a blockchain-based supply chain traceability method and system. Background Art

[0002] Traditional supply chain traceability systems have problems such as data islands, information opacity, and lack of trust mechanisms, making it difficult to achieve high efficiency and high credibility traceability in complex logistics networks. Especially in global cross-border logistics networks such as Cheng Tian International, logistics nodes are scattered and data sources are diverse, resulting in difficult effective integration and verification of information, time-consuming traceability processes, and risks of difficult authenticity guarantee.

[0003] As a distributed ledger technology, blockchain provides a new technical path for solving trust problems in supply chain traceability with its characteristics of immutability, traceability, and decentralization. However, traditional blockchain technology faces challenges such as low computing efficiency, storage redundancy, and insufficient privacy protection when dealing with large-scale supply chain data. Especially in the global logistics network environment, how to balance traceability integrity and system performance, and how to ensure secure data sharing between different participants, have become key issues in the application of blockchain to the field of supply chain traceability. Summary of the Invention

[0004] This application provides a blockchain-based supply chain traceability method and system, which while ensuring the reliability of block verification, reduces the number of verification nodes and network communication overhead, improves the consensus efficiency, and enhances the objectivity and efficiency of the traceability process.

[0005] In the first aspect of this application, a blockchain-based supply chain traceability method is provided. The blockchain-based supply chain traceability method includes: Collect and perform feature learning on product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector; Based on the supply chain transaction feature vector, perform smart contract verification policy confirmation and weighted voting verification on transaction groups to obtain a consensus confirmation block; Extract transaction data from the consensus confirmation block, construct a double-hash Merkle tree structure and generate a supply chain traceability feature; Execute a commodity traceability contract, a quality verification contract, and a liability determination contract according to the supply chain traceability feature to generate an execution log and a visual traceability report.

[0006] In the second aspect of this application, a blockchain-based supply chain traceability system is provided. The blockchain-based supply chain traceability system includes: A feature learning module for collecting and performing feature learning on product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector; A verification module, configured to perform smart contract verification policy confirmation and weighted voting verification on a transaction group based on the supply chain transaction feature vector, and obtain a consensus confirmation block; A construction module, configured to extract transaction data from the consensus confirmation block, construct a double-hash Merkle tree structure, and generate supply chain traceability features; A generation module, configured to execute a product traceability contract, a quality verification contract, and a liability determination contract according to the supply chain traceability features, and generate an execution log and a visual traceability report.

[0007] Compared with the prior art, the present application has the following beneficial effects: By collecting product information in real time through Internet of Things devices, introducing a local anomaly factor algorithm for data anomaly detection, and using digital signatures to ensure data integrity, the problems of poor data quality and difficult authenticity guarantee in traditional traceability systems are solved. By combining a double-layer feedforward neural network, a channel attention mechanism, and a graph convolutional network for feature learning, complex topological relationships and temporal features in supply chain transactions are captured, and similar transactions and abnormal transactions can be identified more accurately compared with traditional methods. By constructing blocks through the combination of cosine similarity grouping and smart contract verification, and introducing a Merkle tree structure to optimize storage, the storage burden of the blockchain network is significantly reduced, and the processing efficiency of the system is improved while maintaining traceability integrity. The proof-of-stake consensus network based on the attention mechanism dynamically allocates the weights of verification nodes through a multi-head self-attention layer, combines sharding technology and a weighted voting mechanism, reduces the number of verification nodes and network communication overhead while ensuring the reliability of block verification, and improves the consensus efficiency. By adopting a double-hash Merkle tree structure and an anchored hash technology, lightweight verification and incremental updates are realized while improving the security of traceability data, and differential traceability services are provided for users with different permissions. Through a hierarchical execution strategy and an event trigger mechanism, product traceability, quality verification, and liability determination are automatically executed, reducing manual intervention, improving the objectivity and efficiency of the traceability process, and generating an intuitive visual traceability report to meet the traceability needs of different users. Description of the Drawings

[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings based on these drawings without creative efforts.

[0009] The structures, proportions, sizes, etc. shown in the accompanying drawings of this specification are only used to cooperate with the content disclosed in the specification for those familiar with this technology to understand and read, and are not used to limit the limited conditions under which the present invention can be implemented. Therefore, they do not have substantial technical significance. Any modification of the structure, change of the proportional relationship, or adjustment of the size, without affecting the effects that the present invention can produce and the purposes that can be achieved, should still fall within the scope that can be covered by the technical content disclosed in the present invention.

[0010] Figure 1 is a schematic flowchart of a blockchain-based supply chain traceability method provided by an embodiment of the present invention; Figure 2 is a schematic block diagram of the structure of a blockchain-based supply chain traceability system provided by an embodiment of the present invention. Specific Embodiments

[0011] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present invention.

[0012] The flowcharts shown in the accompanying drawings are only illustrative, and do not necessarily include all contents and operations / steps, nor do they necessarily need to be executed in the described order. For example, some operations / steps can also be decomposed, combined, or partially merged. Therefore, the actual execution order may be changed according to the actual situation.

[0013] It should also be understood that the terms used in this specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this specification of the present application and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.

[0014] It should be further understood that the term "and / or" used in this specification of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations. Please refer to Figure 1 , an embodiment of the blockchain-based supply chain traceability method in the embodiments of the present application includes: Step 100: Collect and perform feature learning on the product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector; It can be understood that the execution subject of this application can be a blockchain-based supply chain traceability system, or it can also be a terminal or a server, and specific limitations are not made here. In the embodiments of this application, the server is taken as an example of the execution subject for illustration.

[0015] Specifically, product identification information and transaction records are collected in real time through RFID readers, QR code scanners and sensor networks. RFID readers capture product electronic tag information, while QR code scanners identify coded data on product packaging. Sensor networks are used to monitor environmental variables of products in the supply chain, such as temperature, humidity, light intensity, etc., to obtain preliminary filtered data. Quality control is performed on the preliminary filtered data to eliminate obviously invalid data and store valid data. Data cleaning operations are performed to ensure data integrity and consistency. The data cleaning process includes missing value filling, duplicate data removal, outlier identification and correction, etc., to remove abnormal or invalid data points. For example, for RFID read data, if there is missing or incomplete tag information, it is supplemented based on time series interpolation or forward filling methods, and for QR code scanning records, redundant data of repeated scans is removed by pattern matching. All data are uniformly converted to ensure consistency of data format. After data cleaning, a complete data set is formed. The numerical data in the complete data set are normalized to eliminate the influence between different dimensions and ensure that the data distribution is within a comparable range to obtain standardized data. Based on the standardized data, the transaction frequency, logistics residence time and temperature fluctuation amplitude are generated to obtain the enhanced data set. The transaction frequency is calculated from the transaction data to measure the transaction activity of a supply chain node within a certain time range. At the same time, the efficiency of goods circulation is evaluated by the logistics residence time, and the temperature fluctuation amplitude is used to monitor the environmental factors that affect product quality during the supply chain circulation process. The enhanced data set is identified by local anomaly factors to discover potential abnormal transactions. The local anomaly factor is a density-based anomaly detection method that identifies anomalies by calculating the local density deviation of data points. If the transaction frequency of a transaction node is abnormally high, the logistics residence time deviates significantly from the normal range, or the temperature fluctuation amplitude exceeds the normal value of historical data, the transaction data is abnormal. The local anomaly factor method can effectively capture these abnormal behaviors and add abnormal tags to them. The data detected by the local anomaly factor is packaged into a standardized JSON format, which contains complete transaction information, feature data and abnormal tags. In order to ensure the integrity and tamper-proofness of the data, a digital signature is added to the JSON data after packaging for data integrity protection. The digital signature uses an asymmetric encryption algorithm, such as RSA or elliptic curve signature, to ensure that the data will not be tampered with during the data transmission process. Each supply chain node uses a private key to sign the data, and the recipient uses the corresponding public key to verify the authenticity of the data. The digitally signed data is transmitted to the processing queue of the blockchain network through a secure channel. TLS encryption or end-to-end encryption is used in this process to ensure the confidentiality and security of the data. After the data enters the blockchain network, the supply chain transaction graph structure is constructed based on the preprocessed data.A transaction graph is a graph data structure in which each supply chain node is represented as a node in the graph, and transaction behaviors are represented as edges in the graph. This structure can effectively represent the complex relationships in the supply chain. After the transaction graph is constructed, node feature initialization is performed. For example, embedding technology is used to map transaction data into low-dimensional feature vectors, and feature learning is carried out. The feature learning process uses a graph neural network to extract high-order features from the transaction graph, such as the stability of supply chain transactions, the changing trend of transaction frequencies, etc. A supply chain transaction feature vector is obtained.

[0016] Map the transaction information in the supply chain into a graph structure, where the participants in the supply chain are defined as nodes, and the transaction relationships are defined as edges, forming a supply chain transaction graph. In this process, attribute information is assigned to each node, such as enterprise category, credit score, transaction frequency, etc., and attributes are assigned to the edges, such as transaction amount, logistics time, product type, etc., so that the supply chain transaction graph can more comprehensively represent the interaction relationships in the supply chain. Use a two-layer feedforward neural network to process the node features of the supply chain transaction graph to achieve a dense vector representation of the nodes. Through the non-linear transformation of the neural network, the original node attributes are more tightly expressed in the high-dimensional space, thereby enhancing the model's ability to understand the supply chain transaction characteristics. At the same time, batch normalization and activation functions are used in the training process of the feedforward neural network to ensure the stability of the feature distribution, improve the convergence speed of training, and reduce the problem of gradient disappearance. Introduce a channel attention mechanism based on the node dense vector representation to enhance the expression ability of transaction information. Since supply chain transactions involve various types of information, such as procurement transactions, logistics transportation, inventory management, etc., the importance of different transaction types is not equal in the supply chain network. The introduction of the channel attention mechanism calculates the attention scores according to the importance of the transaction information and weights the node features, so that the supply chain transaction characteristics can more accurately capture the importance of the transactions. The channel attention mechanism adopts an adaptive weight allocation method to calculate the influence degree of each transaction category in the supply chain network and adjusts the feature representation accordingly, so that the more critical transaction information occupies a larger weight in the feature learning process and improves the model's ability to understand supply chain transactions. After completing the attention weighting, use the graph convolutional network layer to perform deep feature extraction on the supply chain transaction graph. The graph convolutional network aggregates the node and its neighborhood information through a message passing mechanism, so that the representation of each node not only contains its own features, but also fuses the information of its neighborhood nodes to form local topological structure features. The features of each node are weighted and summed with the features of its adjacent nodes and undergo a non-linear transformation to obtain a more rich feature representation. Input the local topological structure features into the global pooling layer to calculate the importance scores of the nodes and generate a representation of the entire transaction graph. The global pooling layer summarizes the node features of the entire supply chain transaction graph and calculates the influence of each node in the entire network to measure its importance in the supply chain. The calculation of the importance scores is based on factors such as the transaction activity, transaction amount, and credit score of the nodes to ensure that the supply chain transaction feature vector fully reflects the overall structure of the supply chain network. In this process, in order to maintain the consistency of feature expression, a skip connection structure is adopted to fuse the initial features and the deep features to prevent the problem of information loss during the training process of the deep network. The skip connection structure effectively integrates the shallow and deep features to obtain the supply chain transaction feature vector.

[0017] Step 200: Based on the supply chain transaction feature vectors, perform smart contract verification policy confirmation and weighted voting verification on the transaction group to obtain a consensus confirmation block; Specifically, calculate the similarity between supply chain transaction nodes and reasonably group the transactions. Measure the similarity between supply chain transaction feature vectors through cosine similarity. Its calculation method is based on the cosine value of the vector angle, that is, by calculating the inner product of the transaction feature vectors divided by the product of their norms, a similarity score ranging from 0 to 1 is obtained. If the cosine similarity of the feature vectors of two transactions is higher than a preset first threshold, it indicates that they have a high similarity in the supply chain network, belong to the same transaction category or have potential associations, and these transactions are grouped into the same potential block to form a set of potential blocks. Apply an intelligent contract verification strategy to the set of potential blocks to ensure the integrity of transaction data and the rationality of the supply chain process. The intelligent contract automatically executes multiple verification logics, including checking the transaction time sequence, judging the rationality of the logistics path, and auditing the qualifications of transaction participants. The transaction time sequence check is used to confirm whether the transaction time of the same batch of goods conforms to the supply chain business logic. For example, the payment time of a certain transaction should not be later than the shipment time, and the logistics arrival time should be later than the shipment time, otherwise it will be judged as an abnormal transaction. At the same time, the rationality judgment of the logistics path verifies whether the current logistics path conforms to the optimal or reasonable transportation path pattern by analyzing the historical logistics data in the supply chain network. If the appearance of a certain logistics node significantly does not conform to the conventional path, such as detouring or having an abnormally long stay time, it means an abnormal transaction. The participant qualification audit is to ensure that all transaction entities have legal transaction permissions by the intelligent contract calling the registration information, credit score, and transaction records of supply chain enterprises. After being strictly audited by the intelligent contract, only the transactions that meet all the requirements can pass the verification and form a group of verified transactions. Generate a block header and a block body based on the group of verified transactions. The block header contains the hash value of the previous block, a timestamp, the Merkle root hash, and consensus-related information, while the block body stores the specific data of supply chain transactions. To ensure the integrity and immutability of block data, calculate the hash of the transaction data of the complete block to obtain the block hash value. The hash calculation uses the SHA-256 algorithm to convert the transaction data of the entire block into a hash value of a fixed length, so that even if the original data changes slightly, the hash value will be completely different, thus ensuring data security. Select verification nodes based on the block hash value and the proof-of-stake consensus mechanism, and assign weight coefficients to different verification nodes to optimize the block verification efficiency. Under the proof-of-stake mechanism, the verification weight of each node is proportional to the supply chain rights and interests it holds, that is, the node with higher rights and interests has higher influence in the consensus process. And divide the blockchain network into multiple sub-networks to form a sharding verification scheme. Add the blocks that have been verified in the sharding verification scheme to the main chain and broadcast them to all blockchain nodes through the P2P network to ensure the consistency of the blockchain network structure and obtain the blockchain network structure.The broadcast mechanism of the P2P network ensures that all nodes can synchronize the latest block information, thereby preventing data isolation or forks and improving the scalability and anti-attack ability of the entire supply chain blockchain. Based on the blockchain network structure, weighted voting verification is performed on the transactions within the block to achieve network-wide consensus. The weighted voting verification mechanism calculates the node weights based on the reputation scores, historical transaction behaviors, and proof of stake of different nodes in the network, and conducts a final vote on the validity of the block. If a certain transaction is confirmed by a majority of high-weight nodes, the transaction will be officially recorded in the blockchain and confirmed as a consensus confirmation block.

[0018] Select a suitable set of candidate verification nodes from the blockchain network structure. This process involves a comprehensive consideration of multiple factors, including the amount of stake held by the nodes, the historical verification accuracy rate, and the network activity. The consideration of the stake amount comes from the proof-of-stake mechanism, that is, nodes with more supply chain stakes have greater voting rights, while the historical verification accuracy rate reflects whether the nodes can stably and correctly execute the consensus task during the past transaction verification process. Nodes with a high accuracy rate are given higher weights. The network activity measures the frequency and response speed of nodes participating in the blockchain network consensus, so as to ensure that the selection of verification nodes not only depends on the static stake holding situation, but also can be dynamically adjusted to ensure the fairness and reliability of the entire consensus mechanism. Based on these factors, calculate the initial weight allocation scheme, allocate initial weights to each verification node, and ensure that the entire set of candidate verification nodes covers a wide enough range of network participants to improve the decentralization degree of the consensus. Input the block header and block body information in the blockchain network structure into the multi-head self-attention layer to calculate the attention scores, capture the correlations between transactions within the block, and automatically identify which transactions are of higher importance. The multi-head self-attention mechanism enables the model to focus on different aspects of the blockchain transaction data through parallel calculations of multiple attention heads, such as features like the amount, time, parties involved, and historical records of the transactions, thus forming a more accurate attention representation. This step can improve the efficiency of transaction verification, while reducing the bias caused by some malicious nodes attempting to manipulate the transaction verification process, making the entire verification process more robust. Apply the scaled dot-product attention mechanism to the multi-head attention output to calculate the attention-weighted result. The scaled dot-product attention mechanism obtains a more accurate feature representation by calculating the weighted correlations between the query, key, and value, and dynamically adjusts the weights of the verification nodes based on this representation. The weight of each verification node is optimized according to its contribution degree to the block data, rather than relying solely on the initially assigned stake weight or historical reputation score. This dynamic adjustment mechanism provides opportunities for newly joined or low-activity but well-performing nodes while ensuring that high-reputation nodes participate in the consensus first, thus achieving fair optimization of the weights of the verification nodes. After this process, an optimized weight allocation scheme is obtained, enabling the entire consensus process to fully utilize the decision-making ability of high-reputation nodes while avoiding the concentration of weights on a few super nodes, ensuring the decentralization characteristics of the supply chain blockchain network. Guide each verification node to verify the block based on the weight optimization scheme and form a comprehensive verification conclusion. Each verification node checks the transactions in the block according to the assigned weight, including the consistency verification of transaction data, the legality check of transaction signatures, and the rationality analysis of the supply chain transaction flow logic, etc. After all verification nodes complete the transaction verification, the verification results of all nodes are weighted and integrated to form a comprehensive verification conclusion.Perform threshold determination on the comprehensive verification conclusion, that is, set a consensus threshold. Only when nodes exceeding this threshold agree that the block is valid will the block be officially added to the main chain. This method can effectively prevent a small number of malicious nodes from influencing the consensus process by manipulating the voting results and improve the anti-attack ability of the entire blockchain system. After the valid block is added to the main chain, update the reputation scores of the verification nodes to optimize the future consensus process. The reputation score of each verification node is adjusted based on its past verification records, the accuracy of the current verification results, and its performance in the consensus process. If the verification result of a certain node is highly consistent with the final consensus result, the reputation score of this node will be increased, while if the verification result of a certain node deviates too much from the results of most nodes, its reputation score will be decreased, thereby reducing its influence in the future consensus process. The dynamic reputation adjustment mechanism can ensure that the system always preferentially selects high-reputation nodes for verification and can also prevent malicious nodes from accumulating weights by continuously participating in the consensus. Broadcast the consensus confirmation block to all participants through the P2P network so that all nodes can synchronize the latest block information. After the broadcast is completed, the entire blockchain network completes a complete consensus process and ensures that all supply chain transactions are recorded in the blockchain securely, accurately, and immutably to obtain the consensus confirmation block.

[0019] Step 300: Extract transaction data from the consensus confirmation block, construct a double-hash Merkle tree structure, and generate supply chain traceability features; It should be noted that transaction data and corresponding verification results are extracted from the blocks that have been verified by the consensus mechanism, and a unique identifier is assigned to each transaction record to ensure the traceability and uniqueness of the data. The extraction of transaction data includes key elements in supply chain transactions, such as transaction time, product batch number, supply chain participants, logistics track, and quality inspection reports, etc. After the transaction data extraction is completed, these transaction data are used as leaf nodes to construct an initial Merkle tree structure, forming a hierarchical storage method for supply chain transaction data. The SHA-256 algorithm and the RIPEMD-160 algorithm are applied to each node of the initial Merkle tree structure to generate a double-hash Merkle tree structure. The SHA-256 algorithm is used as the first-layer hash processing to ensure the integrity and collision resistance of the transaction data, while the RIPEMD-160 algorithm further compresses the SHA-256 hash result to reduce the storage space requirement and enhance the data security at the same time. The product flow path features are extracted from the double-hash Merkle tree structure to construct a supply chain time series feature set. The extraction of product flow path features depends on the transaction timestamps and logistics node information recorded in the blockchain. By analyzing the time series relationship of the transaction data, the flow path of the product in the supply chain is reconstructed to ensure that the transaction behavior of each supply chain node can be effectively traced. The establishment of the time series feature set can reflect the product circulation situation in the supply chain and identify abnormal transaction patterns, such as delays in the logistics link, abnormal deviations in the product transportation path, or supply chain breakpoints. Based on the time series feature set, a relational network feature set containing product identification index, geographical location index, and time range index is established to improve the queryability and visualization ability of supply chain traceability data. The product identification index associates all relevant transaction data through the product unique identifier, enabling users to query based on the product ID and quickly trace the complete circulation link of a certain product. The geographical location index assigns geographical coordinates to each transaction by analyzing the logistics node information in the transaction data, enabling supply chain managers to analyze the rationality of supply chain circulation based on geographical information and discover abnormal areas, such as whether there are long-term delays or abnormal data tampering in a certain logistics center. The time range index uses the timestamp information of the transaction data to support time interval queries, enabling the supply chain traceability system to restore the complete transaction history of the product in chronological order. The relational network feature set is combined with the time series feature set and the product flow path features to form a supply chain traceability data structure. At the same time, to improve the data security and verifiability, the Merkle root hash value of this chain is written into the public chain in a periodic manner to ensure the verifiability of the supply chain data. Even if the data on this chain changes, the Merkle root hash on the public chain can still be used as the only reference data for traceability verification.

[0020] Step 400: Execute the commodity traceability contract, quality verification contract, and liability determination contract according to the supply chain traceability characteristics, and generate an execution log and a visual traceability report.

[0021] Specifically, create a set of traceability smart contracts, including product traceability contracts, quality verification contracts, and liability determination contracts, and input the supply chain traceability features as parameters into these contracts to ensure that the contracts perform corresponding verification and traceability tasks based on real supply chain data, thus obtaining the set of traceability smart contracts. The supply chain traceability features include the product's transfer path, transaction timestamps, supplier and logistics provider information, environmental monitoring data, etc. Implement a hierarchical execution strategy for the set of traceability smart contracts to optimize the execution order and logic of the smart contracts. The hierarchical execution strategy divides different types of contracts into levels according to the computational complexity and dependencies of the contracts to ensure that there is no resource waste or invalid calculation during the execution process. In this strategy, execute the product traceability contract to determine the complete transfer path and historical transaction records of the product. Subsequently, execute the quality verification contract to analyze the environmental parameters, storage conditions, and quality inspection data of the product in each link of the supply chain and generate a quality assessment report. Finally, execute the liability determination contract. Combining the product traceability results and quality verification data, determine the responsible parties in the supply chain and give a clear liability determination conclusion. After the optimized contract execution plan is determined, the product traceability contract accepts the product's unique identifier and queries the complete supply chain traceability features of the product in the blockchain network. The query process is based on the blockchain's distributed storage mechanism. By accessing the Merkle tree structure of transaction data through a smart contract, all relevant information about the product from raw material supply, production and manufacturing, logistics transportation to final delivery is obtained. During the execution of the product traceability contract, the traceability data is parsed into structured information for subsequent use by the quality verification and liability determination contracts, and at the same time, a product traceability result is generated to intuitively display the product's circulation process. Execute the quality verification contract according to the product traceability result, which includes analyzing the environmental condition monitoring data during the transportation and storage of the product, such as temperature, humidity, vibration intensity, etc., to determine whether the product has experienced abnormal storage or transportation conditions. At the same time, the quality verification contract calls third-party inspection data in the supply chain network, such as laboratory test reports, supplier self-inspection data, etc., to evaluate whether the product quality meets the predetermined standards. By comprehensively calculating the quality loss degree of the product in each link, the quality verification contract generates a quality assessment report. After the quality assessment is completed, the liability determination contract analyzes the liability attribution of each participating party in the supply chain based on the product traceability result and the quality assessment report. The liability determination contract adopts a rule-based determination logic. For example, if the main cause of the quality problem is due to improper storage, the logistics company needs to bear part of the responsibility, while if the raw material composition does not meet the standard, the supplier needs to bear the main responsibility. The contract calculates the liability ratio of each responsible party by analyzing the transaction data, quality reports, and environmental parameters of each supply chain node and generates a liability determination conclusion. Integrate the liability determination conclusion, quality assessment report, and product traceability result into an execution log to ensure that all data and calculation processes of the traceability process are auditable and reproducible.The execution log records the input parameters, contract execution path, and final output results, and also includes the key calculation steps involved in the execution process of the smart contract to support the review of the execution process by supply chain managers and regulatory agencies. To improve the readability and visualization of information, a visual traceability report is generated based on the execution log, which includes the supply chain flow map, quality parameter change curve, and responsible party identification, etc. The supply chain flow map is visually displayed through the geographical location index of blockchain transaction data, presenting the flow path of products from raw material supply to final delivery in an intuitive way. The quality parameter change curve plots the change trends of key quality parameters such as temperature, humidity, and vibration of products based on time series data to evaluate the degree to which product quality is affected by the external environment. The responsible party identification marks the responsibility ratio and determination basis of different participants in the supply chain through graphical means, so that regulatory agencies and enterprises can quickly identify the responsibility attribution.

[0022] In the embodiment of the present application, by collecting product information in real time through Internet of Things devices, introducing a local anomaly factor algorithm for data anomaly detection, and using digital signatures to ensure data integrity, the problems of poor data quality and difficulty in guaranteeing authenticity in traditional traceability systems are solved. By combining a two-layer feedforward neural network, a channel attention mechanism, and a graph convolutional network for feature learning, the complex topological relationships and temporal features in supply chain transactions are captured, and similar transactions and abnormal transactions can be identified more accurately compared with traditional methods. Blocks are constructed by combining cosine similarity grouping and smart contract verification, and the Merkle tree structure is introduced to optimize storage, significantly reducing the storage burden of the blockchain network and improving the processing efficiency while maintaining the traceability integrity of the system. The proof-of-stake consensus network based on the attention mechanism dynamically allocates the weights of verification nodes through multi-head self-attention layers, combines sharding technology and a weighted voting mechanism, reduces the number of verification nodes and network communication overhead while ensuring the reliability of block verification, and improves the consensus efficiency. The double-hash Merkle tree structure and the anchored hash technology are adopted to improve the security of traceability data while realizing lightweight verification and incremental updates, providing differentiated traceability services for users with different permissions. Through a hierarchical execution strategy and an event trigger mechanism, product traceability, quality verification, and responsibility determination are automatically executed, reducing manual intervention, improving the objectivity and efficiency of the traceability process, and generating an intuitive visual traceability report to meet the traceability needs of different users.

[0023] In a specific embodiment, the process of executing step 100 may specifically include the following steps: Collect product identification information and transaction records through RFID readers, QR code scanners, and sensor networks to obtain preliminary filtered data; Perform data cleaning operations on the preliminary filtered data to obtain a complete data set, and perform normalization processing on the numerical data in the complete data set to obtain standardized data; Generate the trading frequency, logistics residence time, and temperature fluctuation range based on the standardized data to obtain an enhanced dataset, and perform local outlier factor identification on the enhanced dataset to obtain outlier-labeled data; Package the outlier-labeled data into a standardized JSON format, add a digital signature for data integrity protection, and transmit it through a secure channel to the processing queue of the blockchain network to obtain preprocessed data; Construct a supply chain transaction graph structure based on the preprocessed data, and perform node feature initialization and feature learning to obtain a supply chain transaction feature vector.

[0024] Specifically, use RFID readers, QR code scanners, and sensor networks to collect data. The RFID reader communicates with the product label via radio waves to obtain the unique identifier, production batch, and supply chain participant information, while the QR code scanner parses the QR code on the product packaging to extract product circulation information such as production time, storage conditions, and logistics tracking number. At the same time, the sensor network monitors the environmental variables in the supply chain, including parameters such as temperature, humidity, and vibration, to ensure that the environment in different transfer links meets the requirements. After these data are initially collected, preliminary filtered data are obtained. Perform data cleaning operations on the preliminary filtered data to remove duplicate records to ensure that the same transaction data is not stored multiple times. The removal of duplicate data relies on the hash comparison method, that is, calculate the hash value for each transaction data and store the transaction record with the unique hash value. For data missing situations, interpolation methods are used for filling, and the specific calculation method is as follows: where represents the value of the current missing data point, and are the known data values at the previous and subsequent time points respectively. For the problem of inconsistent formats, unify the data units. For example, if the temperature data units recorded by some supply chain nodes are different, they are uniformly converted. where is the converted data, is the original data, and are the conversion coefficients, which are determined by the mapping relationship of different data standards. After completing the cleaning operation, a complete dataset is formed. Based on the complete dataset, perform normalization processing to eliminate the influence of dimensions between different features. The normalization uses the min-max normalization method, and its calculation method is as follows: where is the normalized data, is the original data, and are the minimum and maximum values of the data feature respectively. After normalization, each data feature is mapped into the interval [0, 1] to ensure that different features have the same scale, thus improving the stability of subsequent feature learning. Based on the normalized data, key features of supply chain transactions are extracted to construct an enhanced dataset. The transaction frequency is calculated as follows: where represents the transaction frequency of a certain supply chain node, is the number of transactions that occurred at this node during time . The logistics residence time is calculated as: where represents the residence time of a certain product at a supply chain node, and are the timestamps of entering and leaving this node respectively. The temperature fluctuation range is calculated as follows: where represents the temperature change of the product during transportation, and are the highest and lowest temperature values of this product in the supply chain respectively. Through calculation, an enhanced dataset is constructed. Local Outlier Factor (LOF) identification is performed on the enhanced dataset to ensure the reliability of the data. The Local Outlier Factor method is adopted, and its calculation formula is as follows: where represents the distance between the data point and its th nearest neighbor, represents the local density of this nearest neighbor point, is the set number of neighbors. If the value of a certain transaction is much greater than 1, then there is an abnormal situation for this transaction, such as an abnormally extended logistics time or a transaction behavior deviating from the historical pattern. All data identified as abnormal will be marked. After encapsulating the abnormally marked data into a standardized format, a digital signature is added to ensure data integrity. The digital signature adopts hash calculation and asymmetric encryption, and its process is as follows: where is the hash value of the data , is the encryption function, is the encryption key, is the finally generated digital signature. This signature ensures that the data has not been tampered with during transmission and is decrypted with the decryption key Verification is carried out. The encapsulated data is transmitted through an encrypted channel to the processing queue of the blockchain network to ensure the secure storage of supply chain data. Based on the preprocessed data, a supply chain transaction graph structure is constructed, where supply chain nodes serve as vertices in the graph and transaction relationships serve as edges. The supply chain transaction graph is optimized through node feature learning, where feature initialization is represented by an embedding vector, and the initial feature representation of each node is as follows: Among them, is the initial node feature, is the weight matrix, is the node 's original feature vector. After feature initialization, a graph neural network is used for feature learning, and its propagation mechanism is: Among them, represents the node feature of the th layer, is the weight matrix of this layer, is the neighbor set of the node , is the activation function. Through multi-layer propagation, a supply chain transaction feature vector is obtained: Among them, is the supply chain transaction feature vector, is the set of nodes of the entire transaction graph, is the number of layers of the neural network. The supply chain transaction feature vector is used for subsequent smart contract execution and supply chain traceability analysis to improve the transparency and traceability of supply chain data.

[0025] In a specific embodiment, the process of executing the steps to construct a supply chain transaction graph structure based on the preprocessed data and performing node feature initialization and feature learning to obtain a supply chain transaction feature vector may specifically include the following steps: Parse the preprocessed data into a graph structure, set supply chain participants as nodes, transaction relationships as edges, and assign node attributes and edge attributes to obtain a supply chain transaction graph structure; Process the node features of the supply chain transaction graph structure through a two-layer feedforward neural network to obtain a dense vector representation of the nodes; Introduce a channel attention mechanism based on the dense vector representation of the nodes, calculate attention scores according to the importance of different types of transaction information, and obtain a weighted feature representation; Apply a graph convolutional network layer to the weighted feature representation, aggregate node and its neighborhood information through a message passing mechanism, and obtain local topological structure features; Input the local topological structure features into the global pooling layer, calculate the node importance scores, and generate a graph representation. Connect the initial features and the deep features through a skip connection structure to obtain the supply chain transaction feature vector.

[0026] Specifically, parse the preprocessed data into a graph structure, where the participants in the supply chain are set as nodes and the transaction relationships are set as edges, forming a directed graph. In this process, each node is assigned multiple attributes, such as credit scores, transaction frequencies, transaction histories, storage conditions, etc., and each edge contains information such as transaction amounts, timestamps, and logistics paths. In this way, the transaction network of the supply chain is mapped into a graph structure. After constructing the supply chain transaction graph structure, use a two-layer feedforward neural network to process the node features to obtain a dense vector representation of the nodes. Suppose the initial feature vector of a certain supply chain participant is , then the calculation of the first-layer feedforward neural network is as follows: where, represents the hidden representation of the first layer, is the weight matrix, is the bias term, is the activation function. The second-layer feedforward neural network further processes this feature: where, is the final dense vector representation of the node, is the weight matrix of the second layer, is the bias term. Through this two-layer neural network, the node features of the supply chain transaction graph are transformed into a low-dimensional dense representation for subsequent feature extraction and aggregation. After obtaining the dense vector representation of the nodes, introduce a channel attention mechanism to identify the importance of different types of transaction information. Since there are various types of transaction information in the supply chain and the importance of different types of transactions to the overall network varies, use the attention mechanism to calculate the attention scores of each transaction type. Suppose the feature vector of a certain transaction is , then its attention score is expressed as: where, is the importance weight of node to the transaction features of its neighbor node , is the attention weight matrix, represents all the neighbor nodes of node . Based on the calculated attention scores, each transaction feature is assigned a different weight to obtain a weighted feature representation: Among them, represents the final weighted feature of the node , which takes into account the importance of different transaction types, making the representation of supply chain transaction features more accurate. Applying a graph convolutional network layer to the weighted feature representation for feature aggregation to extract the local topological structure features of the supply chain transaction graph. Through the message passing mechanism of the graph convolutional network, the representation of each node not only depends on its own features but also can fuse neighborhood information. The specific calculation formula is as follows: Where, represents the updated feature of the -th node, is the weight matrix of the graph convolutional layer, is the feature representation of the neighbor node , represents the number of neighbor nodes, represents the non-linear activation function. Through the calculation of the graph convolutional network, each node of the supply chain transaction graph aggregates the information of its neighbor nodes layer by layer to form local topological structure features. Inputting the local topological structure features into the global pooling layer to calculate the importance score of the nodes and generate the overall representation of the entire supply chain transaction graph. The calculation method of global pooling is as follows: Where, is the global feature representation of the supply chain transaction graph, is the set of nodes of the entire transaction graph, is the importance weight of the node , which is calculated based on factors such as transaction frequency and credit score. Through global pooling, the features of all nodes are fused into an overall supply chain transaction feature, enabling the transaction relationships in the supply chain network to be analyzed and utilized in a higher-level manner. To enhance the expression ability of the supply chain transaction features, a skip connection structure is introduced to connect the initial features and the deep features. The calculation method of the skip connection is as follows: Where, represents the final supply chain transaction feature vector, represents the initial input feature, is the weight coefficient of the skip connection. The role of the skip connection is to retain the information of the original transaction data and at the same time fuse the advanced features extracted by deep learning to avoid the loss of information during the training process of the deep network. After the above steps, the supply chain transaction feature vector is obtained.

[0027] In a specific embodiment, the process of executing step 200 may specifically include the following steps: Calculate the cosine similarity corresponding to the supply chain transaction feature vectors between each pair of supply chain transaction nodes, and group the transactions with a cosine similarity higher than the first threshold into the same potential block to obtain a set of potential blocks; Apply the smart contract verification strategy to the set of potential blocks to check the transaction time sequence, the rationality of the logistics path, and the qualifications of the participating parties to obtain a group of transactions that pass the verification; Generate a block header and a block body based on the group of transactions that pass the verification to obtain a complete block, and perform block hash calculation on the transaction data in the complete block to obtain a block hash value; Select verification nodes based on the block hash value and the proof-of-stake consensus mechanism, assign weight coefficients to different verification nodes, and divide the blockchain network into multiple sub-networks to obtain a sharding verification scheme; Add the blocks that have been verified in the sharding verification scheme to the main chain and broadcast them to all nodes through the P2P network to obtain the blockchain network structure; Perform weighted voting verification on the transactions within the block based on the blockchain network structure to obtain a consensus confirmation block.

[0028] Specifically, calculate the cosine similarity corresponding to the supply chain transaction feature vectors between each pair of supply chain transaction nodes, and group the transactions according to the similarity level to form a set of potential blocks. The calculation formula of the cosine similarity is as follows: Among them, represents the cosine similarity between transaction nodes and , and are the supply chain transaction feature vectors of transaction nodes and respectively, and represent the norm of the vector, that is: Among them, is the value of node on the th-dimensional feature, is the feature dimension. If is greater than the set first threshold, it means that there is a high correlation between transaction nodes and . These transactions are assigned to the same potential block to form a set of potential blocks. Apply the smart contract verification strategy to the set of potential blocks to check the legality and rationality of the transactions. Check the transaction time sequence to ensure that the timestamps of the transactions conform to the supply chain logic, that is, if transaction occurs before transaction , its timestamp needs to satisfy: Among them, and are respectively the and timestamps of the transactions. The rationality of the logistics path is calculated based on the geographical location information of the supply chain. Assuming that the geographical coordinates of the supply chain transaction nodes and are and respectively, then the geographical distance between the two is expressed as: If this distance significantly deviates from the conventional supply chain path, then this transaction is marked as an abnormal transaction. Check the qualifications of the transaction participants to ensure that all parties in the supply chain meet the transaction requirements. Only the transaction groups that meet all verification conditions can pass the verification of the smart contract and thus enter the next step of processing. After the transaction groups pass the verification, a block header and a block body are generated based on these transaction groups to construct a complete block. The block header contains the metadata of the block, such as the hash value of the previous block, the timestamp, and the Merkle root hash, while the block body contains the specific transaction data. To ensure the integrity and immutability of the block, a hash calculation is performed on the block data, and the calculation method is as follows: Among them, is the hash value of the current block, is the hash value of the previous block, is the hash value of the transaction data of the current block, and represents the hash function (such as SHA-256). Through this hash calculation, the immutability of the blockchain is ensured, that is, if the data in the block is modified, its hash value will change significantly, thus destroying the entire chain structure. After completing the block hash calculation, verification nodes are selected according to the proof-of-stake consensus mechanism, and weight coefficients are assigned to different verification nodes to optimize the consensus efficiency. The selection of verification nodes is based on the amount of stake and the historical verification accuracy to calculate the weight: Among them, is the weight of the verification node , and is the weight coefficient, which is used to balance the influence of the equity holding amount and the verification accuracy. After selecting the verification nodes, in order to improve the scalability of the blockchain, the blockchain network is divided into multiple sub-networks to form a sharding verification scheme. In the sharding scheme, each sub-network is only responsible for verifying part of the transaction data, thereby reducing the computational burden of a single node and improving the throughput of the overall system. After completing the sharding verification, the verified blocks are added to the full main chain and broadcast to all nodes through the peer-to-peer network to synchronize the blockchain network structure. The broadcast mechanism ensures that all nodes can receive the latest block information and update the local ledger based on this information. The propagation model of the network is expressed as: where, is the propagation time of the block data, is the block data size, is the network bandwidth. By optimizing the network topology structure, the propagation delay of the block in the blockchain network is reduced, and the data synchronization efficiency is improved. After completing the block broadcast, in order to finally confirm the transaction, weighted voting verification is performed on the transactions in the block based on the blockchain network structure to reach a final consensus. The weighted voting mechanism is based on the reputation scores of different verification nodes to calculate the voting weight: where, is the verification node 's voting weight, represents the reputation score of this node, is the set of all nodes participating in the consensus. If more than the set threshold of verification nodes recognize a block as valid, then the block is finally confirmed and written into the blockchain to form a consensus confirmation block.

[0029] In a specific embodiment, the process of performing weighted voting verification on the transactions in the block based on the blockchain network structure to obtain the consensus confirmation block may specifically include the following steps: Select a set of verification candidate nodes from the blockchain network structure, and calculate the initial weight allocation scheme according to the equity quantity held by the nodes, the historical verification accuracy, and the network activity; Input the block header and block body information in the blockchain network structure into the multi-head self-attention layer to calculate the attention scores, and obtain the multi-head attention output; Apply the scaled dot-product attention mechanism to the multi-head attention output to obtain the attention weighted result, and dynamically allocate weights for each verification node based on the attention weighted result to obtain the weight optimization scheme; Guided by the weight optimization scheme, each verification node verifies the block to obtain a comprehensive verification conclusion, performs threshold determination on the comprehensive verification conclusion, adds the valid block to the main chain, updates the reputation score of the verification node, broadcasts a confirmation message to all participants, and obtains a consensus confirmation block.

[0030] Specifically, a set of verification candidate nodes is selected from the blockchain network structure, and an initial weight allocation scheme is calculated based on the number of interests held by the nodes, the historical verification accuracy, and the network activity. Set the number of interests held by each candidate node as , the historical verification accuracy as , the network activity as , and the initial weight of the node is calculated by weighted summation: Among them, , , and are weight coefficients used to adjust the influence degree of different factors, ensuring that the interest holdings, historical accuracy, and network activity reasonably affect the final allocation result. For a specific node, if it has a high number of interests held, good accuracy in past verified transactions, and high activity in the network, its weight will be greater, meaning that the influence of this node in the consensus process is also higher. After calculating the initial weight, analyze the block header and block body information in the blockchain network structure, and input it into the multi-head self-attention layer to calculate the attention score and obtain the multi-head attention output. Let the block header feature vector be , and the block body feature vector be , then its fused representation is calculated by linear transformation as: Among them, and are trainable weight matrices. Applying the multi-head self-attention mechanism enables the model to focus on different levels in the block data. Let the query matrix, key matrix, and value matrix of the multi-head attention be , , and respectively, and the calculation method of the attention score is as follows: Among them, represents the scaling factor of the feature dimension, avoiding the influence of too large inner product values on gradient stability, is the attention score matrix, indicating the correlation of different block data on multiple heads. The outputs calculated by multiple attention heads are concatenated and linearly transformed to obtain the final multi-head attention output : Among them, is a linear projection matrix, and are respectively the score and value matrices of the th attention head. The model makes full use of the information of different aspects of the block data to improve the feature expression ability. Apply the scaled dot-product attention mechanism to the multi-head attention output to calculate the attention-weighted result, and dynamically assign weights to each verification node based on this weighted result to form a weight optimization scheme. Let the input feature of a certain verification node be , and its attention-weighted result is calculated as follows: Among them, is a trainable mapping matrix, represents the feature representation of node after scaled dot-product attention. Based on this result, a new weight is assigned to the verification node: Among them, is the optimized node weight, indicating its influence in the current block verification task. If a node obtains a high attention score in the block feature analysis, its weight in the current consensus round will increase, thus affecting the final voting result. Based on the optimized weight scheme, each verification node verifies the block according to the assigned weight to obtain a comprehensive verification conclusion. During the verification process, the node checks the legality based on the transaction information in the block, including timestamp verification, transaction signature verification, and analysis of the rationality of the supply chain transaction logic. Let the verification result of the th node be , then the comprehensive verification conclusion is calculated by weighted summation: Among them, is the total number of all nodes participating in the verification, represents the final comprehensive verification conclusion. If this value exceeds the set threshold , that is: Then the block is determined to be a valid block and is officially added to the main chain. At this time, update the reputation score of the verification node to optimize the node selection strategy for subsequent verification tasks. Let the historical verification accuracy rate of a certain node be , and the current verification result be , then the new reputation score is updated as follows: Among them, is the smoothing coefficient, which is used to control the influence degree of historical verification records. If a node gives correct verification results multiple times, its reputation score will gradually increase, while nodes with incorrect verifications will gradually lose consensus weight. After the block verification is completed, a confirmation message is broadcast to all participating parties to ensure that all nodes in the blockchain network can synchronize the latest block status. The broadcast adopts a peer-to-peer propagation mechanism, and the propagation time is calculated as follows: where is the data propagation time, is the data size, is the network bandwidth. By optimizing the network topology structure, reducing the data propagation delay, and improving the synchronization efficiency of the entire blockchain system. After calculation and consensus verification, the new block is successfully added to the blockchain and forms a consensus confirmation block.

[0031] In a specific embodiment, the process of executing step 300 may specifically include the following steps: Extract transaction data and verification results from the consensus confirmation block, assign a unique identifier to each transaction, and construct an initial Merkle tree structure with the transaction data as leaf nodes; Apply the SHA-256 algorithm and the RIPEMD-160 algorithm to each node of the initial Merkle tree structure to generate a double-hash Merkle tree structure; Extract the product transfer path features from the double-hash Merkle tree structure to obtain a time series feature set, and establish a relational network feature set including product identification index, geographical location index, and time range index; Combine the relational network feature set with the time series feature set and the product transfer path features, and periodically write the Merkle root hash of this chain to the public chain to obtain the supply chain traceability features.

[0032] Specifically, extract transaction data and verification results from the consensus confirmation block, and assign a unique identifier to each transaction to ensure that each transaction in the supply chain can be accurately traced. Let the transaction data set be: where represents the th transaction, then the unique identifier of each transaction is calculated through a hash function where represents the hash function, As the unique identifier of the transaction, it ensures that the same transaction will not be stored repeatedly or tampered with. These transaction data are used as leaf nodes to construct the initial Merkle tree structure. The Merkle tree is a binary tree structure, where the leaf nodes store the hash values of the transaction data, and the non-leaf nodes store the hash values of their child nodes. The calculation method is as follows: Among them, represents the hash value of the th node in the th layer of the Merkle tree. || represents the hash concatenation operation, and are the hash values of the left and right child nodes of this node respectively. At the root of the Merkle tree, the Merkle root hash is calculated: Among them, represents the top layer of the Merkle tree, as the overall hash digest of this transaction set, providing a basis for subsequent data deposit. After the initial Merkle tree is constructed, in order to improve data security and collision resistance, double hashing is applied to each node in the Merkle tree, that is, first perform SHA-256 hash calculation, and then perform RIPEMD-160 hash calculation: Among them, represents the hash value obtained by SHA-256 calculation, represents the RIPEMD-160 hash function, and finally is used as the hash value of the double-hashed Merkle tree, further enhancing data integrity. The double-hashing mechanism can effectively prevent hash collisions and improve anti-tampering ability, thus ensuring the security of supply chain transaction data. Extract the product flow path characteristics from the double-hashed Merkle tree structure to establish supply chain traceability information. The product flow path depends on the logistics information, supplier information, and timestamp information in the transaction data. Suppose the transaction path of a certain product in the supply chain is: Then its time series feature set is expressed as: Among them, represents the time interval between transaction and transaction , reflecting the time flow of the product in different links of the supply chain. By calculating the time series feature set, identify the logistics bottlenecks or abnormal stagnation situations in the supply chain. For example, if If it is much greater than the industry standard, it indicates that there is an abnormal delay in this link of the product. Establish a relationship network feature set to facilitate supply chain traceability queries. The relationship network feature set includes a product identification index, a geographical location index, and a time range index to ensure that supply chain data can be queried through different dimensions. Let the unique identifier of a certain product be , and its trading location is , and the timestamp is , then the relationship network index is represented as a triple: This index ensures that the query system looks up its logistics track through the product , and filters relevant transactions through the geographical location or time range. Combine the relationship network feature set with the time series feature set and the product transfer path feature, and periodically write the Merkle root hash of this chain to the public chain to ensure data verifiability. Let the supply chain traceability feature set be: Among them, represents the time series feature set, represents the relationship network feature set, represents the product transfer path feature. By merging these feature data, a supply chain traceability data set is formed, and its hash value is calculated as follows: Among them, , as the hash digest of the current supply chain traceability data, is written to the public chain every fixed period to form a verifiable timestamp record.

[0033] In a specific embodiment, the process of executing step 400 may specifically include the following steps: Create a product traceability contract, a quality verification contract, and a liability determination contract, and pass the supply chain traceability features as input parameters into the contracts to obtain a set of traceability smart contracts; Execute a hierarchical execution strategy on the set of traceability smart contracts to obtain an optimized contract execution plan; Based on the product traceability contract in the optimized contract execution plan, receive the product unique identifier, query the blockchain network to obtain the supply chain traceability features, and obtain the product traceability result; Execute the quality verification contract according to the product traceability result to obtain a quality assessment report, and execute the liability determination contract based on the quality assessment report to obtain a liability determination conclusion; Integrate the liability determination conclusion, the quality assessment report, and the product traceability result into an execution log, record the input parameters, the execution path, and the output result, and generate a visual traceability report including the supply chain transfer map, the quality parameter change curve, and the liable party identifier.

[0034] Specifically, create a product traceability contract, a quality verification contract, and a liability determination contract, and use the supply chain traceability features as input parameters and pass them into these contracts to obtain a set of traceability smart contracts. Let the set of supply chain traceability features be: Among them, represents the unique identifier of the product, represents the product transfer path information, represents time series data, represents quality inspection data, represents the reputation information of each trading node. During the execution of the smart contract, these data are passed in as input to the product traceability contract, the quality verification contract, and the liability determination contract for supply chain traceability, quality analysis, and liability division. After creating the set of traceability smart contracts, a hierarchical execution strategy is implemented for these contracts to ensure that the contracts are processed in the optimal execution order. The core goal of the hierarchical execution strategy is to reduce computational redundancy and improve the contract execution efficiency. Let the contract set be: Among them, represents the product traceability contract, represents the quality verification contract, represents the liability determination contract. The execution order should satisfy the following optimization strategy: Among them, represents the optimal contract execution plan, represents the execution of the contract The required computation time. Since the execution result of the product traceability contract is the input of the quality verification contract, and the result of the quality verification contract is the input of the liability determination contract, the optimal execution order should satisfy . After executing the optimized contract plan, the product traceability contract receives the product unique identifier , and queries the supply chain traceability features of the product in the blockchain network. During the query process, the smart contract calls the blockchain storage data, locates the relevant transaction information through the hash index, and the calculation method is as follows: Among them, represents the unique identifier The hash index value on the blockchain. According to this index value, the smart contract obtains the complete traceability information from the blockchain and returns the product traceability result. Suppose the traceability path of a certain product contains transaction nodes, then its complete path is expressed as: Among them, Represents the timestamp of the product at the th node, which represents the geographical location of this node. The smart contract constructs a supply chain traceability graph based on this information to visually display the product's flow process. After obtaining the product traceability results, the quality verification contract analyzes the quality changes of the product in the supply chain. Let the set of quality parameters of a certain product be: Among them, represents the quality inspection result of the product at the th supply chain node. Quality parameters include indicators such as temperature, humidity, and pressure, and their changes are measured by calculating the standard deviation: Among them, represents the average quality of all nodes, represents the degree of fluctuation of the quality parameters. If exceeds the set threshold, it indicates that the product has experienced storage or transportation conditions that do not meet the standards. The quality verification contract generates a quality assessment report based on these analysis results to determine whether the product meets the supply chain quality standards. After the quality verification contract is completed, the liability determination contract analyzes the source of problems with the product in the supply chain and determines the liability attribution. Let the liability score of a certain transaction node in the supply chain network be: Among them, represents the quality deviation value caused by this transaction node, represents the proportion of this node in the entire liability attribution. If the of a certain node is higher than the set liability determination threshold , then this node will be identified as the main responsible party. The liability determination contract records this conclusion and stores the result in the blockchain for subsequent accountability. After all smart contracts are executed, the liability determination conclusion, quality assessment report, and product traceability results are integrated into an execution log, and the input parameters, execution path, and final output results of the contract execution are recorded to ensure the transparency and traceability of the supply chain traceability process. Let the execution log data structure be: Among them, represents the product identification information, represents the supply chain flow path, represents the quality assessment data, Represents the result of responsibility determination. To improve the readability and visualization of data, a visual traceability report is generated based on the execution log, which includes the supply chain flow map, the quality parameter change curve, and the identification of responsible parties, etc. The supply chain flow map draws the circulation track of products through geographical location indexing, while the quality parameter change curve draws the trend of product quality changing over time based on time series data. The identification of responsible parties marks different responsible parties in the supply chain through color coding, enabling supply chain managers to quickly identify risk points.

[0035] The above describes the blockchain-based supply chain traceability method in the embodiments of the present application. Next, the blockchain-based supply chain traceability system 10 in the embodiments of the present application will be described. Please refer to Figure 2 , an embodiment of the blockchain-based supply chain traceability system 10 in the embodiments of the present application includes: A feature learning module 11, configured to collect and perform feature learning on the product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector; A verification module 12, configured to perform smart contract verification policy confirmation and weighted voting verification on a transaction group based on the supply chain transaction feature vector to obtain a consensus confirmation block; A construction module 13, configured to extract transaction data from the consensus confirmation block, construct a double-hash Merkle tree structure and generate supply chain traceability features; A generation module 14, configured to execute a commodity traceability contract, a quality verification contract, and a responsibility determination contract according to the supply chain traceability features, and generate an execution log and a visual traceability report.

[0036] Through the collaborative cooperation of the above-mentioned various components, product information is collected in real time through Internet of Things devices, a local anomaly factor algorithm is introduced for data anomaly detection, and digital signatures are used to ensure data integrity, solving the problems of poor data quality and difficult-to-guarantee authenticity in traditional traceability systems. By combining a double-layer feedforward neural network, a channel attention mechanism, and a graph convolutional network for feature learning, complex topological relationships and temporal features in supply chain transactions are captured, enabling more accurate identification of similar and abnormal transactions compared to traditional methods. Blocks are constructed through a combination of cosine similarity grouping and smart contract verification, and a Merkle tree structure is introduced to optimize storage, significantly reducing the storage burden of the blockchain network and improving the processing efficiency of the system while maintaining traceability integrity. The proof-of-stake consensus network based on the attention mechanism dynamically allocates the weights of verification nodes through multi-head self-attention layers, combines sharding technology and a weighted voting mechanism, reduces the number of verification nodes and network communication overhead while ensuring the reliability of block verification, and improves the consensus efficiency. By adopting a double-hash Merkle tree structure and an anchored hash technology, lightweight verification and incremental updates are achieved while improving the security of traceability data, providing differentiated traceability services for users with different permissions. Through a hierarchical execution strategy and an event-triggering mechanism, automatic execution of product traceability, quality verification, and liability determination is carried out, reducing manual intervention, enhancing the objectivity and efficiency of the traceability process, and generating an intuitive visual traceability report to meet the traceability needs of different users.

[0037] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described systems, systems, and units can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0038] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0039] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present application.

Claims

1. A blockchain-based supply chain traceability method, characterized in that, The method includes: Collecting and performing feature learning on product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector; Based on the supply chain transaction feature vector, performing intelligent contract verification policy confirmation and weighted voting verification on transaction groups to obtain a consensus confirmation block; Extracting transaction data from the consensus confirmation block, constructing a double-hash Merkle tree structure and generating supply chain traceability features; Executing commodity traceability contracts, quality verification contracts, and liability determination contracts according to the supply chain traceability features to generate execution logs and visual traceability reports.

2. The blockchain-based supply chain traceability method according to claim 1, wherein The collecting and performing feature learning on product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector includes: Collecting product identification information and transaction records through RFID readers, QR code scanners, and sensor networks to obtain preliminary filtered data; Performing data cleaning operations on the preliminary filtered data to obtain a complete data set, and performing normalization processing on the numerical data in the complete data set to obtain standardized data; Generating transaction frequency, logistics residence time, and temperature fluctuation amplitude based on the standardized data to obtain an enhanced data set, and performing local outlier factor identification on the enhanced data set to obtain outlier marked data; Packing the outlier marked data into a standardized JSON format, adding a digital signature for data integrity protection, and transmitting it through a secure channel to the processing queue of the blockchain network to obtain preprocessed data; Constructing a supply chain transaction graph structure based on the preprocessed data, and performing node feature initialization and feature learning to obtain a supply chain transaction feature vector.

3. The blockchain-based supply chain traceability method according to claim 2, wherein The constructing a supply chain transaction graph structure based on the preprocessed data, and performing node feature initialization and feature learning to obtain a supply chain transaction feature vector includes: Parsing the preprocessed data into a graph structure, setting supply chain participants as nodes, transaction relationships as edges, and assigning node attributes and edge attributes to obtain a supply chain transaction graph structure; Processing the node features of the supply chain transaction graph structure through a two-layer feedforward neural network to obtain a dense vector representation of the nodes; Introducing a channel attention mechanism based on the dense vector representation of the nodes, calculating attention scores according to the importance of different types of transaction information to obtain a weighted feature representation; Applying a graph convolutional network layer to the weighted feature representation, aggregating node and its neighborhood information through a message passing mechanism to obtain local topological structure features; Inputting the local topological structure features into a global pooling layer, calculating node importance scores and generating a graph representation, and connecting the initial features and deep features through a skip connection structure to obtain a supply chain transaction feature vector.

4. The blockchain-based supply chain traceability method according to claim 1, wherein, The performing intelligent contract verification policy confirmation and weighted voting verification on transaction groups based on the supply chain transaction feature vector to obtain a consensus confirmation block includes: Calculating the cosine similarity corresponding to the supply chain transaction feature vectors between each pair of supply chain transaction nodes, and grouping the transactions with a cosine similarity higher than the first threshold into the same potential block to obtain a set of potential blocks; Apply the smart contract verification strategy to the set of potential blocks, check the transaction time sequence, the rationality of the logistics path, and the qualifications of the participating parties, and obtain the transaction group that passes the verification; Generate a block header and a block body based on the transaction group that passes the verification, obtain a complete block, and perform block hash calculation on the transaction data in the complete block to obtain a block hash value; Select verification nodes based on the block hash value and the proof-of-stake consensus mechanism, assign weight coefficients to different verification nodes, and divide the blockchain network into multiple sub-networks to obtain a sharding verification scheme; Add the blocks that have been verified in the sharding verification scheme to the main chain and broadcast them to all nodes through the P2P network to obtain the blockchain network structure; Perform weighted voting verification on the transactions in the block based on the blockchain network structure to obtain a consensus confirmation block.

5. The blockchain-based supply chain traceability method according to claim 4, wherein The performing weighted voting verification on the transactions in the block based on the blockchain network structure to obtain a consensus confirmation block includes: Select a set of verification candidate nodes from the blockchain network structure, and calculate the initial weight allocation scheme according to the amount of equity held by the nodes, the historical verification accuracy rate, and the network activity; Input the block header and block body information in the blockchain network structure into the multi-head self-attention layer for attention score calculation to obtain the multi-head attention output; Apply the scaled dot-product attention mechanism to the multi-head attention output to obtain the attention weighted result, and dynamically assign weights to each verification node based on the attention weighted result to obtain a weight optimization scheme; Guide each verification node to verify the block based on the weight optimization scheme to obtain a comprehensive verification conclusion, perform threshold determination on the comprehensive verification conclusion, add the valid block to the main chain, update the reputation score of the verification node, and broadcast a confirmation message to all participating parties to obtain a consensus confirmation block.

6. The blockchain-based supply chain traceability method according to claim 1, wherein, The extracting transaction data from the consensus confirmation block, constructing a double-hash Merkle tree structure and generating supply chain traceability features includes: Extract transaction data and verification results from the consensus confirmation block, assign a unique identifier to each transaction, and use the transaction data as leaf nodes to construct an initial Merkle tree structure; Apply the SHA-256 algorithm and the RIPEMD-160 algorithm to each node of the initial Merkle tree structure to generate a double-hash Merkle tree structure; Extract the product transfer path features from the double-hash Merkle tree structure to obtain a time series feature set, and establish a relational network feature set including product identification indexes, geographical location indexes, and time range indexes; Combine the relational network feature set with the time series feature set and the product transfer path features, and periodically write the Merkle root hash of this chain into the public chain to obtain supply chain traceability features.

7. The blockchain-based supply chain traceability method according to claim 1, characterized in that, The executing the commodity traceability contract, the quality verification contract, and the liability determination contract according to the supply chain traceability features to generate an execution log and a visual traceability report includes: Create a commodity traceability contract, a quality verification contract, and a liability determination contract, and pass the supply chain traceability features as input parameters into the contract to obtain a set of traceability smart contracts; Execute a hierarchical execution strategy on the traced smart contract set to obtain an optimized contract execution plan; Based on the product unique identifier received by the product traceability contract in the optimized contract execution plan, query the blockchain network to obtain the supply chain traceability characteristics and get the product traceability result; Execute the quality verification contract according to the product traceability result to obtain a quality assessment report, and execute the liability determination contract based on the quality assessment report to obtain a liability determination conclusion; Integrate the liability determination conclusion, the quality assessment report and the product traceability result into an execution log, record the input parameters, execution path and output results, and generate a visual traceability report including a supply chain flow map, a quality parameter change curve and a responsible party identifier.

8. A blockchain-based supply chain traceability system, characterized in that, For executing the blockchain-based supply chain traceability method according to any one of claims 1-7, the blockchain-based supply chain traceability system includes: A feature learning module for collecting and performing feature learning on the product identification information and transaction records of supply chain nodes to obtain a supply chain transaction feature vector; A verification module for performing a smart contract verification strategy confirmation and weighted voting verification on a transaction group based on the supply chain transaction feature vector to obtain a consensus confirmation block; A construction module for extracting transaction data from the consensus confirmation block, constructing a double-hash Merkle tree structure and generating supply chain traceability characteristics; A generation module for executing a product traceability contract, a quality verification contract and a liability determination contract according to the supply chain traceability characteristics, generating an execution log and a visual traceability report.

Citation Information

Cited By

  • Traditional Chinese medicine whole-chain informatization traceability management method and system

    CN120707174A

  • Charger supply chain data traceability management method based on block chain

    CN120894048A

  • A blockchain-based charger supply chain data traceability management method

    CN120894048B

  • Lightweight integrated data chain tracing management method and system

    CN120896754A

  • Distributed network intrusion event tracing method and system based on block chain

    CN120956530A