Blockchain-based traceability code generation method, device and electronic device

The blockchain smart contract automatically generates the traceability code for each part of the target object after it is split. The non-tamperability of the blockchain is used to solve the problem that the traceability code is easy to be tampered with after the split, and the credibility and authenticity of the traceability code are achieved. .

CN114331471BActive Publication Date: 2024-09-13ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111572147.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-21
Publication Date
2024-09-13
Estimated Expiration
2041-12-21

AI Technical Summary

Technical Problem

It is difficult to effectively trace the traceability codes of different parts of the target object after splitting with the existing technology, and it is especially susceptible to tampering offline, resulting in the untrustworthiness of the traceability codes.

Method used

The smart contract of the blockchain automatically generates the unique traceability code corresponding to each designated part after the target object is split, and uses the non-tamperability of the blockchain to ensure the uniqueness and credibility of the traceability code.

Benefits of technology

In the scenario of splitting the target object, the unique traceability code generated for each designated part cannot be tampered with, which solves the problem of offline tampering with the traceability code and improves the credibility and authenticity of the traceability code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114331471B
    Figure CN114331471B
Patent Text Reader

Abstract

The embodiments of this specification provide a method and device for generating a traceability code based on blockchain and an electronic device. The method includes: receiving the generation data of the traceability code for the target object initiated by the first client; wherein the generation data includes the object identifier of the target object; in response to the generation data, calling the generation logic declared in the smart contract published on the blockchain, obtaining at least one sub-object obtained after the target object corresponding to the object identifier is split; wherein the at least one sub-object corresponds to different areas on the target object respectively; and generating a traceability code uniquely corresponding to each sub-object; so that the first client can assign a unique corresponding traceability code to each sub-object after the target object is split after obtaining the generated traceability code uniquely corresponding to each sub-object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of blockchain technology, and in particular to a blockchain-based traceability code generation method and device and electronic device. Background Art

[0002] The traceability code used for traceability is usually one-to-one, that is, each traceability object needs to be bound to a unique traceability code. In actual business, there are cases where the target object is split and used separately. For example, a whole pig will be bound to a unique traceability code before it is sold; however, when the whole pig is sold, the meat of different parts will be cut and sold separately, and the meat of these split parts cannot be effectively traced. Summary of the invention

[0003] The embodiments of this specification provide a blockchain-based traceability code generation method, device, and electronic device, which are used to solve the problem of tampering with the traceability codes of different parts of a target object after it is split.

[0004] According to a first aspect of an embodiment of this specification, a blockchain-based traceability code generation method is provided, which is applied to a computer device, and the method includes:

[0005] Receiving generation data of a traceability code for a target object initiated by a first client; wherein the generation data includes an object identifier of the target object;

[0006] In response to the generated data, calling the generation logic declared in the smart contract published on the blockchain, obtaining at least one sub-object obtained by splitting the target object corresponding to the object identifier; wherein the at least one sub-object corresponds to different areas on the target object respectively; and,

[0007] Generate a tracing code uniquely corresponding to each sub-object; so that after the first client obtains the generated tracing code uniquely corresponding to each sub-object, it assigns a unique tracing code to each sub-object after the target object is split.

[0008] According to a second aspect of an embodiment of this specification, there is provided a blockchain-based traceability code generation device, which is applied to a computer device, and the device includes:

[0009] A receiving unit, receiving generation data of a traceability code for a target object initiated by a first client; wherein the generation data includes an object identifier of the target object;

[0010] A response unit, in response to the generated data, calls the generation logic declared in the smart contract published on the blockchain, and obtains at least one sub-object obtained by splitting the target object corresponding to the object identifier; wherein the at least one sub-object corresponds to different areas on the target object respectively;

[0011] The generating unit generates a tracing code uniquely corresponding to each sub-object, so that after the first client obtains the generated tracing code uniquely corresponding to each sub-object, it allocates a unique tracing code to each sub-object after the target object is split.

[0012] According to a third aspect of the embodiments of this specification, there is provided an electronic device, including:

[0013] processor;

[0014] a memory for storing processor-executable instructions;

[0015] Wherein, the processor is configured as any of the above-mentioned blockchain-based traceability code generation methods.

[0016] The embodiments of this specification provide a traceability code generation solution based on blockchain, which automatically generates a unique graphic code corresponding to each designated part of the target object after it is split through a smart contract of the blockchain; since the execution process of the smart contract is not subject to external interference, and the execution result of the smart contract will be stored in the blockchain, in the scenario of splitting the target object, the generated unique graphic code corresponding to each designated part cannot be tampered with; therefore, in the scenario of splitting the target object, the problem of offline tampering with the graphic code of the designated part can be solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 This is a schematic diagram of the architecture of a traceability code generation system based on blockchain provided in an embodiment of this specification;

[0018] Figure 2 This is a flowchart of a method for generating a traceability code based on blockchain provided in an embodiment of this specification;

[0019] Figure 3 It is a schematic diagram of the target object splitting and the traceability code corresponding to each sub-object provided in an embodiment of this specification;

[0020] Figure 4 This is a hardware structure diagram of a blockchain-based traceability code generation device provided in an embodiment of this specification;

[0021] Figure 5 It is a module of a blockchain-based traceability code generation device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0022] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0023] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0024] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0025] The blockchain described in this specification may include private chains, public chains, and alliance chains, etc., which are not specifically limited in this specification. Node devices in the blockchain can be added without restriction, and each node device can synchronize a system time to ensure the timeliness of smart contract execution.

[0026] It should be noted that the transaction described in this specification refers to a piece of data created by a blockchain client and that needs to be ultimately published to the blockchain's data storage system.

[0027] Transactions in the blockchain are usually divided into narrow transactions and broad transactions. A transaction in the narrow sense refers to a value transfer published by a user to the blockchain; for example, in a traditional blockchain network, a transaction can be a transfer initiated by a user in the blockchain. A transaction in the broad sense refers to a business data with business intent published by a user to the blockchain; for example, an operator can build a consortium chain based on actual business needs, and rely on the consortium chain to deploy some other types of online services that are not related to value transfer (for example, broadly divided into query services, call services, etc.), and in this type of consortium chain, a transaction can be a business message or business request with business intent published by a user in the consortium chain.

[0028] The above-mentioned client may include any type of upper-layer application that uses the underlying business data stored in the blockchain as data support to implement specific business functions.

[0029] Please refer to Figure 1 , Figure 1 This is a schematic diagram of a network environment related to blockchain shown in this specification.

[0030] In such Figure 1 The network environment shown may include a client 101, a server 102, and at least one blockchain system; for example, blockchain system 103, blockchain system 104, and blockchain system 105.

[0031] In one implementation, the client 101 may include various types of client-side terminal devices; for example, the client-side terminal devices may include PC terminal devices, mobile terminal devices, Internet of Things devices, and other forms of smart devices with certain computing capabilities, etc.

[0032] In one embodiment, at least some of the computing devices in the client 101 may be coupled to the server 102 via various communication networks; for example, Figure 1 The device 3 shown in the figure is coupled to the server 102.

[0033] It is not difficult to understand that some terminal devices in the client 101 may not be coupled to the server 102, but directly coupled to the blockchain system through various communication networks as blockchain nodes; for example, Figure 1 The device 4 shown in the figure can be coupled to the blockchain system as a blockchain node.

[0034] Among them, the above-mentioned communication network may include wired and / or wireless communication networks; for example, it may be a local area network (LAN), a wide area network (WAN), the Internet or a combination thereof implemented based on a wired access network or a wireless access network (such as a mobile cellular network) provided by an operator.

[0035] In one implementation, the client 101 may also include one or more user-side servers; for example, Figure 1 At least some of the computing devices in the client 101 may be coupled to the user-side server, and the user-side server may be further coupled to the server 102; for example, Figure 1 The device 1 and the device 2 shown in the figure are coupled to the device 5 , and the device 5 is further coupled to the server 102 .

[0036] In one implementation, the user-side server may be implemented by a service entity that has built a user account system; the service entity may include an operating entity of a service carrier that provides various online and / or offline services to users;

[0037] The above service carrier may include a service carrier in the form of software or a service carrier in the form of hardware.

[0038] In one embodiment, the above-mentioned service carrier may include various client software that provides online Internet services; for example, a website, a webpage, an APP, etc.

[0039] In one implementation, the above-mentioned service carrier may also include various smart devices deployed offline and capable of providing offline services.

[0040] Correspondingly, the above-mentioned operating entity may include the operator corresponding to the above-mentioned service carrier; for example, the above-mentioned operating entity may include individuals, organizations, companies and enterprises that operate and manage the above-mentioned service carrier, etc.

[0041] In one embodiment, the server 102 may also be coupled to one or more blockchain systems via various communication networks; for example, Figure 1 The service end 102 shown in the figure can be coupled to the blockchain system 103, the blockchain system 104, the blockchain system 105, and so on.

[0042] In one embodiment, each blockchain system may maintain one or more blockchains (e.g., a public blockchain, a private blockchain, a consortium blockchain, etc.), and include multiple blockchain nodes for hosting the one or more blockchains; for example, Figure 1The blockchain nodes 1, 2, 3, 4, and i shown in the figure can jointly carry one or more blockchains. Cross-chain data access can also be performed between the blockchains included in each blockchain system and between each blockchain system.

[0043] In one embodiment, the blockchain node may include a full node and a light node. The full node may download all blockchain transactions contained in each block in the blockchain, and may perform consensus verification on the blockchain transactions contained in each blockchain according to the blockchain consensus algorithm installed.

[0044] Instead of downloading the entire blockchain, a light node can only download the block header data of each block in the blockchain and use the data contained in the block header as a verification root to verify the authenticity of blockchain transactions. Light nodes can be attached to full nodes to access more functions of the blockchain.

[0045] For example, Figure 1 Each blockchain node in the blockchain system 103 shown in FIG. 1 can serve as a full node; and Figure 1 The device 4 directly coupled to the blockchain system shown in the figure can be used as a light node and attached to each full node in the blockchain system 103.

[0046] In one implementation, a blockchain node can be a physical device or a virtual device implemented in a server or server cluster; for example, a blockchain node device can be a physical host in a server cluster, or a virtual machine created by virtualizing the hardware resources of a server or server cluster based on virtualization technology. Each blockchain node can be coupled together through various types of communication methods (such as TCP / IP) to form a network to carry one or more blockchains.

[0047] In one embodiment, the server 102 may include a BaaS platform (also referred to as a BaaS cloud) for providing blockchain as a service (BaaS, Blockchain as a Service). The BaaS platform can provide pre-written software for activities occurring on the blockchain (such as subscriptions and notifications, user verification, database management and remote updates), and provide easy-to-use, one-click deployment, fast verification, and flexible and customizable blockchain services for clients coupled to the BaaS platform, thereby accelerating the development, testing, and launch of blockchain business applications, and helping the implementation of blockchain business application scenarios in various industries.

[0048] For example, in one example, the BaaS platform can provide software such as MQ (Message Queue) services; the client coupled to the BaaS platform can subscribe to a smart contract deployed on a blockchain in the blockchain system coupled to the BaaS platform, and the contract events generated on the blockchain after the execution is triggered; and the BaaS platform can monitor the events generated on the blockchain after the smart contract is triggered, and then based on the software related to the MQ service, add the contract events to the message queue in the form of notification messages, so that the client subscribed to the message queue can receive notifications related to the above contract events.

[0049] In one embodiment, the BaaS platform can also provide enterprise-level platform services based on blockchain technology to help enterprise-level customers build a secure and stable blockchain environment and easily manage the deployment, operation, maintenance and development of blockchain.

[0050] For example, in one example, the BaaS platform can implement rich security policies and multi-tenant isolation environments based on cloud technology, provide advanced security protection based on chip encryption technology, and provide end-to-end high-availability services that can be quickly expanded without interruption based on highly reliable data storage;

[0051] In another example, enhanced management capabilities can also be provided to help customers build an enterprise-level blockchain network environment; and native support can be provided for standard blockchain applications and data, supporting mainstream open source blockchain technologies such as Hyperledger Fabric and Enterprise Ethereum-Quorum to build an open and inclusive technology ecosystem.

[0052] As mentioned above, the graphic code used for traceability is usually one-to-one, that is, each traceability object needs to be bound to a unique corresponding graphic code. In actual business, there are cases where the target object is split and used separately. For example, a whole pig will be bound to a unique corresponding graphic code before it is sold; however, when the whole pig is sold, the meat of different parts will be cut and sold separately, and the meat of these split parts cannot be effectively traced.

[0053] In the related art, in the case of splitting the target object, it is generally adopted to assign sub-traceability codes to different parts, and bind the sub-traceability code to the parent traceability code (that is, the traceability code uniquely corresponding to the target object). In this way, the user only needs to scan the sub-traceability code to associate it with the bound parent traceability code, and then query the traceability information of the target object based on the parent traceability code.

[0054] However, in actual applications, since the sub-traceability code is generated by a third party with an interest, and the binding process of the sub-traceability code cannot be managed, it is difficult to avoid the possibility of a third party tampering with the sub-traceability code of different parts of the target object after it is split. Taking pork as an example, since the segmentation result of a pig is certain, for example, a pig can only have one leg, and there can only be one front left leg, etc., the correct approach is to bind a unique sub-image to each segmented part.

[0055] However, since third parties are often sellers of whole pigs, in order to pursue profits, sellers may pass off inferior products as good ones, and pass off meat from the same part of other pigs as meat from this pig. For example, the parent traceability code of the same pig is associated with 8 child traceability codes of its legs, and 4 of the child traceability codes are all the front left legs.

[0056] Although the sub-traceability code has been tampered with, it is difficult to identify the malicious behavior of tampering with the sub-traceability code because the target object has been split and the traceability information associated with the parent traceability code bound to the sub-traceability code can indeed be queried according to the existing traceability process.

[0057] To this end, this specification aims to provide a traceability code generation solution based on blockchain, which automatically generates a unique graphic code corresponding to each designated part after the target object is split through the smart contract of the blockchain; since the execution process of the smart contract is not subject to external interference, and the execution result of the smart contract will be stored in the blockchain, in the scenario of splitting the target object, the generated unique graphic code corresponding to each designated part cannot be tampered with; therefore, in the scenario of splitting the target object, the problem of offline tampering with the graphic code of the designated part can be solved.

[0058] The following combination Figure 2 An embodiment of a method for generating a traceability code based on blockchain provided in this specification is introduced, which is applied to a computer device. The method includes:

[0059] Step 210: receiving generation data of a traceability code for a target object initiated by a first client; wherein the generation data includes an object identifier of the target object;

[0060] Step 220: In response to the generated data, calling the generation logic declared in the smart contract published on the blockchain, obtaining at least one sub-object obtained by splitting the target object corresponding to the object identifier; wherein the at least one sub-object corresponds to different areas on the target object; and,

[0061] Step 230: Generate a traceability code uniquely corresponding to each sub-object; so that after the first client obtains the generated traceability code uniquely corresponding to each sub-object, it assigns a unique traceability code to each sub-object after the target object is split.

[0062] Among them, the above-mentioned computer device may include a server corresponding to the blockchain, or a node device of the blockchain.

[0063] When the computer device is a node device of the blockchain, the client (including the first client and the second client in this specification) is as described above. Figure 1 The device 4 shown in FIG. 1 is directly coupled to the blockchain.

[0064] When the computer device is a server corresponding to the blockchain, the client (including the first client and the second client in this specification) is as described above. Figure 1 The device 3 shown in is coupled to the server, and the server can be further coupled to the blockchain through various communication networks. That is to say, in this embodiment, the client is not directly coupled to the blockchain.

[0065] In an exemplary embodiment, the server may include a blockchain as a service platform as described above.

[0066] In practical applications, the first client initiates the generation of the traceability code for the target object to the computer device; wherein the generation transaction includes the object identifier of the target object. The object identifier may be an identifier unique to the target object, such as the unique ID of the target object, the unique traceability code of the target object, etc.

[0067] After receiving the generated data, the computer device may respond to the generated data and query whether the blockchain stores the object identifier. If the blockchain stores the object identifier, the generation logic declared in the smart contract published on the blockchain may be called to obtain the target object corresponding to the object identifier stored in the blockchain, as well as at least one sub-object after the target object is split; wherein the at least one sub-object corresponds to different areas on the target object.

[0068] In an exemplary embodiment, the step of obtaining at least one sub-object obtained by splitting the target object corresponding to the object identifier includes:

[0069] Querying the target object corresponding to the object identifier stored in the blockchain;

[0070] Obtain at least one sub-object after the target object is split and bound to the target object and stored in the blockchain.

[0071] The at least one sub-object may be pre-stored on the chain for the target object. Generally, the splitting of the target object needs to be based on a preset splitting rule, and clear sub-objects can be obtained after the target object is split.

[0072] For example, there are clear regulations on how to cut up a whole pig, and the various parts after cutting up are also clear based on the regulations. Figure 3 The schematic diagram of the target object (taking a whole pig as an example) splitting shown in the figure shows that the whole pig can be split into 1-8 sub-objects, including the head 1, the back 2, the abdomen 3, the buttocks 4, and the front left elbow 5, the front right elbow 6, the rear left elbow 7, and the rear right elbow 8.

[0073] It should be noted that Figure 3 The sub-objects in the figure are only examples. In actual applications, the number of sub-objects after splitting is larger and more detailed. In addition, the splitting results of different target objects are also different.

[0074] After obtaining at least one sub-object after the target object stored in the blockchain is split, the computer device can further generate a traceability code uniquely corresponding to each sub-object based on the generation logic declared in the above-mentioned smart contract.

[0075] Continue with Figure 3 Taking the schematic diagram of the traceability codes corresponding to each sub-object shown in the figure as an example, a traceability code 1 uniquely corresponding to the head 1 is generated, a traceability code 2 uniquely corresponding to the back 2 is generated, and a traceability code 3 uniquely corresponding to the abdomen 3 is generated; and traceability codes uniquely corresponding to the buttocks 4, the front left elbow 5, the front right elbow 6, the rear left elbow 7, and the rear right elbow 8 are respectively generated, which are not shown in the figure.

[0076] Since the execution of smart contracts in the blockchain is not interfered by external factors, for example, the first client cannot control how the smart contract generates the traceability code, nor can it control which sub-object the generated traceability code is bound to; in addition, the execution result of the smart contract, that is, the traceability code, will also be recorded in the blockchain and cannot be tampered with; therefore, the traceability code that uniquely corresponds to each sub-object after the target object is split and automatically generated by the smart contract of the blockchain can be considered safe and reliable.

[0077] Furthermore, after the traceability code is generated, the first client may obtain the generated traceability code uniquely corresponding to each sub-object, and assign a unique traceability code to each sub-object after the target object is split.

[0078] The allocating a unique traceability code to each sub-object after the target object is split may refer to making the received traceability code into a traceability code label and pasting it to the uniquely corresponding sub-object.

[0079] The first client acquisition method may be active acquisition or passive acquisition.

[0080] In an exemplary active acquisition method, the first client can actively acquire the generated traceability code with the help of the event mechanism of the smart contract.

[0081] Among them, the event mechanism of smart contracts is a way for smart contracts to interact with entities outside the chain. For smart contracts deployed on the blockchain, it is usually impossible to directly interact with entities outside the chain; for example, after the smart contract is called, it is usually impossible to send the call result of the smart contract point-to-point to the call initiator of the smart contract.

[0082] The call results (including intermediate results and final call results) generated by the smart contract during the call process are usually recorded in the form of events in the transaction logs of the transaction that calls the smart contract and stored in the storage space of the node device. The off-chain entity (i.e., the first client) that needs to interact with the smart contract can obtain the call results of the smart contract by monitoring the transaction logs stored in the storage space of the node device;

[0083] The transaction log will eventually be stored in the MPT receipt tree as part of the receipt of the smart contract call transaction. The off-chain entity (the first client) that interacts with the smart contract can monitor the transaction receipts on the MPT receipt tree stored in the storage space of the node device, and obtain the generated traceability code that uniquely corresponds to each sub-object from the monitored transaction receipts.

[0084] In an exemplary passive acquisition method, the computer device may return the generated traceability code and the sub-object uniquely corresponding to the traceability code to the first client.

[0085] In another exemplary passive acquisition method, in addition to monitoring the events of the smart contract through the transaction log, the first client can also obtain the traceability code by subscribing to the smart contract. After the smart contract generates a traceability code that uniquely corresponds to each sub-object, the traceability code that uniquely corresponds to each sub-object can be actively pushed to the first client. The difference from the previous passive acquisition is that the former is actively sent by the node device, while this one is actively sent by the smart contract.

[0086] By applying the above embodiment, a unique traceability code corresponding to each sub-object after the target object is split is automatically generated through the smart contract of the blockchain; since the execution process of the smart contract is not subject to external interference, and the execution result of the smart contract will be stored in the blockchain, the unique traceability code corresponding to each generated sub-object cannot be tampered with; therefore, the problem of offline tampering with the traceability code of the sub-object can be solved.

[0087] In an exemplary embodiment, the above method may further include:

[0088] After calling the smart contract, the computer device can store the association relationship between the traceability code generated by the smart contract and the uniquely corresponding sub-object in the blockchain.

[0089] By applying the above embodiment, by storing the traceability code and the association between the traceability code and the uniquely corresponding sub-object in the blockchain, the stored information can be used as a basis for subsequent verification of whether the sub-object is authentic, thereby identifying offline tampering with the sub-object traceability code and improving the authenticity of the target object after splitting.

[0090] In an exemplary embodiment, the above method may further include:

[0091] The computer device receives verification data initiated by the second client for the target sub-object after the target object is split; wherein the verification data includes the target traceability code assigned to the target sub-object collected by the second client;

[0092] The computer device responds to the verification data by calling the verification logic declared in the smart contract published on the blockchain to query whether the target traceability code is stored in the blockchain;

[0093] If the target traceability code is stored in the blockchain, a sub-object uniquely corresponding to the target traceability code stored in the blockchain is further queried; so that after the second client obtains the queried sub-object, it determines whether it is consistent with the target sub-object based on the queried sub-object.

[0094] In actual applications, after the target object is split offline, if the user corresponding to the second client needs to purchase or use a target sub-object, he can collect the target traceability code on the target sub-object and initiate verification data to the computer device to verify whether the target sub-object truly belongs to the target object.

[0095] As mentioned earlier, the blockchain will store the traceability code generated by the smart contract, as well as the relationship between the traceability code and the unique corresponding sub-object.

[0096] Therefore, by querying the information stored in the blockchain, if the blockchain does not store a traceability code that is identical to the target traceability code, it means that the target traceability code is false. In this case, the computer device can return a verification result indicating that the verification failed, so that the user corresponding to the second client gives up purchasing or using the target sub-object.

[0097] If the blockchain stores a traceability code that is identical to the target traceability code, it means that the target traceability code is authentic, but it has not yet been determined whether the target sub-object is authentic; therefore, it is necessary to further query the sub-object of the target object that is uniquely corresponding to the target traceability code stored in the blockchain.

[0098] If the sub-object stored in the blockchain is inconsistent with the target sub-object determined by the second client, it means that the target sub-object is not split from the target object. In this case, the computer device can return a verification result indicating that the verification failed, so that the user corresponding to the second client gives up purchasing or using the target sub-object.

[0099] If the sub-object stored in the blockchain is consistent with the target sub-object determined by the second client, it means that the target sub-object is indeed split from the target object. The computer device can return a verification result indicating successful verification, so that the user corresponding to the second client can purchase or use the target sub-object with confidence.

[0100] By applying the above embodiment, a method for verifying whether an offline target sub-object is authentic is provided. By comparing the target traceability code of the target sub-object with the evidence record in the blockchain, offline tampering of the sub-object traceability code can be identified to avoid user losses.

[0101] In an exemplary embodiment, the above method may further include:

[0102] If the target traceability code is stored in the blockchain, the computer device can further query the traceability information of the target object corresponding to the target traceability code stored in the blockchain; so that the second client can display the traceability information after obtaining the queried traceability information.

[0103] In this embodiment, the blockchain can also store traceability information related to the target object. The traceability information can refer to the information of the target object in its entire life cycle from the beginning to the end.

[0104] The target object includes goods that can be split and sold, and the sub-object includes split goods obtained by splitting the goods. The traceability information includes production information and / or logistics information of the goods to be sold.

[0105] Taking pigs as an example, the life cycle of a pig can be started from breeding in a farm (i.e. the starting point), and ends with the pig growing up and being marketed in a slaughterhouse and finally sold at the terminal (i.e. the end point).

[0106] Relevant traceability information may include farm information (breeding time, market release time, etc.), pig growth information (such as feed information, health information, weight information, etc.), slaughterhouse information (such as slaughter time, slaughter operator, etc.), logistics information (such as dealers, distributors, terminal market information, etc.), and safety information (such as quarantine compliance information, food safety information, etc.).

[0107] Generally, the life cycle of the target object can be fully understood based on the traceability information, so as to determine whether there are any abnormalities in the target sub-object that the user needs to purchase or use. For example, based on the logistics information in the traceability information, it can be determined whether there is a situation of mixed goods, which refers to the abnormal situation of goods from other terminal markets appearing in the current terminal market. For another example, based on the safety information in the traceability information, it can be determined whether the target sub-object that the user needs to purchase or use is safe.

[0108] This embodiment is applied to provide the traceability information related to the target object stored in the blockchain to the second client so that the user corresponding to the second client can view it as a reference to determine whether to purchase or use the target sub-object.

[0109] In an exemplary embodiment, the querying of the traceability information of the target object corresponding to the target traceability code stored in the blockchain includes:

[0110] Querying the primary traceability code of the target object bound to the target traceability code stored in the blockchain;

[0111] Query the traceability information of the target object bound to the primary traceability code stored in the blockchain.

[0112] In this example, the main traceability code refers to the traceability code uniquely bound to the target object, and the traceability code uniquely corresponding to each sub-object can be called a sub-traceability code. After each sub-traceability code is generated, it can be bound to the main traceability code; through the binding relationship, the main traceability code can be queried from the target sub-traceability code, and then the traceability information of the target object bound to the main traceability code can be queried.

[0113] The object identifier of the aforementioned target object may refer to the primary traceability code. The first client initiates the generation data of the traceability code to the computer device by scanning the primary traceability code of the target object, and the generated data includes the primary traceability code. Correspondingly, the object identifier stored in the blockchain may also refer to the primary traceability code.

[0114] By using the existing main traceability code as the object identifier of the target object, the amount of additional data can be reduced (for example, only the main traceability code needs to be stored during storage, without the need to additionally store the object identifier).

[0115] Corresponding to the aforementioned blockchain-based traceability code generation method embodiment, this specification also provides a blockchain-based traceability code generation device embodiment. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the device in which it is located reading the corresponding computer program in the non-volatile memory into the memory and running it. From the hardware level, if Figure 4The following is a hardware structure diagram of the device where the traceability code generation device based on blockchain is located in this manual, except Figure 4 In addition to the processor, network interface, memory, and non-volatile memory shown, the device in which the apparatus in the embodiment is located generally generates actual functions according to a blockchain-based traceability code, and may also include other hardware, which will not be described in detail.

[0116] See also Figure 5 , is a module diagram of a traceability code generation device based on blockchain provided in an embodiment of this specification, and the device corresponds to Figure 2 The embodiment shown is applied to a computer device, and the device includes:

[0117] The receiving unit 410 receives the generation data of the traceability code for the target object initiated by the first client; wherein the generation data includes the object identifier of the target object;

[0118] The response unit 420, in response to the generated data, calls the generation logic declared in the smart contract published on the blockchain, and obtains at least one sub-object obtained by splitting the target object corresponding to the object identifier; wherein the at least one sub-object corresponds to different areas on the target object respectively;

[0119] The generating unit 430 generates a traceability code uniquely corresponding to each sub-object, so that after the first client obtains the generated traceability code uniquely corresponding to each sub-object, it allocates a unique traceability code to each sub-object after the target object is split.

[0120] In an exemplary embodiment, the apparatus further comprises:

[0121] The evidence storage unit, after generating the traceability code uniquely corresponding to each sub-object, stores the association relationship between the generated traceability code and the uniquely corresponding sub-object in the blockchain.

[0122] In an exemplary embodiment, the apparatus further comprises:

[0123] A receiving and verification unit receives verification data initiated by a second client for a target sub-object after the target object is split; wherein the verification data carries a target traceability code allocated to the target sub-object and collected by the second client;

[0124] The response verification unit, in response to the verification data, calls the verification logic declared in the smart contract published on the blockchain, and queries whether the target traceability code is stored in the blockchain; if the target traceability code is stored in the blockchain, further queries the sub-object uniquely corresponding to the target traceability code stored in the blockchain; so that after obtaining the queried sub-object, the second client determines whether it is consistent with the target sub-object based on the queried sub-object.

[0125] In an exemplary embodiment, the apparatus further comprises:

[0126] The traceability unit further queries the traceability information of the target object corresponding to the target traceability code stored in the blockchain if the target traceability code is stored in the blockchain; so that the second client displays the traceability information after obtaining the queried traceability information.

[0127] In an exemplary embodiment, the traceability unit queries the traceability information of the target object corresponding to the target traceability code stored in the blockchain, including:

[0128] Querying the primary traceability code of the target object bound to the target traceability code stored in the blockchain;

[0129] Query the traceability information of the target object bound to the primary traceability code stored in the blockchain.

[0130] In an exemplary embodiment, the target object includes a commodity that can be split and sold, and the sub-objects include split commodities obtained by splitting the commodity.

[0131] In an exemplary embodiment, the response unit 420 obtains at least one sub-object obtained by splitting the target object corresponding to the object identifier, including:

[0132] Querying the target object corresponding to the object identifier stored in the blockchain;

[0133] Obtain at least one sub-object after the target object is split and bound to the target object and stored in the blockchain.

[0134] In an exemplary embodiment, the computer device includes a server corresponding to the blockchain, or a node device of the blockchain.

[0135] In an exemplary embodiment, the service end includes a blockchain as a service platform.

[0136] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0137] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0138] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.

[0139] above Figure 5 The internal functional modules and structural schematic diagram of the traceability code generation device based on blockchain are described. Its actual execution subject can be an electronic device, including:

[0140] processor;

[0141] a memory for storing processor-executable instructions;

[0142] In which, the processor is configured to execute any of the above-mentioned embodiments of the blockchain-based traceability code generation method.

[0143] In the above-mentioned embodiment of the electronic device, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc., and the aforementioned memory can be a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk or a solid-state drive. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.

[0144] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the electronic device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0145] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention disclosed herein. The specification is intended to cover any variations, uses, or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not disclosed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0146] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

Claims

1. A blockchain-based traceability code generation method, applied to a computer device, the method comprising: Receiving generation data of a traceability code for a target object initiated by a first client; wherein the generation data includes a primary traceability code of the target object; In response to the generated data, the generation logic declared in the smart contract published on the blockchain is called to obtain at least one sub-object obtained by splitting the target object corresponding to the main traceability code; wherein the at least one sub-object corresponds to different areas on the target object respectively; and, Generate a sub-traceability code uniquely corresponding to each sub-object; so that the first client can assign a unique sub-traceability code to each sub-object after the target object is split after acquiring the generated sub-traceability code uniquely corresponding to each sub-object; After generating a sub-traceability code uniquely corresponding to each sub-object, each sub-traceability code is bound to the main traceability code, and the corresponding relationship between the generated sub-traceability code and the uniquely corresponding sub-object and the binding relationship between each sub-traceability code and the main traceability code are recorded in the blockchain.

2. The method according to claim 1, further comprising: Receiving verification data initiated by the second client for the target sub-object after the target object is split; wherein the verification data includes the target sub-traceability code allocated to the target sub-object and collected by the second client; In response to the verification data, calling the verification logic declared in the smart contract published on the blockchain to query whether the target sub-traceability code is stored in the blockchain; If the target sub-traceability code is stored in the blockchain, a sub-object uniquely corresponding to the target sub-traceability code stored in the blockchain is further queried; so that after the second client obtains the queried sub-object, it determines whether it is consistent with the target sub-object based on the queried sub-object.

3. The method according to claim 2, further comprising: If the target sub-traceability code is stored in the blockchain, the traceability information of the target object corresponding to the target sub-traceability code stored in the blockchain is further queried; so that the second client displays the traceability information after obtaining the queried traceability information.

4. According to the method of claim 3, the querying of the traceability information of the target object corresponding to the target sub-traceability code stored in the blockchain comprises: Querying the primary traceability code of the target object bound to the target sub-traceability code stored in the blockchain; Query the traceability information of the target object bound to the primary traceability code stored in the blockchain.

5. According to the method of claim 1, the target object includes a commodity that can be split and sold, and the sub-object includes split commodities obtained by splitting the commodity.

6. According to the method of claim 1, the step of obtaining at least one sub-object obtained by splitting the target object corresponding to the primary traceability code comprises: Querying the target object corresponding to the primary traceability code stored in the blockchain; Obtain at least one sub-object after the target object is split and bound to the target object and stored in the blockchain.

7. According to the method according to claim 1, the computer device includes a server corresponding to the blockchain, or a node device of the blockchain.

8. According to the method of claim 7, the service end includes a blockchain as a service platform.

9. A blockchain-based traceability code generation device, applied to a computer device, comprising: A receiving unit, receiving generation data of a traceability code for a target object initiated by a first client; wherein the generation data includes a primary traceability code of the target object; A response unit, in response to the generated data, calls the generation logic declared in the smart contract published on the blockchain, and obtains at least one sub-object obtained by splitting the target object corresponding to the main traceability code; wherein the at least one sub-object corresponds to different areas on the target object respectively; A generating unit, generating a sub-traceability code uniquely corresponding to each sub-object, so that the first client can assign a unique sub-traceability code to each sub-object after the target object is split after acquiring the generated sub-traceability code uniquely corresponding to each sub-object; The evidence storage unit, after generating the sub-traceability code uniquely corresponding to each sub-object, binds each sub-traceability code to the main traceability code, and stores the association relationship between the generated traceability code and the uniquely corresponding sub-object and the binding relationship between each sub-traceability code and the main traceability code in the blockchain.

10. The device according to claim 9, further comprising: A receiving and verification unit receives verification data initiated by a second client for a target sub-object after the target object is split; wherein the verification data carries a target sub-traceability code allocated to the target sub-object and collected by the second client; The response verification unit, in response to the verification data, calls the verification logic declared in the smart contract published on the blockchain, and queries whether the target sub-traceability code is stored in the blockchain; if the target sub-traceability code is stored in the blockchain, further queries the sub-object uniquely corresponding to the target sub-traceability code stored in the blockchain; so that after obtaining the queried sub-object, the second client determines whether it is consistent with the target sub-object based on the queried sub-object.

11. The device according to claim 10, further comprising: The traceability unit further queries the traceability information of the target object corresponding to the target sub-tracing code stored in the blockchain if the target sub-tracing code is stored in the blockchain; so that the second client displays the traceability information after obtaining the queried traceability information.

12. The device according to claim 11, wherein the querying of the traceability information of the target object corresponding to the target sub-traceability code stored in the blockchain comprises: Querying the primary traceability code of the target object bound to the target sub-traceability code stored in the blockchain; Query the traceability information of the target object bound to the primary traceability code stored in the blockchain.

13. The device according to claim 9, wherein the target object comprises a commodity that can be split and sold, and the sub-object comprises split commodities obtained by splitting the commodity.

14. The device according to claim 9, wherein the step of obtaining at least one sub-object obtained by splitting the target object corresponding to the primary traceability code comprises: Querying the target object corresponding to the primary traceability code stored in the blockchain; Obtain at least one sub-object after the target object is split and bound to the target object and stored in the blockchain.

15. According to the apparatus according to claim 9, the computer device includes a server corresponding to the blockchain, or a node device of the blockchain.

16. The device according to claim 15, wherein the service end comprises a blockchain as a service platform.

17. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 8.