Agilawood tracing method and system based on distributed identity and smart contract
By adopting distributed identity and smart contract technology in the agarwood supply chain, the problems of insufficient transparency in the supply chain and complex information sharing are solved, and the traceability and verification of the entire process of agarwood products are realized, and the security and transparency of data are improved.
Patent Information
- Application Number
- CN202510171230.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-06-10
AI Technical Summary
The agarwood supply chain is insufficient transparency and complex identity authentication and information sharing, resulting in difficulty in traceability and low traceability accuracy.
Using a method based on distributed identity and smart contracts, the electronic data files of agarwood in each link are collected and verified, the file data fingerprint hash value is calculated, and the file data is recorded on the chain and recorded in the blockchain network to achieve transparency and credibility of information.
It improves the security and transparency of agarwood evidence storage data, breaks down information exchange barriers, enhances the collaborative efficiency of all links of the industrial chain, and ensures the difficulty of tampering and traceability of data.
Smart Images

Figure CN120125252A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of agarwood traceability, and particularly to an agarwood traceability method and system based on distributed identity and smart contract. Background Art
[0002] Agarwood is a non-wood fragrant tree, and its resin part has extremely high medicinal and perfume values. Due to its unique aroma and rarity, agarwood has always been regarded as a precious commodity in history. The formation of agarwood is usually related to the damage and fungal infection of agarwood trees. The trees will secrete resin as a defense reaction. Over time, these resins accumulate around the wounds, forming agarwood. The agarwood supply chain faces challenges such as illegal logging, adulteration, and lack of transparent and reliable information, which not only threaten the sustainability of agarwood resources but also weaken the trust of consumers and industry stakeholders. Therefore, traceability support will become an inevitable trend in the development of the industry.
[0003] Blockchain traceability systems have achieved initial results in some fields. However, there are many and scattered participants in the agarwood supply chain, and the complexity of identity authentication and information sharing is relatively high; existing traceability systems often lack comprehensive supervision of each link in the supply chain, resulting in affected data credibility and consistency; at the same time, there are also certain technical obstacles in the design and execution of smart contracts in practical applications.
[0004] In the technical field of agarwood traceability, the main challenges include: insufficient supply chain transparency: the agarwood supply chain involves multiple links, including planting, collection, processing, storage, logistics, and sales. Currently, the information sharing and transparency of these links are not high; complex identity authentication and information sharing: there are many and scattered participants in the agarwood supply chain, and it is difficult to conduct identity authentication and information sharing.
[0005] Therefore, due to insufficient supply chain transparency and complex information sharing, traditional agarwood traceability technologies have problems such as difficult traceability and low traceability accuracy. Summary of the Invention
[0006] Based on this, in order to solve the above technical problems, an agarwood traceability method and system based on distributed identity and smart contract are provided, which can build a traceability and verification method for the whole process of agarwood products, break the information exchange barrier, and improve the security and transparency of agarwood evidence storage data.
[0007] An agarwood traceability method based on distributed identity and smart contract, the method comprising:
[0008] Collecting electronic data files of agarwood in each link and verifying them, sending the verified electronic data files to a distributed file system, and calculating the file data fingerprint hash value;
[0009] Based on distributed identity technology, determine the data to be uploaded to the blockchain according to the file data fingerprint hash values and the electronic data files generated by the participants in each link;
[0010] Design an intelligent contract based on the factory pattern. Each link participant runs a stack virtual machine locally through the intelligent contract parameters. After reaching a consensus on the operation results with each node, record the data to be uploaded to the blockchain network;
[0011] Determine the target data of aloeswood other than the data to be uploaded to the blockchain in each link, and store the target data in an off-chain verifiable database outside the blockchain network;
[0012] Based on the stored off-chain data, generate a hash value through encryption and hashing algorithms, and record the hash value and storage location on the blockchain network to achieve collaborative interaction of information on and off the chain;
[0013] Obtain the intelligent contract address corresponding to the aloeswood to be traced, and call the query function according to the intelligent contract address to obtain the data of each link corresponding to the aloeswood to be traced.
[0014] In one embodiment, collect the electronic data files of aloeswood in each link and verify them, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value, including:
[0015] Use a data collector to collect the target information of aloeswood in each link;
[0016] Encode the target information through a standardized format, and digitally process it into an electronic data file;
[0017] Verify the electronic data file, send the verified electronic data file to the distributed file system, and calculate the file data fingerprint hash value.
[0018] In one embodiment, based on distributed identity technology, determine the data to be uploaded to the blockchain according to the file data fingerprint hash values and the electronic data files generated by the participants in each link, including:
[0019] Respectively obtain the file data fingerprint hash values and the corresponding electronic data files generated by the participants in each link;
[0020] Use distributed identity technology to verify each of the file data fingerprint hash values respectively;
[0021] Take the verified file data fingerprint hash values and the corresponding electronic data files as the data to be uploaded to the blockchain.
[0022] In one embodiment, the target information includes the geographical information of agarwood planting, the date and method of collection, the technical parameters of processing, the quality inspection results, and the storage information; the method further includes:
[0023] Adding additional information to the target information to obtain an electronic data file;
[0024] Wherein, the additional information is the variety information of agarwood, the growth environment, the identity information of the collectors, and the sales information.
[0025] In one embodiment, the intelligent contract based on the factory mode uniformly manages each functional contract. The functional contracts include planting, collection, production, processing, warehousing, transportation, sales, query, and DID contracts; among them, the functional contracts at different stages are all written in Solidity language, and the Solidity compiler compiles the functional contracts into bytecode and ABI files.
[0026] In one embodiment, an intelligent contract based on the factory mode is designed. Participants in each link run a stack virtual machine locally through the intelligent contract parameters. After reaching a consensus on the operation results with each node, the on-chain data is recorded in the blockchain network, including:
[0027] The intelligent contract based on the factory mode is used to manage the deployment of each functional contract. When deploying, the bytecode and ABI files are written into the blockchain network through a deployment request;
[0028] Each functional contract generates a contract address during deployment, and the intelligent contract based on the factory mode stores the address list;
[0029] Each node in the blockchain network corresponds to a participant in each link to determine each functional contract. Each node runs a stack virtual machine locally according to the parameters of each functional contract to obtain the operation result;
[0030] After reaching a consensus on the operation result with other nodes in the blockchain network, it is recorded in the blockchain network.
[0031] In one embodiment, consensus nodes, observation nodes, and supervision nodes are set on the blockchain network, where:
[0032] The consensus nodes are used to record and verify the data of agarwood in each link and obtain the right to package transactions;
[0033] The observation nodes are used to communicate with other nodes normally and access the on-chain data, and are also used to view the source and transfer process of agarwood;
[0034] The regulatory node is used to access all data on the blockchain network and audit and supervise the data on the face.
[0035] In one embodiment, based on the stored off-chain data, a hash value is generated through encryption and hashing algorithms, and the hash value and storage location are recorded on the blockchain network to achieve collaborative interaction of on-chain and off-chain information, including:
[0036] Encrypt the target data other than the on-chain data of aloeswood in each link to obtain the encrypted data;
[0037] Based on the encrypted data, calculate the corresponding hash value and storage location link;
[0038] Store the target data in an off-chain verifiable database outside the blockchain network, and record the hash value and storage location link on the blockchain network.
[0039] In one embodiment, achieving collaborative interaction of on-chain and off-chain information includes:
[0040] When data access or data verification is required, extract the hash value and storage location link corresponding to the data to be accessed from the blockchain;
[0041] Through the hash value and storage location link, obtain the corresponding target data through the off-chain verifiable database;
[0042] Calculate the hash value of the corresponding target data, and compare it with the hash value and storage location link to achieve information collaborative interaction.
[0043] An aloeswood traceability system based on distributed identity and smart contract, the system includes:
[0044] A data acquisition module, which is used to collect electronic data files of aloeswood in each link and verify them, send the verified electronic data files to a distributed file system, and calculate the file data fingerprint hash value;
[0045] An on-chain data determination module, which is used to determine on-chain data based on distributed identity technology according to the file data fingerprint hash value and the electronic data file generated by participants in each link;
[0046] A data on-chain module, which is used to design a smart contract based on the factory pattern. After each link participant runs a stack virtual machine locally through smart contract parameters, and reaches a consensus on the operation result with each node, record the on-chain data in the blockchain network;
[0047] The off-chain data storage module is used to determine the target data outside the on-chain data of agarwood in each link, and store the target data in an off-chain verifiable database outside the blockchain network;
[0048] The information interaction module is used to generate a hash value based on the stored off-chain data through encryption and hashing algorithms, record the hash value and storage location on the blockchain network, and realize the collaborative interaction of on-chain and off-chain information;
[0049] The agarwood traceability module is used to obtain the smart contract address corresponding to the agarwood to be traced, and call the query function according to the smart contract address to obtain the data of each link corresponding to the agarwood to be traced.
[0050] The above-mentioned agarwood traceability method and system based on distributed identity and smart contract collect data of agarwood in each link, deploy a smart contract based on the factory mode to realize data on-chain, ensure the immutability of data through encryption and hashing algorithms, improve the collaboration efficiency of each link in the industrial chain, break the information exchange barrier, and improve the security and transparency of agarwood deposit data; create and manage independent contracts through the factory mode, improve the security of smart contracts in the whole life cycle, provide convenient multi-contract deployment, management, update and destruction functions, and have higher flexibility and maintainability. Brief Description of the Drawings
[0051] Figure 1 It is an application environment diagram of the agarwood traceability method based on distributed identity and smart contract in an embodiment;
[0052] Figure 2 It is a flow schematic diagram of the agarwood traceability method based on distributed identity and smart contract in an embodiment;
[0053] Figure 3 It is a structural schematic diagram of the agarwood traceability system based on distributed identity and smart contract in an embodiment;
[0054] Figure 4 It is a structural design diagram of the contract system based on the factory mode in an embodiment;
[0055] Figure 5 It is a structural design diagram of the blockchain network structure in an embodiment;
[0056] Figure 6 It is a flow schematic diagram of the on-chain and off-chain collaboration scheme of the agarwood traceability system in an embodiment;
[0057] Figure 7 It is a structural block diagram of the agarwood traceability system based on distributed identity and smart contract in an embodiment;
[0058] Figure 8Internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0059] To make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0060] The agarwood traceability method based on distributed identity and smart contract provided by the embodiment of the present application can be applied to an application environment as Figure 1 shown. As Figure 1 shown, the application environment includes a computer device 110. The computer device 110 can collect and verify the electronic data files of agarwood in each link, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value; the computer device 110 can, based on the distributed identity technology, determine the data to be uploaded to the chain according to the file data fingerprint hash value and the electronic data files generated by the participants in each link; the computer device 110 can design a smart contract based on the factory mode, and the participants in each link run the stack virtual machine locally through the smart contract parameters. After reaching a consensus on the operation results with each node, the data to be uploaded to the chain is recorded in the blockchain network; the computer device 110 can determine the target data other than the data to be uploaded to the chain in each link of agarwood, and store the target data in a verifiable database off-chain outside the blockchain network; the computer device 110 can, based on the stored off-chain data, generate a hash value through encryption and hashing algorithms, and record the hash value and the storage location on the blockchain network to realize the collaborative interaction of information on-chain and off-chain; the computer device 110 can obtain the smart contract address corresponding to the agarwood to be traced, call the query function according to the smart contract address, and obtain the data of each link corresponding to the agarwood to be traced based on the file data fingerprint hash value. Among them, the computer device 110 can be, but is not limited to, various personal computers, laptop computers, smart phones, robots, unmanned aerial vehicles, tablet computers and other devices.
[0061] In one embodiment, as Figure 2 shown, a method for tracing the origin of agarwood based on distributed identity and smart contract is provided, including the following steps:
[0062] Step 202, collect and verify the electronic data files of agarwood in each link, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value.
[0063] Key information will be generated in each link of agarwood, such as the information generated during the processes of planting, collecting, processing, etc.
[0064] In one embodiment, a method for tracing the origin of agarwood based on distributed identity and smart contracts may further include the process of collecting and processing information of agarwood in each link. The specific process includes: using a data collector to collect the target information of agarwood in each link; encoding the target information through a standardized format, and digitally processing it into an electronic data file; verifying the electronic data file, sending the verified electronic data file to a distributed file system, and calculating the file data fingerprint hash value.
[0065] Specifically, the key information of agarwood in each link can be converted into an electronic data file through digital means, and then the electronic data file is authenticated and authorized to ensure the source and integrity of the data. Then, the verified electronic data file can be sent to the distributed file system to obtain the calculated file data fingerprint hash value; then the fingerprint hash value of the electronic data file and the target information of agarwood, such as the planting location, collection time, etc., are sent to the blockchain network to ensure the integrity and immutability of the agarwood data stored in the blockchain network. Among them, the information that needs to be digitally processed can include: the geographical information of agarwood planting, the date and method of collection, the technical parameters of processing, etc.; the digital processing of agarwood information includes: using high-precision scanning equipment and sensors for data collection, and using a standardized format for data encoding.
[0066] Step 204, based on the distributed identity technology, determine the data to be uploaded to the chain according to the file data fingerprint hash values and electronic data files generated by the participants in each link.
[0067] In one embodiment, a method for tracing the origin of agarwood based on distributed identity and smart contracts may further include the process of determining the data to be uploaded to the chain and performing the upload operation. The specific process includes: respectively obtaining the file data fingerprint hash values and the corresponding electronic data files generated by the participants in each link; respectively verifying the file data fingerprint hash values by using the distributed identity technology; using the verified file data fingerprint hash values and the corresponding electronic data files as the data to be uploaded to the chain.
[0068] Among them, in one embodiment, the target information includes the geographical information of agarwood planting, the date and method of collection, the technical parameters of processing, the quality inspection results, and the storage information; further, additional information can be added to the target information to obtain an electronic data file; the additional information is the variety information of agarwood, the growth environment, the identity information of the collection personnel, and the sales information.
[0069] As Figure 3 shown, there are many participants in the source of the agarwood supply chain and their roles are clearly divided. The participants in each link play an indispensable role in the entire supply chain. In this embodiment, as Figure 3As shown in the figure, the source 301 of the agarwood supply chain can be mainly divided into six categories according to different responsibilities. The six categories of the source of the agarwood supply chain are responsible for selecting suitable varieties of agarwood trees for planting, recording the planting time, planting location, and all important data during the planting process, and uploading the planting data to the planting personnel node of the blockchain; selecting the appropriate time and method for felling the agarwood trees, recording all important data during the felling and collection process, and uploading the collection data to the collection personnel node of the blockchain; recording all key data during the processing process, including processing methods, quality inspection results, etc., and uploading the processed data to the processing personnel node of the blockchain after ensuring that the processed agarwood products meet the standards of the market and regulatory agencies; being responsible for managing the storage of agarwood products, recording the data such as storage time and storage environment that need to be uploaded to the warehouse management personnel node of the blockchain; being responsible for recording information such as the place of origin and destination and uploading it to the transportation personnel node; recording all key data during the sales process, including sales time, location, and price, etc., and uploading the sales data to the blockchain to ensure the publicity and credibility of the data at the salesperson node.
[0070] Step 206, design an intelligent contract based on the factory pattern. Participants in each link run a stack virtual machine locally through the intelligent contract parameters. After reaching a consensus on the operation results with each node, record the data uploaded to the blockchain network in the blockchain network.
[0071] In one embodiment, the intelligent contract based on the factory pattern uniformly manages each functional contract. The functional contracts include planting, collection, production, processing, warehousing, transportation, sales, query, and DID contracts. Among them, the functional contracts in different stages are all written in the Solidity language, and the Solidity compiler compiles the functional contracts into bytecode and ABI files. Nodes on the blockchain network run a stack virtual machine locally through the contract parameters and record the operation results on the blockchain network after reaching a consensus with other nodes.
[0072] Among them, as Figure 3 shown, assign a unique distributed identity DID to the six categories of the source 301 of the agarwood supply chain, that is, the participants in the agarwood traceability link, and generate relevant data information 302 in different links to ensure the information association of identity and behavior. Among them, the data information 302 includes but is not limited to: agarwood tree planters, planting time and planting location, agarwood collectors, processors, collection time and processing time, warehouse managers, storage quantity, and inbound and outbound records, logistics personnel, logistics information, transportation route, and timestamp, sales orders, salespersons, and sales prices, etc.
[0073] In one embodiment, a method for tracing the origin of agarwood based on distributed identity and smart contracts may further include the process of uploading data to the blockchain. The specific process is as follows: The smart contract based on the factory pattern is used to manage the deployment of each functional contract. When deploying, the bytecode and ABI file are written into the blockchain network through a deployment request. Each functional contract generates a contract address during deployment, and the smart contract based on the factory pattern stores the address list. Each node in the blockchain network corresponds to each participant in each link, determines each functional contract, and each node runs a stack virtual machine locally according to the parameters of each functional contract to obtain a running result. The running result is recorded in the blockchain network after reaching a consensus with other nodes in the blockchain network.
[0074] Based on the design of the smart contract with the factory pattern, the agarwood origin tracing system can flexibly manage and expand contract instances in different business scenarios, ensuring the efficiency and maintainability of the system. As Figure 3 shown, the factory contract 303a uniformly manages the production, processing, transportation, sales, DID management contract 303b, and information query contract 303c. Each functional contract collaborates to upload the production data generated by various participants to the blockchain, realizing data authenticity and immutability, and improving the reusability of smart contracts and the overall performance of the system.
[0075] As Figure 3 shown, the verifiable database 304a in the data storage system 304 realizes the detailed data storage of a large amount of off-chain data. The consortium blockchain system 304b realizes the transparent and immutable storage of important on-chain data through the joint cooperation of observation nodes, consensus nodes, and supervision nodes.
[0076] In this embodiment, as Figure 3 shown, the consumer 305 sends a query request to the client. The client then calls the information query contract 303c to read the DID identity information and data storage location from the consortium blockchain system 304b, reads the agarwood production process information from the verifiable database according to the data storage location, calculates its hash value, and if it matches the hash value stored on the chain, returns the full process information of the agarwood, such as the planting origin, producer, and seller, to the consumer. Through the above process, the full process tracing of agarwood production information can be realized.
[0077] In one embodiment, as Figure 4As shown, after the developer completes the system deployment, they can interact with the system through the client 401 (such as a Web application or a mobile application), and the client sends an operation request to the system, such as recording production information, updating processing information, etc. Among them, the API interface 402 is located between the client and the blockchain, and is responsible for receiving the operation request and forwarding it to the corresponding smart contract. The developer calls the API interface through the client to send a business request, and the API interface then forwards the request to the contract factory to implement operations on the smart contract on the blockchain 405, such as creating a new functional contract.
[0078] In this embodiment, the contract call interface API includes but is not limited to creating a cultivation contract instance CreateCultivationContract(), creating a processing contract instance CreateProcessingContract(), creating a DID management contract instance CreateDidManagementContract(), returning the receipt of the cultivation contract, including status and log GetCultivationContract(), and freezing the cultivation contract FreezeCultivationContract().
[0079] As Figure 4 shown, the factory contract 403, as the management center of the smart contract, is responsible for creating, deploying, and managing various functional contracts, and provides interfaces such as createContract(), getContract(), and freezeContract(), etc., to facilitate the creation and management of functional contracts. The functional contract S304 is responsible for handling specific business logics, such as cultivation, collection, processing, transportation, sales, DID management and parsing. Each functional contract is an independent smart contract instance, recording specific business data and performing corresponding business operations. Only the factory contract is exposed externally. The factory contract creates new functional contracts, and all functional contracts are maintained by a unified factory contract. After mutual agreement, all parties can call this contract to initiate new sub - contracts to facilitate the continuous expansion of contract functions.
[0080] Functional contracts at different stages (such as planting contracts, processing contracts, transportation contracts, and sales contracts) are written in the Solidity language. The Solidity compiler compiles the contracts into bytecode and ABI files. The factory contract is responsible for managing the deployment of each functional contract. During deployment, the bytecode and ABI files are written to the blockchain through a deployment request. Each functional contract generates a unique contract address during deployment, and the factory contract stores the relevant address list. Production personnel at different links will pass task data (task hash values, the smart contract addresses called, and other relevant parameters, etc.) to the corresponding RPC interface when processing tasks. Nodes on the blockchain network run a stack-based virtual machine locally through contract parameters and record the operation results on the blockchain network after reaching a consensus with other nodes. Consumers or other stakeholders can call the query function of the contract through the contract address to obtain information about each link of agarwood. These query operations are read-only and do not change the data on the blockchain. Due to the transparency and immutability of the blockchain, all data uploaded to the chain can be verified, ensuring the authenticity and reliability of the information.
[0081] Among them, the functional contracts include but are not limited to: Production Contract, Collection Contract, Processing Contract, LogisticsContract, Transportation Contract, Sales Contract, DID Management Contract, DID Parsing Contract.
[0082] Step 208: Determine the target data other than the data uploaded to the chain in each link of agarwood, and store the target data in a verifiable off-chain database outside the blockchain network.
[0083] Step 210: Based on the stored off-chain data, generate a hash value through encryption and hashing algorithms, and record the hash value and the storage location on the blockchain network to achieve collaborative interaction of on-chain and off-chain information.
[0084] Among them, on-chain data storage directly stores key information in the blocks on the blockchain network, which requires data with high transparency, security, and not easy to change frequently. The immutability, authenticity, and security of on-chain data storage.
[0085] In one embodiment, such as Figure 5As shown in the figure, there are consensus nodes 501, observation nodes 502, and supervision nodes 503 set up on the blockchain network, where: The consensus nodes 501 are used to record and verify the data of agarwood in each link and obtain the right to package transactions; The observation nodes 502 are used to communicate with other nodes normally and access the data on the chain, and are also used to view the source and transfer process of agarwood; The supervision nodes 503 are used to access all the data on the blockchain network and audit and supervise the data on the chain.
[0086] The data on the chain is implemented by Figure 5 the blockchain network nodes in. In the agarwood supply chain, the consensus nodes 501 record and verify the data of each link of the agarwood product from planting, processing to sales, and obtain the power to package transactions by solving complex mathematical problems, ensuring the authenticity and immutability of all transaction records. The observation nodes 502 do not participate in the consensus process, but can communicate with other nodes normally and access the data on the chain, and their failure will not affect the operation of the entire network. The existence of the observation nodes 502 can improve the transparency and accessibility of the blockchain without increasing the burden on the network. Consumer clients can view the source and transfer process of agarwood through the observation nodes, increasing their trust. The main role of the supervision nodes 503 is to monitor the data on the chain to ensure the compliance and security of the data, and ensure the legal and compliant operation of the supply chain. They can access all the data on the blockchain for auditing and supervision to prevent fraud and illegal activities.
[0087] Among them, the main data on the chain can include: Identity information: including planting personnel, collection personnel, processing personnel, transportation personnel, retailers, and regulatory agencies, etc. The uploading of these identity information to the chain ensures the authenticity of each participant and the traceability of their behaviors; Off-chain corresponding data hash value: The unique identifier of the traceability data uploaded in each batch, ensuring the integrity of the off-chain data; Timestamp: Record the timestamps of each key operation, including the time information of links such as planting, collection, processing, transportation, and sales; License and certification information: Record the hash of various licenses and certification reports to ensure their authenticity and verifiability; Storage location link: Record the storage location of the off-chain corresponding data.
[0088] In one embodiment, a method for tracing the origin of agarwood based on distributed identity and smart contract may further include a process of realizing the collaborative interaction of on-chain and off-chain information. The specific process includes: Encrypt the target data outside the on-chain data of agarwood in each link to obtain the encrypted data; Based on the encrypted data, calculate the corresponding hash value and storage location link; Store the target data in an off-chain verifiable database outside the blockchain network, and record the hash value and storage location link on the blockchain network.
[0089] Off-chain data storage refers to storing a large amount of information in a verifiable database outside the blockchain. Although these data are not directly stored on the blockchain, their integrity and verifiability can still be ensured by recording their hash values and links on the chain. The advantages of off-chain data storage include large storage capacity, fast access speed, and low cost. Its storage is achieved through distributed database technology or centralized database technology to ensure the efficient access and management of data. To ensure the security and integrity of the data, the off-chain data will be encrypted before storage, and the corresponding hash values will be generated. These hash values will be stored on the blockchain to provide a mechanism for data verification.
[0090] In this embodiment, the main off-chain data includes: participant identity information at different stages, planting time, location, environment, method, collection time, method, processing time, method, quality inspection, storage time, environment, transportation route, time, sales time, price, location and other information.
[0091] In one embodiment, a method for tracing the origin of agarwood based on distributed identity and smart contract may further include a process of information collaborative interaction. The specific process includes: when data access or data verification is required, extract the hash value and storage location link corresponding to the data to be accessed from the blockchain; through the hash value and storage location link, obtain the corresponding target data through the off-chain verifiable database; calculate the hash value of the corresponding target data and compare it with the hash value and storage location link to achieve information collaborative interaction.
[0092] The on-chain and off-chain collaboration in agarwood origin tracing is as Figure 6 shown, including several processes such as on-chain data storage, off-chain data storage, and on-chain and off-chain interaction. Among them, as Figure 6As shown, the interaction methods of the data stored on-chain and off-chain mainly include: Data generation and hash calculation: In each link of the supply chain, detailed data is first stored off-chain, and corresponding hash values are generated through encryption and hash algorithms; Hash value on-chain: The generated data hash values and storage locations are linked and recorded on the blockchain to ensure that the on-chain data can be used to verify the integrity and authenticity of the off-chain data; Data access and verification: When data needs to be accessed or verified, the system extracts relevant hash values and links from the blockchain, obtains the actual data through the off-chain storage system, and recalculates the hash values for comparison to ensure that the data has not been tampered with; Dynamic update: For data that needs to be updated frequently (such as transportation environment parameters, etc.), the off-chain storage system provides real-time update and access support, while only the hash values and timestamps of key node updates are recorded on-chain to reduce the burden of on-chain storage; Data display and query: When consumers and other stakeholders query data through observation nodes, the system quickly and accurately extracts and verifies the data through the above mechanism and displays it in a user-friendly manner. Through data verification, it is possible to prevent the traceability data of agarwood products from being changed and prevent the integrity of the data uploaded to the system from being damaged.
[0093] Step 212, obtain the smart contract address corresponding to the agarwood to be traced, call the query function according to the smart contract address, and obtain the data of each link corresponding to the agarwood to be traced based on the file data fingerprint hash value.
[0094] Consumers or other stakeholders can call the query function of the contract through the contract address to obtain information on each link of the agarwood.
[0095] In this application, using blockchain technology, through the alliance system jointly constructed by all parties participating in the agarwood industrial chain, all parties in links such as planting, collection, processing, logistics, and sales are connected to each other as nodes, and smart contracts are deployed to jointly maintain this alliance blockchain network; The planting information, collection records, processing processes, logistics tracks, sales data, etc. of agarwood are realized to be uploaded to the chain by calling the deployed smart contracts; Through the hash technology of the blockchain, the difficulty of data tampering is ensured. Each node stores all the information of the blockchain, and the information is synchronously shared through the consensus algorithm of the network, improving the cooperation efficiency of each link in the industrial chain. In this way, a traceability and verification method for the entire process of agarwood products is constructed, breaking the information exchange barrier and improving the security and transparency of agarwood deposit data.
[0096] Furthermore, in view of the problems that the current technical solution only focuses on the secure storage and query of agarwood data, lacks on-chain execution of the entire industrial chain process, and lacks an intelligent contract design mode in the agarwood industry field, this application provides strong support for the secure development, secure operation, and runtime monitoring of intelligent contracts in the agarwood industry. In view of the limitations and complexity problems brought about by the fact that once an intelligent contract is deployed, it cannot be changed during demand changes or system upgrades, this application creates and manages independent functional contracts through the factory mode, improves the security of intelligent contracts throughout the entire life cycle, and provides convenient multi-contract deployment, management, update, and destruction functions, making the system more flexible and maintainable. At the same time, in view of the problem of high blockchain storage costs, this application optimizes the storage cost and improves the availability of the system by storing key information on-chain and detailed data off-chain; the security and transparency of on-chain data are combined with the efficient access and management of off-chain data to ensure the integrity and authenticity of agarwood traceability data. In summary, this application can implement a secure, effective, and scalable agarwood traceability and verification method, provide technical support for the sustainable development of the agarwood industry, enhance the market competitiveness of agarwood products, and protect the rights and interests of consumers.
[0097] It should be understood that although the steps in the above flowchart are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.
[0098] In one embodiment, as Figure 7 shown, a kind of agarwood traceability system based on distributed identity and intelligent contract is provided, including: a data acquisition module 710, an on-chain data determination module 720, a data on-chain module 730, an off-chain data storage module 740, an information interaction module 750, and an agarwood traceability module 760, wherein:
[0099] The data acquisition module 710 is used to collect electronic data files of agarwood in each link, verify them, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value;
[0100] The on-chain data determination module 720 is used to determine the on-chain data based on the distributed identity technology according to the file data fingerprint hash value and the electronic data file generated by the participants in each link;
[0101] The data uploading module 730 is used to design an intelligent contract based on the factory pattern. Participants in each link run a stack virtual machine locally through the intelligent contract parameters. After reaching a consensus on the operation results with each node, the uploaded data is recorded in the blockchain network.
[0102] The off-chain data storage module 740 is used to determine the target data of aloeswood other than the uploaded data in each link, and store the target data in an off-chain verifiable database outside the blockchain network.
[0103] The information interaction module 750 is used to generate a hash value based on the stored off-chain data through encryption and hashing algorithms, record the hash value and storage location on the blockchain network, and realize the collaborative interaction of on-chain and off-chain information.
[0104] The aloeswood traceability module 760 is used to obtain the intelligent contract address corresponding to the aloeswood to be traced, and call the query function according to the intelligent contract address to obtain the data of each link corresponding to the aloeswood to be traced.
[0105] In one embodiment, the data acquisition module 710 is further used to collect the target information of aloeswood in each link using a data collector; encode the target information in a standardized format, and digitally process it into an electronic data file; verify the electronic data file, send the verified electronic data file to the distributed file system, and calculate the file data fingerprint hash value.
[0106] In one embodiment, the uploaded data determination module 720 is further used to obtain the fingerprint hash values of each file data generated by participants in each link and the corresponding electronic data files respectively; verify the fingerprint hash values of each file data using distributed identity technology respectively; use the verified fingerprint hash values of each file data and the corresponding electronic data files as the uploaded data.
[0107] In one embodiment, the target information includes the geographical information of aloeswood planting, the collection date and method, the processing technical parameters, the quality inspection results, and the storage information; the data acquisition module 710 is further used to add additional information to the target information to obtain an electronic data file; wherein, the additional information is the variety information of aloeswood, the growth environment, the identity information of the collectors, and the sales information.
[0108] In one embodiment, the intelligent contract based on the factory pattern uniformly manages each functional contract. The functional contracts include planting, collection, production, processing, warehousing, transportation, sales, query, and DID contracts; among them, the functional contracts in different stages are all written in Solidity language, and the Solidity compiler compiles the functional contracts into bytecode and ABI files.
[0109] In one embodiment, the off-chain data storage module 740 is further configured to manage the deployment of each functional contract based on the factory-mode smart contract. When deploying, the bytecode and ABI file are written into the blockchain network through a deployment request; each functional contract generates a contract address during deployment, and the address list is stored by the factory-mode smart contract; each node in the blockchain network corresponds to each link participant, determines each functional contract, and each node runs a stack virtual machine locally according to each functional contract parameter to obtain a running result; the running result is recorded in the blockchain network after reaching a consensus with other nodes in the blockchain network.
[0110] In one embodiment, consensus nodes, observer nodes, and regulatory nodes are set on the blockchain network, where: the consensus nodes are used to record and verify the data of agarwood in each link and obtain the right to package transactions; the observer nodes are used to communicate with other nodes normally and access the on-chain data, and are also used to view the source and transfer process of agarwood; the regulatory nodes are used to access all the data on the blockchain network and audit and supervise the on-chain data.
[0111] In one embodiment, the information interaction module 750 is further configured to encrypt the target data other than the on-chain data of agarwood in each link to obtain encrypted data; based on the encrypted data, calculate the corresponding hash value and storage location link; store the target data in an off-chain verifiable database outside the blockchain network, and record the hash value and storage location link on the blockchain network.
[0112] In one embodiment, the information interaction module 750 is further configured to, when data access or data verification is required, extract the hash value and storage location link corresponding to the data to be accessed from the blockchain; obtain the corresponding target data through the off-chain verifiable database by means of the hash value and storage location link; calculate the hash value of the corresponding target data and compare it with the hash value and storage location link to achieve information collaborative interaction.
[0113] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as Figure 8As shown in the figure. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it realizes a Agarwood traceability method based on distributed identity and smart contract. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, a trackball, or a touchpad set on the outer shell of the computer device, or an external keyboard, a touchpad, or a mouse, etc.
[0114] Those skilled in the art can understand that Figure 8 the structure shown in the figure is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0115] In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, it realizes the steps of the Agarwood traceability method based on distributed identity and smart contract.
[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, it realizes the steps of the Agarwood traceability method based on distributed identity and smart contract.
[0117] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0118] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0119] The above-described embodiments merely represent several implementation manners of the present application. Their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A method for tracing the origin of agarwood based on distributed identity and smart contracts, characterized in that: The method comprises: Collect and verify the electronic data files of agarwood at each stage, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value; Based on distributed identity technology, the on-chain data is determined according to the file data fingerprint hash value and the electronic data file generated by the participants in each link; Design a smart contract based on the factory model. Participants in each link run the stack virtual machine locally through the smart contract parameters. After reaching a consensus with each node on the running results, the on-chain data is recorded in the blockchain network. Determine the target data of agarwood other than the on-chain data in each link, and store the target data in an off-chain verifiable database outside the blockchain network; Based on the stored off-chain data, a hash value is generated through encryption and hashing algorithms, and the hash value and storage location are recorded on the blockchain network to achieve collaborative interaction of on-chain and off-chain information; Obtain the smart contract address corresponding to the agarwood to be traced, call the query function according to the smart contract address, and obtain the data of each link corresponding to the agarwood to be traced based on the file data fingerprint hash value.
2. The agarwood traceability method based on distributed identity and smart contract according to claim 1 is characterized in that: Collect and verify the electronic data files of agarwood at each stage, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value, including: Use data collector to collect target information of agarwood in each link; Data encoding of the target information is performed in a standardized format, and digital processing is performed to convert the data into an electronic data file; The electronic data file is verified, the verified electronic data file is sent to the distributed file system, and a file data fingerprint hash value is calculated.
3. The agarwood traceability method based on distributed identity and smart contract according to claim 1 is characterized in that: Based on the distributed identity technology, the on-chain data is determined according to the file data fingerprint hash value generated by the participants in each link and the electronic data file, including: Obtain the data fingerprint hash value of each file and the corresponding electronic data file generated by the participants in each link respectively; Using distributed identity technology to verify the fingerprint hash value of each file data; The verified file data fingerprint hash value and the corresponding electronic data file are used as the on-chain data.
4. The agarwood traceability method based on distributed identity and smart contract according to claim 2 is characterized in that: The target information includes geographical information of agarwood planting, date and method of collection, technical parameters of processing, quality inspection results, and storage information; the method also includes: Adding additional information to the target information to obtain an electronic data file; Among them, the additional information includes the variety information, growth environment, identity information of the collectors, and sales information of the agarwood.
5. The agarwood traceability method based on distributed identity and smart contract according to claim 1 is characterized in that: The smart contract based on the factory model uniformly manages various functional contracts, including planting, collection, production, processing, warehousing, transportation, sales, query, and DID contracts; among them, the functional contracts at different stages are all written in Solidity language, and the Solidity compiler compiles the functional contracts into bytecode and ABI files.
6. The agarwood traceability method based on distributed identity and smart contracts according to claim 5 is characterized in that: Design a smart contract based on the factory model. Participants in each link run the stack virtual machine locally through the smart contract parameters. After reaching a consensus with each node on the running results, the on-chain data is recorded in the blockchain network, including: The factory-based smart contract is used to manage the deployment of each of the functional contracts, and during deployment, the bytecode and ABI file are written into the blockchain network through a deployment request; Each of the functional contracts generates a contract address when deployed, and the address list is stored by the smart contract based on the factory mode; Each node in the blockchain network corresponds to a participant in each link, determines each functional contract, and each node runs a stack virtual machine locally according to the parameters of each functional contract to obtain an operating result; The operation result is recorded in the blockchain network after reaching a consensus with other nodes in the blockchain network.
7. The agarwood traceability method based on distributed identity and smart contract according to claim 1 is characterized in that: The blockchain network is provided with consensus nodes, observation nodes, and supervision nodes, among which: The consensus node is used to record and verify the data of agarwood at each stage and obtain the right to package transactions; The observation node is used to communicate normally with other nodes and access on-chain data, and is also used to check the source and circulation process of agarwood; The regulatory node is used to access all data on the blockchain network and to audit and supervise facial data.
8. The agarwood traceability method based on distributed identity and smart contract according to claim 1 is characterized in that: Based on the stored off-chain data, a hash value is generated through encryption and hashing algorithms, and the hash value and storage location are recorded on the blockchain network to achieve collaborative interaction of on-chain and off-chain information, including: Encrypt the target data other than the data uploaded to the chain in each link of the agarwood to obtain the encrypted data; Based on the encrypted data, calculating a corresponding hash value and a storage location link; The target data is stored in an off-chain verifiable database outside the blockchain network, and the hash value and storage location link are recorded on the blockchain network.
9. The agarwood traceability method based on distributed identity and smart contracts according to claim 8 is characterized in that: Realize the coordinated interaction of on-chain and off-chain information, including: When data access or data verification is required, the hash value and storage location link corresponding to the data to be accessed are extracted from the blockchain; By linking the hash value and the storage location, the corresponding target data is obtained through the off-chain verifiable database; The hash value of the corresponding target data is calculated and compared with the hash value and the storage location link to achieve information collaborative interaction.
10. An agarwood traceability system based on distributed identity and smart contracts, characterized in that: The system comprises: The data collection module is used to collect and verify the electronic data files of agarwood at various stages, send the verified electronic data files to the distributed file system, and calculate the file data fingerprint hash value; The on-chain data determination module is used to determine the on-chain data based on the file data fingerprint hash value generated by the participants in each link and the electronic data file based on the distributed identity technology; The data on-chain module is used to design a smart contract based on the factory model. Participants in each link run the stack virtual machine locally through the smart contract parameters, and after reaching a consensus with each node on the running results, the on-chain data is recorded in the blockchain network; An off-chain data storage module is used to determine the target data of agarwood other than the on-chain data in each link, and store the target data in an off-chain verifiable database outside the blockchain network; An information interaction module is used to generate a hash value based on the stored off-chain data through encryption and hashing algorithms, and record the hash value and storage location on the blockchain network to achieve collaborative interaction of on-chain and off-chain information; The agarwood traceability module is used to obtain the smart contract address corresponding to the agarwood to be traced, call the query function according to the smart contract address, and obtain the data of each link corresponding to the agarwood to be traced.
Citation Information
Patent Citations
A product traceability information management system and method based on a block chain
CN109034833A
Decentralized storage system for DNS resource records, and implementation method and information retrieval method thereof
CN110061838A
Intelligent contract function-level dynamic monitoring analysis system and implementation method
CN112015628A
Grain and oil quality safety credible traceability method based on block chain and identifier analysis
CN114386992A
Agilawood tree and agilawood product traceability block chain platform
CN118014598A