Resource exchange method and device based on block chain, equipment, medium and product

By acquiring and processing resource data sets, efficient resource redemption and record management is realized on the blockchain, and the problem of low efficiency in querying resource redemption records in the existing technology is solved.

CN119850203APending Publication Date: 2025-04-18GUANGZHOU TENCENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311341400.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-16
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the prior art, it is inefficient to view historical redemption records after resource redemption, and it is necessary to traverse all redemption records to analyze the redemption process.

Method used

By obtaining a resource data set including resource status identifier and voucher identification, when the redemption status meets the requirements, resource redemption is performed between accounts based on the voucher data, and after the redemption is successful, the resource status identifier is reset and the updated data set is stored.

Benefits of technology

The query efficiency of resource redemption records is improved, so that subsequent accounts can directly obtain the historical redemption records of resources on the chain through the reset resource status identifier without analyzing the redemption process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850203A_ABST
    Figure CN119850203A_ABST
Patent Text Reader

Abstract

The invention discloses a resource exchange method and device based on a block chain, equipment, a medium and a product, and relates to the technical field of block chains. The method comprises the following steps: acquiring a resource data set corresponding to resources on a chain; under the condition that the exchange state meets the exchange requirement, transferring the on-chain resource from the first account to a second account based on the voucher data, and transferring an exchange resource corresponding to the on-chain resource in the second account to the first account; and in response to successful exchange of the resources on the chain, performing state resetting on the resource state identifier in the resource data set, and storing the updated resource data set. Through the above mode, the subsequent account can directly obtain the historical exchange record corresponding to the on-chain resource through the reset resource state identifier, and the query efficiency of the resource exchange record is improved. The method can be applied to various scenes such as cloud technology, artificial intelligence and intelligent transportation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of blockchain technology, and in particular to a resource exchange method, device, equipment, medium and product based on blockchain. Background Art

[0002] With the continuous development of blockchain, resource exchange using blockchain technology has also emerged. Among them, the resource exchange process is that in the exchange platform, the first account places an order for the target resource stored on the blockchain, and the second account accepts the order from the first account to complete a resource exchange. In this resource exchange process, the first account transfers the target resource to the second account, and the second account transfers the exchange resource corresponding to the target resource to the first account.

[0003] In the related technology, the first account signs the exchange request for the target resource and stores the signature. The second account uses the signature to call the resource exchange contract corresponding to the exchange platform. After the resource exchange contract verifies the legitimacy of the signature, the resource exchange process between the second account and the first account is realized.

[0004] However, in the related art, after the second account completes the resource exchange, if it wants to view its own historical exchange records, it is necessary to traverse all resource exchange records in the resource exchange contract and analyze the exchange process in each resource exchange record to determine the resource exchange record belonging to the second account, thereby reducing the efficiency of resource exchange record query. Summary of the invention

[0005] The embodiments of the present application provide a resource exchange method, device, equipment, medium and product based on blockchain, which can improve the query efficiency of resource exchange records. The technical solution is as follows.

[0006] In one aspect, a resource exchange method based on blockchain is provided, the method being executed by a node in a blockchain system, the method comprising:

[0007] Obtain a resource data set corresponding to an on-chain resource, wherein the resource data set includes a resource status identifier and a credential identifier, the credential identifier corresponds to credential data, the on-chain resource is a resource deployed in the blockchain system by a first account, the credential data is used to indicate an exchange requirement corresponding to the on-chain resource, and the resource status identifier is used to indicate an exchange status of the on-chain resource;

[0008] If the exchange status meets the exchange requirements, transfer the on-chain resource from the first account to the second account based on the voucher data, and transfer the exchange resource corresponding to the on-chain resource in the second account to the first account;

[0009] In response to the successful exchange of the on-chain resources, the resource status identifier in the resource data set is reset, and the updated resource data set is stored, wherein the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to the historical exchange record that has been exchanged.

[0010] On the other hand, a resource exchange device based on blockchain is provided, the device comprising:

[0011] An acquisition module, used to acquire a resource data set corresponding to an on-chain resource, wherein the resource data set includes a resource status identifier and a credential identifier, wherein the credential identifier corresponds to credential data, wherein the on-chain resource is a resource deployed in the blockchain system by a first account, wherein the credential data is used to indicate an exchange requirement corresponding to the on-chain resource, and wherein the resource status identifier is used to indicate an exchange status of the on-chain resource;

[0012] a transfer module, configured to transfer the on-chain resource from the first account to the second account based on the voucher data when the exchange status meets the exchange requirements, and transfer the exchange resource corresponding to the on-chain resource in the second account to the first account;

[0013] A storage module is used to reset the resource status identifier in the resource data set in response to the successful exchange of the on-chain resources, and store the updated resource data set, wherein the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to a historical exchange record that has been exchanged.

[0014] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement a resource exchange method based on blockchain as described in any of the above-mentioned embodiments of the present application.

[0015] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, a code set or an instruction set is stored in the storage medium, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the blockchain-based resource exchange method as described in any of the above-mentioned embodiments of the present application.

[0016] On the other hand, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any of the resource exchange methods based on blockchain described in the above embodiments.

[0017] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:

[0018] After obtaining a resource data set including a resource status identifier and a voucher identifier, when the exchange status corresponding to the resource status identifier meets the exchange requirements, the on-chain resources are exchanged between the first account and the second account according to the voucher data corresponding to the voucher identifier. After the exchange is successful, the resource status identifier is reset, and the updated resource data set is stored. That is, when the resource exchange is completed, the resource status identifier representing the exchange status of the on-chain resource is reset, and the resource data set containing the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 This is a structural diagram of a distributed system provided by an exemplary embodiment of the present application applied to a blockchain system;

[0021] Figure 2 is a schematic diagram of a block structure provided by an exemplary embodiment of the present application;

[0022] Figure 3 It is a schematic diagram of an implementation environment provided by an exemplary embodiment of the present application;

[0023] Figure 4 is a flowchart of a resource exchange method based on blockchain provided by an exemplary embodiment of the present application;

[0024] Figure 5 is a flowchart of a resource exchange method based on blockchain provided by another exemplary embodiment of the present application;

[0025] Figure 6 is a flowchart of a resource exchange method based on blockchain provided by another exemplary embodiment of the present application;

[0026] Figure 7 is a schematic diagram of a resource exchange method based on blockchain provided by another exemplary embodiment of the present application;

[0027] Figure 8 It is a structural block diagram of a resource exchange device based on blockchain provided by an exemplary embodiment of the present application;

[0028] Fig. 9 It is a structural block diagram of a resource exchange device based on blockchain provided by an exemplary embodiment of the present application;

[0029] Fig.10 It is a structural block diagram of a server provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0031] First, a brief introduction is given to the terms involved in the embodiments of the present application.

[0032] Blockchain: Blockchain is a distributed ledger technology in the field of information technology. It is generally composed of consensus, transaction blocks and status data storage, cryptographic identity security, etc. Since the ledger is stored in a distributed manner and the blocks are agreed upon, it has the characteristics of being tamper-proof, traceable, and jointly maintained.

[0033] Smart contract: A smart contract is a program that runs on the blockchain. Unlike ordinary programs, smart contracts must ensure that the results of running in every node of the blockchain network are exactly the same, so that any node can verify whether the results of the smart contract execution in the block are correct.

[0034] Decentralized Identity (DID): Decentralized digital identity is a digital identity built on blockchain technology. It can ensure that the account's identity data is authentic and reliable, while also protecting the account's privacy and ensuring that data related to the account's identity belongs to the account.

[0035] Verifiable Credential (VC): Verifiable Credential is a credential data such as identity proof, capability proof, permission description or report sent by a designated authority to a specific object (e.g. account). Its essence is to transfer the practicality and portability of physical identity credentials to digital devices.

[0036] In the related art, resource exchange based on blockchain technology has developed rapidly, and users usually exchange resources on a designated exchange platform. For example, a first account uses a private key to sign the relevant information of the target resource to be exchanged (for example, the contract address corresponding to the target resource, resource identifier, etc.) and the exchange requirement, and then uses the signature to initiate an exchange request for the target resource. The second account exchanges resources with the first account based on the signature. That is, from an external perspective, for data security reasons, the second account can only receive the exchange request initiated by the first account, but cannot directly obtain the specific exchange information about the target resource in the exchange request. Therefore, after the second account exchanges the target resource, if it wants to view the resource exchange record to which it belongs, it also needs to traverse all the exchange records and analyze the specific exchange information to determine the exchange record belonging to itself. Therefore, the query efficiency of the resource exchange record is reduced.

[0037] In an embodiment of the present application, after obtaining a resource data set including a resource status identifier and a voucher identifier, when the exchange status corresponding to the resource status identifier meets the exchange requirements, the on-chain resource is exchanged between the first account and the second account according to the voucher data corresponding to the voucher identifier, and after the exchange is successful, the resource status identifier is reset, and the updated resource data set is stored. That is, when the resource exchange is completed, after the resource status identifier representing the exchange status of the on-chain resource is reset, the resource data set including the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records.

[0038] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions. For example, the on-chain resources, resource data sets and other contents involved in this application are all obtained with full authorization.

[0039] The system involved in the embodiments of the present application may be a distributed system formed by connecting a client and multiple nodes (any form of computing devices in an access network, such as a server and a user terminal) through network communication.

[0040] Take the distributed system as the blockchain system as an example, see Figure 1 , Figure 1 This is an optional structural diagram of the distributed system 100 provided in the embodiment of the present application applied to the blockchain system, which is formed by multiple nodes (any form of computing devices in the access network, such as: servers, user terminals) and clients, and a point-to-point network is formed between the nodes. The point-to-point protocol is an application layer protocol running on the Transmission Control Protocol (TCP) protocol. In a distributed system, any machine such as a server or a terminal can join and become a node, and the node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.

[0041] See also Figure 1 The functions of each node in the blockchain system shown include:

[0042] 1) Routing: a basic function of a node, used to support communication between nodes.

[0043] In addition to the routing function, the node can also have the following functions:

[0044] 2) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system for other nodes to add the record data to a temporary block when they successfully verify the source and integrity of the record data.

[0045] For example, the services implemented by the application include:

[0046] 2.1) Wallet, used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After successful verification by other nodes, as a response to acknowledging the validity of the transaction, the transaction record data is stored in a temporary block of the blockchain; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address.

[0047] 2.2) Shared ledger, which is used to provide functions such as storage, query and modification of account data. The record data of the operation on the account data is sent to other nodes in the blockchain system. After other nodes verify the validity, as a response to acknowledging the validity of the account data, the record data is stored in a temporary block, and a confirmation can also be sent to the node that initiated the operation.

[0048] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented by deploying code on a shared ledger that is executed when certain conditions are met. The code is used to complete automated transactions based on actual business needs, such as querying the logistics status of goods purchased by the second account, and transferring the electronic currency of the second account to the merchant's address after the second account signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.

[0049] 3) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system.

[0050] See also Figure 2 , Figure 2 It is an optional schematic diagram of the block structure (Block Structure) provided in the embodiment of the present application. Each block includes the hash value of the transaction record stored in this block (the hash value of this block) and the hash value of the previous block. Each block is connected by the hash value to form a blockchain. In addition, the block can also include information such as the timestamp when the block was generated. Blockchain (Block chain) is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block.

[0051] In an optional embodiment, the implementation environment involved in the embodiment of the present application is described, and the blockchain-based resource exchange method provided in the embodiment of the present application is implemented by executing a node in the blockchain system.

[0052] For illustration, please refer to Figure 3 The implementation environment involves a resource publisher 310, a node 320 in a blockchain system, and a resource exchanger 330. The resource publisher can be implemented as a first account, and the resource exchanger can be implemented as a second account.

[0053] In some embodiments, the resource publisher 310 is used to publish on-chain resources in the blockchain system so that the node 320 in the blockchain system obtains at least one on-chain resource. The on-chain resource is a resource deployed in the blockchain system.

[0054] In some embodiments, the node 320 in the blockchain system also receives a configuration instruction. Schematically, the configuration instruction is an instruction issued by the resource publisher 310 for configuring parameters of the exchange requirements of the on-chain resources. The configuration instruction includes at least one voucher data. The configuration instruction is used to configure the voucher data in the blockchain system. The voucher data is used to characterize the exchange requirements corresponding to the on-chain resources.

[0055] In some embodiments, the node 320 in the blockchain system stores a resource data set corresponding to the on-chain resource based on the configuration instruction, and the resource data set includes a resource status identifier and a credential identifier corresponding to the credential data, wherein the resource status identifier is used to indicate the exchange status of the on-chain resource. In another case, the node 320 includes a plurality of resource data sets corresponding to different on-chain resources, and only one of them is described in detail in this embodiment.

[0056] In some embodiments, the resource exchanger 330 is used to send a status query request to the node 320 in the blockchain system, and the status query request is used to request to view the exchange status corresponding to the on-chain resource. After receiving the status query request, the node 320 in the blockchain system sends the resource data set corresponding to the on-chain resource to the resource exchanger 330.

[0057] After the resource exchanger 330 receives the resource data set, if it is determined according to the resource status identifier that the on-chain resource is in a pending exchange state, and if it is determined according to the voucher data corresponding to the voucher identifier that the exchange resource currently held by the resource exchanger 330 meets the resource exchange quantity requirement of the on-chain resource, the resource exchanger 330 sends an exchange request to the node 320 in the blockchain system to request the exchange of the on-chain resource.

[0058] After receiving the exchange request, the node 320 in the blockchain system transfers the on-chain resources from the first account corresponding to the resource publisher 310 to the second account corresponding to the resource exchanger 330 based on the voucher data, and transfers the exchange resources corresponding to the on-chain resources in the second account to the first account.

[0059] When the on-chain resource exchange is successful, the node 320 in the blockchain system resets the resource status identifier in the resource data set and stores the updated resource data set, wherein the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to the historical exchange record that has been exchanged.

[0060] In some embodiments, the node 320 in the blockchain system can be implemented as a server, and the resource publisher 310 and / or the resource exchanger 330 can be implemented as a terminal; or, the node 320 in the blockchain system can be implemented as a server, etc. The above implementation environment is only an illustrative example, and the embodiments of the present application are not limited to this.

[0061] It is worth noting that the above-mentioned terminals include but are not limited to mobile terminals such as mobile phones, tablet computers, portable laptops, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc., and can also be implemented as desktop computers, etc.; the above-mentioned servers can be independent physical servers, or they can be server clusters or distributed systems composed of multiple physical servers, or they can be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0062] Among them, cloud technology refers to a hosting technology that unifies hardware, application programs, networks and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient.

[0063] In combination with the above-mentioned noun introduction and application scenarios, the resource exchange method based on blockchain provided by this application is explained, and the method is applied to a node in a blockchain system as an example. Figure 4 As shown, the method includes the following steps 410 to 430.

[0064] Step 410, obtaining a resource data set corresponding to the on-chain resources.

[0065] Among them, the resource data set includes a resource status identifier and a credential identifier. The credential identifier corresponds to the credential data. The on-chain resource is a resource deployed in the blockchain system by the first account. The credential data is used to indicate the exchange requirements corresponding to the on-chain resource, and the resource status identifier is used to indicate the exchange status of the on-chain resource.

[0066] In principle, the resources that have been put on-chain are called on-chain resources. The on-chain processing is used to instruct the first account to upload the resources (data) to the blockchain system so that each node in the blockchain system can reach a consensus on the on-chain process of the resources. Then the resources can be called on-chain resources.

[0067] In some embodiments, in the process of obtaining resources by the first account, the resources will be stored in the nodes in the blockchain system, and the resources after multiple nodes reach consensus are the on-chain resources, so that the blockchain system obtains at least one on-chain resource. In the embodiments of the present application, the first account also refers to the resource publisher.

[0068] In some embodiments, the types of on-chain resources involved in the blockchain-based resource exchange method can also be completed by executing a resource contract for recording on-chain resource generation, exchange, etc. to complete the blockchain-based resource exchange method.

[0069] Schematically, different on-chain resources correspond to different resource data sets, that is, the resource data sets corresponding to the on-chain resources are unique to the on-chain resources.

[0070] In some embodiments, the resource status identifier is an identifier used to indicate the exchange status corresponding to the current on-chain resource. Optionally, the resource status identifier includes three types of identifiers: pending exchange status, exchange completed, and non-convertible status. For example, the pending exchange status corresponds to "1", the exchange completed corresponds to "0", and the non-convertible status corresponds to "2".

[0071] Optionally, the resource status identifiers corresponding to resources on different chains are the same when they are in the same exchange state; or, the resource status identifiers corresponding to resources on different chains are different.

[0072] In some embodiments, the voucher data is used to represent the redemption requirements corresponding to the on-chain resources, including: the contract address corresponding to the on-chain resources, the redemption resource requirements required to redeem the on-chain resources (including at least one of the redemption resource type requirements and the redemption resource quantity requirements), the contract address corresponding to the redemption resource requirements, the redemption start time, the redemption end time, the number of redeemable on-chain resources, the redemption status, the resource identifier, the signature, the voucher identifier, and at least one of the sub-data such as the account identity identifier corresponding to the account document.

[0073] The contract address refers to the unique identifier corresponding to the contract created on Ethereum or other smart contract platforms. A contract is a code snippet that can automatically perform a specific task, and the contract address is used to uniquely identify the place where the contract code and data are stored.

[0074] Among them, the account identity corresponding to the account document is used to indicate the account to which the on-chain resource belongs.

[0075] Optionally, the voucher data is constructed by the first account according to various redemption requirement parameters; or, the first account sends a data configuration instruction to a node in the blockchain system, and the data configuration instruction includes various redemption requirement parameters, so that the node in the blockchain system constructs the voucher data according to the data configuration instruction.

[0076] Illustratively, the credential identifier is a unique identifier corresponding to the credential data.

[0077] Optionally, a node in the blockchain system receives a resource data set sent by the first account; or, a node in the blockchain system receives credential data sent by the first account, and obtains a stored resource data set from the node in the blockchain system based on the credential data.

[0078] It is worth noting that the unique identifier involved in the embodiments of the present application is for specified data, that is, the contract address corresponding to the contract and the voucher identifier corresponding to the voucher data are two different identification symbols, referring to different objects.

[0079] Step 420, when the exchange status meets the exchange requirements, the on-chain resources are transferred from the first account to the second account based on the voucher data, and the exchange resources corresponding to the on-chain resources in the second account are transferred to the first account.

[0080] Optionally, when obtaining a resource status identifier in a resource data set, the exchange status of the on-chain resource is determined according to the identification content of the resource status identifier. When the exchange status is in the state of pending exchange, it is considered that the exchange status of the on-chain resource meets the exchange requirements.

[0081] Optionally, in addition to the above-mentioned situation where the exchange status is pending exchange, when the corresponding voucher data is obtained according to the voucher identifier in the resource data set, the exchange resource quantity requirement required to exchange the on-chain resources in the voucher data is compared with the quantity of exchange resources owned in the second account. If the quantity of all exchange resources in the second account meets the resource quantity requirement corresponding to the on-chain resources, it is considered that the exchange status of the on-chain resources and the exchange resource balance of the second account both meet the exchange requirements.

[0082] In some embodiments, when the redemption status meets the redemption requirements, the redemption function is called, the relevant redemption requirement parameters in the voucher data are filled into the redemption function, the on-chain resources are transferred from the first account to the second account using the redemption function, and the redemption resources corresponding to the on-chain resources in the second account are transferred to the first account using the redemption function, thereby completing the on-chain resource redemption process.

[0083] Optionally, several examples of on-chain resource transfer methods are given:

[0084] In the first case, when transferring the on-chain resources from the first account to the second account, the resource ownership account in the credential data is rewritten from the account identity corresponding to the first account to the account identity corresponding to the second account.

[0085] Among them, the account document is used to describe the characteristics of the digital identity corresponding to the account. When DID is used to represent the digital identity corresponding to an account, the account corresponds to a unique DID document. It can be understood that the DID document contains all the data that can represent the digital identity information corresponding to the account. The account identity identifier corresponding to the first account is the unique identifier specified by the first account document, that is, there is a one-to-one correspondence between the account identity identifier corresponding to the account document and the account document.

[0086] In the second case, when the on-chain resource belongs to the first account, the resource identifier corresponding to the on-chain resource is stored in the first account address corresponding to the first account, and the resource identifier in the first account address is transferred to the second account address corresponding to the second account through the redemption function.

[0087] Among them, the account address is the account address corresponding to the object used in the blockchain system, which is used to receive and store digital assets (for example: on-chain resources, exchange resources).

[0088] Schematically, there is a one-to-one correspondence between each account address and account.

[0089] Optionally, multiple on-chain resources respectively correspond to resource identifiers; the resource identifiers uniquely identify the on-chain resources.

[0090] Indicatively, each on-chain resource is unique, and each on-chain resource corresponds to a resource identifier, through which the corresponding on-chain resource can be uniquely represented. For example: on-chain resource 1 corresponds to resource identifier A, on-chain resource 2 corresponds to resource identifier B, and so on.

[0091] In the third case, in the process of transferring the on-chain resource from the first account to the second account, the resource data set corresponding to the on-chain resource is directly written into the second account.

[0092] Illustratively, in the process of transferring the exchange resources corresponding to the on-chain resources in the second account to the first account, when the exchange resources belong to the second account, the exchange resource identifier corresponding to the exchange resource (including the resource type and resource quantity, which is different from the resource identifier) ​​is stored in the second account address. Through the exchange function, the exchange resource identifier is deleted from the second account address and added to the first account address, wherein the resource type and resource quantity contained in the exchange resource identifier meet the exchange resource requirements corresponding to the on-chain resources.

[0093] Step 430, in response to the successful exchange of resources on the chain, the resource status identifier in the resource data set is reset, and the updated resource data set is stored.

[0094] Among them, the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to the historical exchange record that has been exchanged.

[0095] In an illustrative manner, when the on-chain resource is successfully transferred from the first account to the second account, and the exchange resource corresponding to the on-chain resource is successfully transferred from the second account to the first account, the on-chain resource exchange is deemed to be successful.

[0096] Optionally, during the process of resetting the resource status identifier, an initialization status identifier is pre-set, and the current resource status identifier is changed to the initialization status identifier as a status reset result; or, the resource status identifier is set to empty (including setting it to 0 or directly as a space character) as a status reset result.

[0097] In some embodiments, the resource state identifier and the credential identifier after the state is reset are used as the updated resource data set.

[0098] Optionally, after obtaining the updated resource data set, the resource data set is stored in a node of the blockchain system, that is, on-chain storage is performed; or, the resource data set is stored in a designated storage module, wherein the storage module is a server module unrelated to the blockchain system, that is, off-chain storage is performed.

[0099] In some embodiments, taking the first account as an example, if the first account wants to prove that it has owned a certain on-chain resource or exchanged a certain on-chain resource, it obtains the credential data that the account has constructed, extracts the credential identifier corresponding to the credential data, and determines the corresponding updated resource data set according to the credential identifier, obtains the resource status identifier from the updated resource data set, and matches the resource status identifier with the contract address and resource identifier corresponding to the on-chain resource in the credential data. If the match is successful, it indicates that the on-chain resource corresponding to the updated resource data set belongs to the on-chain resource that the first account once owned and has been successfully exchanged.

[0100] In some embodiments, taking the second account or blockchain system as an example, by obtaining the credential data, the updated resource data set is determined according to the credential identifier corresponding to the credential data, and the historical exchange record corresponding to the on-chain resource is obtained according to the updated resource data set.

[0101] In schematic form, the historical exchange record refers to the resource transfer process of on-chain resources from a first account to a second account.

[0102] In summary, the blockchain-based resource exchange method provided in the embodiment of the present application, after obtaining a resource data set including a resource status identifier and a voucher identifier, when the exchange status corresponding to the resource status identifier meets the exchange requirements, the on-chain resources are exchanged between the first account and the second account according to the voucher data corresponding to the voucher identifier, and after the exchange is successful, the resource status identifier is reset, and the updated resource data set is stored. That is, when the resource exchange is completed, after the resource status identifier representing the exchange status of the on-chain resource is reset, the resource data set containing the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records.

[0103] In some embodiments, the resource status indicator is adjusted to a specified reset indicator as an example for explanation. For illustration, please refer to Figure 5 , which shows a flowchart of a resource exchange method based on blockchain provided by an exemplary embodiment of the present application, that is, before step 410, steps 4101 to 4103 are also included, step 410 also includes step 411, step 420 also includes steps 421 to 423, and step 430 also includes steps 431 to 433, such as Figure 5 As shown, the current embodiment includes the following steps.

[0104] Step 4101, obtain the voucher data corresponding to the on-chain resources through the resource exchange contract.

[0105] Among them, the resource exchange contract is a smart contract used to coordinate on-chain resources for resource exchange.

[0106] In some embodiments, the on-chain resources are resources that are released by a resource publisher and uploaded to a node in the blockchain system, where the resource publisher corresponds to the first account.

[0107] Indicatively, in the process of the first account casting resources, the resources will be stored in the nodes in the blockchain system. The resources after multiple nodes reach consensus are the on-chain resources, so that the blockchain system obtains at least one on-chain resource.

[0108] In an optional embodiment, a resource configuration parameter sent by the first account is received.

[0109] The resource configuration parameters are used to generate at least one on-chain resource on the blockchain. Schematically, the first account is used to represent the object for making on-chain resources, and the resource configuration parameters are the parameter content required to synthesize on-chain resources. The first account generates on-chain resources on the blockchain system by sending the resource configuration parameters to the blockchain system.

[0110] Indicatively, the process of generating on-chain resources through resource configuration parameters is called the "casting" process. "Casting" can also be called the process of writing digital items (such as images, audio, video, text, etc.) into the blockchain system. Optionally, Ethereum smart contracts (Ethereum Request for Comment, ERC20), ERC721, ERC1155 and other smart contracts are used as standard requirements to be followed in the resource casting process. By setting various resource configuration parameters such as name, address, file parameters, etc., the purpose of casting to obtain on-chain resources is achieved.

[0111] Schematically, the on-chain resources are implemented as non-fungible Tokens (NFTs), which are non-interchangeable.

[0112] Optionally, the process of casting NFT can be realized through the open platform OpenSea. First, set up an encrypted wallet, which is regarded as the registration process of the user object on the blockchain system. It is used to save the NFT, encrypted resources, etc. of the user object when exchanging resources and casting resources in the blockchain system. In this embodiment, the wallet address corresponding to the encrypted wallet is the account address, that is, the wallet corresponds to the account;

[0113] Secondly, you can also create a collection before minting NFT to determine the collection to which the minted NFT belongs. For example: create a collection by naming and describing;

[0114] Finally, by setting various parameters such as name, address, file parameters, etc., the resources are uploaded to the blockchain system, so that the on-chain resources after consensus by each node in the blockchain system are obtained based on the resources, thus realizing the process of casting on-chain resources.

[0115] Indicatively, when the second account obtains the credential data (VC sell ), the contract address and the required amount of exchanged resources corresponding to the exchanged resource requirements of the on-chain resources are extracted from the voucher data. The specific code content is as follows:

[0116] "AssetsContractAddress": "ZZZ Addr ”;

[0117] "AssetsNumber": "200";

[0118] Among them, "AssetsContractAddress" indicates the contract address corresponding to the exchange resource requirement, "ZZZ" indicates the resource type corresponding to the exchange resource, "Addr" refers to the address, "AssetsNumber" indicates the exchange resource quantity requirement, and "200" is the specific required quantity.

[0119] That is, according to the above code content, it takes 200 ZZZ to exchange for on-chain resources. At this time, the second account will call the protocol contract to authorize the resource exchange contract to exchange the amount of resources.

[0120] Illustratively, the protocol contract is a smart contract used to transfer the exchange resources in the account (i.e., transfer the exchange resources from the second account to the first account), thereby realizing the resource exchange process. In this embodiment, the protocol contract can be implemented as an ERC20 contract.

[0121] Illustratively, a resource exchange contract is a smart contract used to schedule multiple smart contracts to complete the entire resource exchange process (i.e., transferring on-chain resources from a first account to a second account, and transferring exchanged resources from a second account to a first account). In this embodiment, the resource exchange contract can be implemented as an NFT exchange contract.

[0122] In this embodiment, the second account calls ZZZ Addr The corresponding quota authorization function in the ERC20 contract authorizes the resource quota of 200 ZZZ to the NFT exchange contract. When the authorization is completed, the NFT exchange contract can transfer the 200 ZZZ in the second account to other accounts by calling the ERC20 contract.

[0123] Among them, ERC20 contract and ZZZ Addr There is a corresponding relationship. The quota authorization function is used to execute the quota process, for example: the approve function, through which the control of 200 ZZZ is transferred from the second account to the NFT exchange contract, and the NFT exchange contract implements the resource exchange process.

[0124] Step 4102, obtaining the candidate resource state identifier and candidate credential identifier corresponding to the on-chain resource based on the credential data.

[0125] Indicatively, after the second account authorizes the exchange resource corresponding to the on-chain resource to the resource exchange contract, the second account uses the voucher data to initiate an exchange request to the resource exchange contract and sends the voucher data to the resource exchange contract.

[0126] When the resource exchange contract receives the voucher data, it analyzes the code content of the voucher data and extracts the candidate resource state representation and candidate voucher identifier corresponding to the on-chain resource.

[0127] Illustratively, the candidate resource state representation and the candidate credential identification refer to the code analysis results obtained by performing code content analysis on the credential data after receiving it through the resource exchange contract.

[0128] In this embodiment, when the NFT exchange contract receives the voucher data, it performs code content analysis on it to obtain the candidate resource identifier corresponding to the voucher data, the candidate contract address corresponding to the on-chain resource, and the candidate voucher identifier. The code analysis results are as follows:

[0129] "tokenId": "tokenId";

[0130] "NFTContractAddress": "NFT Addr ”;

[0131] "id": "id";

[0132] Among them, tokenId represents the resource identifier, tokenId represents the candidate resource identifier obtained by analyzing the NFT exchange contract, NFTContractAddress represents the contract address corresponding to the on-chain resource, and NFT Addr Indicates the candidate contract address corresponding to the on-chain resource, and id is the certificate identifier.

[0133] Schematically, while a node in the blockchain system generates at least one on-chain resource based on resource configuration parameters, a corresponding resource identifier is generated for each on-chain resource, and the resource identifier is used to uniquely represent the on-chain resource.

[0134] For example: the on-chain resource obtained by casting is NFT, and multiple NFTs are generated based on different resource configuration parameters. A resource identifier is generated for each NFT, which is represented by tokenId, which can also be called the resource serial number.

[0135] In some embodiments, based on the resource issuer and at least one on-chain resource, a resource identifier corresponding to each of the at least one on-chain resource is generated.

[0136] In an illustrative manner, after generating at least one on-chain resource, the object that casts the on-chain resource is determined, that is, the resource publisher (first account) is determined, an association relationship is established between the resource publisher and at least one on-chain resource, and a resource identifier corresponding to at least one on-chain resource is generated. The resource identifier can not only represent the on-chain resource, but also represent the resource publisher that casts the on-chain resource.

[0137] Optionally, in the blockchain system, the resource publisher corresponds to a first account address, the on-chain resources minted by the resource publisher are stored in the first account address, and each on-chain resource corresponds to a resource identifier.

[0138] In this embodiment, the form of the contract address corresponding to the on-chain resource + the resource identifier is used as the resource status identifier. Therefore, the form of the candidate contract address corresponding to the on-chain resource + the candidate resource identifier is used as the candidate resource status identifier.

[0139] Step 4103, calling the voucher contract through the candidate resource state identifier to obtain the resource data set stored in the voucher contract.

[0140] Among them, the voucher contract is a smart contract used to store resource data sets, and the reference data set includes a reference voucher identifier.

[0141] Indicatively, in addition to storing a resource data set, the voucher contract also stores the exchange status corresponding to the voucher data.

[0142] Optionally, the exchange status includes two status conditions: a to-be-exchanged status (sell) and an unexchanged status (unsell).

[0143] In this embodiment, the second account calls the voucher contract through the candidate resource status identifier to determine the exchange status corresponding to the on-chain resource, and when the exchange status is exchangeable, obtains the parameter data set stored in the exchange contract. Among them, the reference data set includes the reference voucher identifier.

[0144] Illustratively, the resource data set is a resource data set constructed by the first account based on on-chain resources.

[0145] In addition, when the exchange status is unconvertible, the exchange process ends.

[0146] Step 411, in response to a successful match between the candidate credential identifier and the credential identifier in the resource data set, the candidate resource state identifier and the candidate credential identifier are used as the resource data set.

[0147] Indicatively, after the credential identifier is obtained through the credential contract, the credential identifier is matched with the candidate credential identifier. If the credential identifier is equal to the candidate credential identifier, it indicates that the current credential data is in a valid state.

[0148] In this embodiment, if the credential data is matched and found to be in a valid state, the credential data is verified to obtain a data verification result. The data verification process will be described in detail in the subsequent embodiments.

[0149] When the data verification result meets the preset verification requirements, the candidate resource state identifier and the candidate credential identifier are used as the resource data set corresponding to the on-chain resource, that is, the resource state identifier and the credential identifier.

[0150] In this embodiment, after the resource exchange contract determines the resource data set, it determines the account address of the second account by specifying a global variable, and calls the quota query function corresponding to the protocol contract, so as to obtain the quota of the exchanged resources authorized by the second account to the resource exchange contract according to the quota query function to determine whether it meets the quantity requirements of the exchanged resources.

[0151] The global variable is specified as msg.sender, and the quota query function is used to allow any user object to query the resource quota from one address to another address, where the address can be implemented as either an account address or a contract address. In this embodiment, the quota query function is implemented as an allowance function.

[0152] Step 421, when the exchange status meets the exchange requirements, call the first exchange function corresponding to the resource contract, and call the second exchange function corresponding to the protocol contract.

[0153] Among them, the resource contract is a smart contract used to transfer on-chain resources, and the protocol contract refers to a smart contract for transferring and exchanging resources.

[0154] Indicatively, after all the above processes are completed, the exchange status of the on-chain resources is deemed to meet the exchange requirements. Therefore, the first exchange function corresponding to the resource contract is called through the resource exchange contract, and the second exchange function corresponding to the protocol contract is called.

[0155] Among them, the resource contract refers to a smart contract used to transfer on-chain resources from the first account to the second account.

[0156] In this embodiment, the resource contract is implemented as an NFT contract, and the NFT contract is a contract address of ZZZ Addr That is, when the on-chain resources are different, the corresponding on-chain resource contract address is also different, so the NFT contract called during the redemption process is also different.

[0157] In this embodiment, the protocol contract is implemented as an ERC20 contract, and the ERC20 contract is also ZZZ with a contract address of Addr agreement contract.

[0158] Illustratively, a redemption function is a function used to perform a resource transfer process.

[0159] Optionally, the first conversion function and the second conversion function are the same or different, which is not limited. In this embodiment, the first conversion function and the second conversion function belong to the same conversion function.

[0160] Step 422: Transferring the on-chain resources from the first account to the second account based on the first exchange function and the voucher data.

[0161] In this embodiment, the NFT exchange contract calls the transferFrom function of the NFT contract, and uses from as the first account address (Addr C ), to is the second account address (Addr A ), tokenId is tokenId, and the on-chain resources corresponding to the tokenId held by the first account are transferred from the first account address to the second account address.

[0162] Step 423: Transfer the redemption resource to the first account based on the second redemption function and the voucher data.

[0163] In this embodiment, the NFT exchange contract calls the transferFrom function of the ERC20 contract, and uses from as the second account address (Addr A ), to is the second account address (Addr C ), value is 200ZZZ, and the 200ZZZ authorized by the second account to the NFT redemption contract is transferred from the second account address to the first account address.

[0164] Step 431, obtaining a specified reset identifier.

[0165] Indicatively, a space character is pre-set as the designated reset identifier.

[0166] In another optional case, the designated reset identifier may also be implemented as other types of identifiers, which is not limited in the embodiments of the present application.

[0167] Step 432: Adjust the resource status identifier in the resource data set to a specified reset identifier as the reset status identifier.

[0168] In this embodiment, the voucher contract is called through the NFT exchange contract, and the resource status identifier in the resource data set is set to a space character to obtain a reset status identifier.

[0169] Optionally, the on-chain resource contract address in the resource status identifier is set to a space character to obtain a reset status identifier; or, the resource identifier in the resource status identifier is set to a space character to obtain a reset status identifier; or, both the on-chain resource contract address and the resource identifier in the resource status identifier are set to a space character to obtain a reset status identifier.

[0170] Step 433: Store the credential identifier and the reset status identifier in a key-value pair storage format.

[0171] In some embodiments, the credential identifier is used as a keyword and the reset status identifier is used as a value to store a key-value pair corresponding to the updated resource data set; the key-value pair storage result is stored on the chain in the blockchain system; or, the credential identifier is used as a keyword and the reset status identifier is used as a value to store a key-value pair corresponding to the updated resource data set; the key-value pair storage result is stored locally.

[0172] Indicatively, after obtaining the reset state identifier, the reset state identifier and the credential identifier are used as the updated resource data set (Map done ) for storage.

[0173] In this embodiment, the reset state identifier and the credential identifier are stored in a key-value pair storage format, and the code content is as follows:

[0174] Map done :VC sell ID=>NFT Addr +tokenId

[0175] Among them, VC sell The id represents the certificate identifier, NFT Addr +tokenId represents the reset status identifier, and the credential identifier is the key and the reset status identifier is the value.

[0176] Optionally, after obtaining the updated resource data set, it can be stored on-chain in the blockchain system, or it can be stored in a designated storage module to achieve off-chain storage, wherein the designated storage module is a server module unrelated to the blockchain system, that is, local storage.

[0177] In this embodiment, when the first account wants to prove that it has ever owned a certain NFT or exchanged a certain NFT, it can use the voucher data it has issued to obtain the voucher identifier corresponding to the voucher data, call the voucher contract, and obtain the voucher from the Map. done Get the reset status mark corresponding to the credential identifier, and then compare the reset status mark with the resource status mark in the issued credential data. If they are consistent, it means that the first account once owned a certain NFT and has redeemed the NFT. There is no need to traverse all transactions of NFT transactions on the chain, as well as the internal transaction details of each transaction, to complete the proof. At the same time, the blockchain platform or the second account can store the credential data on the chain to quickly obtain the circulation record of the NFT.

[0178] In summary, the blockchain-based resource exchange method provided in the embodiment of the present application, after obtaining a resource data set including a resource status identifier and a voucher identifier, when the exchange status corresponding to the resource status identifier meets the exchange requirements, the on-chain resources are exchanged between the first account and the second account according to the voucher data corresponding to the voucher identifier, and after the exchange is successful, the resource status identifier is reset, and the updated resource data set is stored. That is, when the resource exchange is completed, after the resource status identifier representing the exchange status of the on-chain resource is reset, the resource data set containing the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records.

[0179] In this embodiment, when the on-chain resource exchange is successful, the resource status identifier is adjusted to a pre-acquired specified reset identifier, so that the credential identifier and the reset status identifier are stored in a key-value pair storage format. When subsequent accounts query the exchange records and on-chain resources, the reset status identifier can be determined through the credential identifier, thereby directly obtaining the historical exchange records of the on-chain resources, thereby improving the query efficiency of the exchange records.

[0180] In this embodiment, the storage result is stored on-chain or off-chain using the credential identifier as the keyword and the reset status identifier as the value as the key-value pair, which enables the account to query the historical exchange records corresponding to the on-chain resources both on-chain and off-chain, expanding the query scenarios of exchange records.

[0181] In this embodiment, by calling the first exchange function corresponding to the resource contract and calling the second exchange function corresponding to the protocol contract, the on-chain resources are transferred from the first account to the second account, and the exchange resources are transferred from the second account to the first account, thereby improving the accuracy of data circulation of resource exchange.

[0182] In this embodiment, after obtaining the credential data through the resource exchange contract, the candidate resource status identifier and the candidate credential identifier are obtained based on the credential data, so that the validity of the credential data is determined based on the comparison result between the candidate credential identifier and the credential identifier in the resource data set, thereby improving data security and data validity.

[0183] In some embodiments, the process of generating the credential data is described in detail. For illustration, please refer to Figure 6 , which shows a flowchart of a resource exchange method based on blockchain provided by an exemplary embodiment of the present application, and takes the method executed by a node in a blockchain system as an example for explanation, such as Figure 6 As shown, the method includes the following steps.

[0184] Step 610: Obtain a first private key and a first account address corresponding to the first account.

[0185] Illustratively, when registering and creating an account in a blockchain system, the blockchain system provides the account with a private key corresponding to the account, a public key corresponding to the private key, and an account address.

[0186] Among them, the private key and the public key are a pair of key pairs generated by mathematical algorithms, which are unique and symmetric for the account. The public key is public and can be viewed and used by any account, while the private key is confidential and can only be mastered and controlled by the account that owns the private key.

[0187] Schematically, the private keys and public keys of different accounts are different.

[0188] Schematically, the account signs and verifies the resource exchange process through the private key, while the public key can be used to verify the identity information corresponding to the account.

[0189] In this embodiment, the account address is also called the wallet address.

[0190] In this embodiment, the first private key PriKey provided by the first account is obtained. C 、First public key PubKey C and the first account address Addr C , and obtain the second private key PriKey provided by the second account A 、Second public key PubKey A And the second account address Addr A .

[0191] Step 620: Generate a first account document corresponding to the first account based on the first private key and the first account address.

[0192] The first account document includes account information corresponding to the first account, an account identity identifier corresponding to the first account document, and a first public key corresponding to the first private key.

[0193] Illustratively, after receiving the first private key provided by the first account, the identity contract is called to register the corresponding first identity identifier for the first account, and a first account document corresponding to the first identity identifier is generated.

[0194] Illustratively, after receiving the second private key provided by the second account, the identity contract is called to register the corresponding second identity identifier for the second account, and a second account document corresponding to the second identity identifier is generated.

[0195] Among them, the identity contract is a smart contract in the blockchain system used to create identity identification and verify credential data.

[0196] In schematic form, an account identity is an identifier corresponding to the account identity in the blockchain system and is unique to the account. Different accounts correspond to different account identities.

[0197] In a schematic manner, each account identity identifier corresponds to an account document, wherein the account document is used to ensure the specific account information corresponding to the account identity. That is, the account identity identifier is only used to indicate a certain account. By determining the account identity identifier, multiple account information corresponding to the account can be obtained according to the account document corresponding to the account identity identifier.

[0198] In this embodiment, taking the identity contract as a decentralized identity contract (DID contract) as an example, the first account identity identifier corresponding to the first account is the first decentralized identity identifier (DID C ), the second account ID corresponding to the second account number is the second decentralized ID (DID A ).

[0199] Taking the first account as an example, after the first account identity is registered, the DID contract receives the first private key and the first account address corresponding to the first account, and calculates the first account document (DID document) corresponding to the first account based on the first private key and the first account address. The code content is as follows:

[0200]

[0201]

[0202] Wherein, publicKey represents the first public key, which is derived from the first private key, and id represents the first account identity identifier, wherein the calculation method of the account identity identifier is shown in the following formula 1.

[0203] Formula 1: DID identification: id = DID prefix + keccak256 (publicKey) [12:]

[0204] Among them, the DID identifier includes the address corresponding to the user object in the blockchain system on the chain, and the user object includes the user or a designated organization.

[0205] Taking the use object as the first account as an example, after the first account derives the corresponding first public key through the first private key, the first public key is hashed using a specified hash function (for example: keccak256) to obtain a 32-byte string, and the last 20 bytes of the 32 bytes are taken as the address part of the DID identifier, which corresponds to the first account address. The prefix did:tdid:f34 in the DID identifier is used to indicate which blockchain the DID identifier is registered on, for example: f34 represents the chain identifier corresponding to the Ethereum chain. Optionally, the blockchain also includes Stellar chain, Tron chain, Cosmos chain, etc.

[0206] In addition, the DID document (json format) also has a controller field, which is used to indicate the controller of the DID document. The controller of the DID document corresponding to the first account is the first account, that is, this field is the same as the id field.

[0207] At this point, the first account and the second account both have a user address, namely, Addr C andAddr A , and DID C and DID A , and Addr C and DID C Have a corresponding relationship, Addr A and DID A There is a corresponding relationship, and the first account and the second account each correspond to a DID document.

[0208] Step 630, obtain various exchange condition parameters corresponding to the on-chain resources.

[0209] Among them, the exchange condition parameter is used to indicate the exchange requirements corresponding to the on-chain resources.

[0210] Indicatively, the multiple exchange condition parameters are exchange requirements set by the first account based on the on-chain resources, including the contract address corresponding to the on-chain resources, the exchange resource requirements required to exchange the on-chain resources (including at least one of the exchange resource type requirements and the exchange resource quantity requirements), the contract address corresponding to the exchange resource requirements, the exchange start time, the exchange end time, the amount of exchangeable on-chain resources, the exchange status, the resource identifier, the signature, the credential identifier, the account identity identifier corresponding to the account document, and at least one of the multiple parameters.

[0211] Step 640, generate voucher data based on multiple redemption condition parameters.

[0212] Indicatively, after obtaining a variety of exchange condition parameters, code is written according to the various exchange condition parameters, thereby ultimately obtaining the voucher data corresponding to the on-chain resources.

[0213] In some embodiments, first candidate credential data is generated based on multiple redemption condition parameters; a hash operation is performed on the first candidate credential data to obtain a first hash operation result; the first hash operation result is encrypted using a first private key to obtain a signature result; the signature result is added to the signature field in the first candidate credential data to obtain second candidate credential data; a hash operation is performed on the second candidate credential data to obtain a credential identifier; the credential identifier is added to the identifier field in the second candidate credential data to obtain credential data.

[0214] Indicatively, based on the above-mentioned multiple exchange condition parameters, the first candidate voucher data is constructed and generated.

[0215]

[0216] Among them, tokenId represents the resource identifier, NFTContractAddress represents the contract address corresponding to the on-chain resource, issuer represents the issuing object (i.e., the first account identity identifier), status represents the redemption status (sell represents the redeemable status, and unsell represents the unredeemable status), AssetsContractAddress represents the contract address corresponding to the redemption resource requirements, AssetsNumber represents the redemption quantity requirement, timestamp represents the redemption deadline, signature represents the signature (the space character in the quotation marks indicates that the signature field in the current first candidate credential data has not generated the corresponding code content), and id represents the credential identifier (the space character in the quotation marks indicates that the id field in the current first candidate credential data is for generating the corresponding code content).

[0217] In this embodiment, after obtaining the first candidate credential data, a hash operation is performed on the first candidate credential data to obtain a first hash operation result, and the first hash operation result is asymmetrically encrypted using the first private key to generate a signature result (Sig) corresponding to the first hash operation result, and the signature result is added to the signature field in the first candidate credential data to obtain the second candidate credential data (VC) with the signature added. middle ). Then, a hash operation is performed on the second candidate credential data to obtain a credential identifier, and the credential identifier is added to the identifier (Id) field in the second candidate credential, thereby finally obtaining credential data (VC) with the credential identifier added. sell ).

[0218] Alternatively, hash operations can also be called hash algorithms. Common hash operations include Message Digest (MD), Secure Hash Algorithm (SHA), and other algorithms. The MD algorithm family includes MD2, MD4, and MD5, which are updated versions of the MD algorithm. The message digests they generate are all 128 bits, usually represented as 32 characters in hexadecimal. The SHA algorithm family includes SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512. SHA-224, SHA-256, SHA-384, and SHA-512 are sometimes collectively referred to as SHA-2. SHA-1 can convert a maximum of 2 64 The data is converted into a 160-bit data digest. The digest length generated by SHA-2 is the number after their name. For example, the digest length generated by the SHA-256 algorithm is 256 bits, so its brute-force resistance is better than that of the MD algorithm.

[0219] Step 650, store the credential data into the credential contract.

[0220] In some embodiments, the credential data is verified based on the first account document to obtain a data verification result; in response to the data verification result meeting the preset verification requirements, the credential data and the credential identifier are stored in the credential contract.

[0221] Indicatively, data verification is used to verify the data accuracy corresponding to the received voucher data through the voucher contract to see whether it is correct voucher data.

[0222] When the data verification result meets the preset verification requirements, the voucher data verification is considered to have passed, and the voucher data and voucher identifier are stored in the voucher contract.

[0223] In this embodiment, taking the first account as an example, the first account calls the voucher contract and stores the voucher data in the voucher contract.

[0224] Among them, when the voucher contract receives the voucher data, it will also verify the voucher contract data through the first account document. The specific data verification process is as follows:

[0225] (1) Based on DID C Take the address part Addr from the corresponding first account document C , call the NFT contract to check whether the holder of the NFT corresponding to tokenId is equal to Addr C ;

[0226] (2) The Status field is sell or unsell;

[0227] (3) Whether the deadline timestamp is greater than or equal to the current block time;

[0228] (4)Use DID C , call the DID contract and view the DID C Whether it exists in the DID contract;

[0229] (5) Check if ZZZ exists on the chain Addr The corresponding exchange resources ensure that such exchange resources can be used to exchange for NFTs;

[0230] (6) Call the DID contract to obtain the DID from the first account document C The corresponding first public key PubKey C ;

[0231] (7) Verify that the signature is correct: Verufy (VC sell ,PubKey C );

[0232] The verification process is as follows: first, the id field in the credential data is set to blank to obtain the second candidate credential data, and then use PubKey C The second candidate credential data is decrypted to obtain the first operation result H1. Then, the signature field in the second credential data is set to blank to obtain the first candidate credential data. The first candidate credential data is hashed to obtain the second operation result H2. If H1=H2, the credential data verification is successful.

[0233] In this embodiment, after completing the above verification, the voucher contract will store VC sell The information in the certificate contract has two Map structuresMap NFR and Map VC , as shown below. If Status = sell, the information is stored as follows:

[0234] Map NFT :NFT Addr +tokenId=>VC sell id

[0235] Map VC :VC sell ID=>VC sell

[0236] When Status = unsell, it means the user does not want to sell and wants to remove the NFT. Addr +The value corresponding to tokenId is set to empty.

[0237] Among them, Map is a collection that maps key objects and value objects. Each of its elements contains a pair of key objects and value objects, that is, it is stored in a key-value pair storage format.

[0238] That is, the multiple exchange condition parameters include the exchange status parameters of the on-chain resources; the resource status identifier and the certificate identifier are stored in the certificate contract as a resource data set in a key-value pair storage format.

[0239] In this embodiment, when the second account wants to view the contract address NFT Addr To check whether the NFT corresponding to the tokenId is redeemable, you can call the voucher contract to query the NFT. Addr +Whether the value corresponding to tokenId is empty. If it is empty, it means that the NFT has been exchanged by the first account. If it is not empty, the voucher data corresponding to the NFT can be obtained, that is, VC sell .

[0240] In summary, the blockchain-based resource exchange method provided in the embodiment of the present application, after obtaining a resource data set including a resource status identifier and a voucher identifier, when the exchange status corresponding to the resource status identifier meets the exchange requirements, the on-chain resources are exchanged between the first account and the second account according to the voucher data corresponding to the voucher identifier, and after the exchange is successful, the resource status identifier is reset, and the updated resource data set is stored. That is, when the resource exchange is completed, after the resource status identifier representing the exchange status of the on-chain resource is reset, the resource data set containing the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records.

[0241] In this embodiment, by generating voucher data according to a variety of exchange condition parameters, the voucher data can include a variety of exchange requirements corresponding to the on-chain resources, thereby enriching the data content.

[0242] In this embodiment, by generating a first account document corresponding to the first account, and using the first account document and a variety of redemption condition parameters to generate voucher data, account information and voucher data can be stored in a decentralized manner.

[0243] In this embodiment, the first account document is used to verify the credential data, thereby ensuring data security.

[0244] Take the block-based resource exchange method applied to the NFT resource exchange scenario as an example. For illustration, please refer to Figure 7, which shows a schematic diagram of a resource exchange method based on blocks provided by an exemplary embodiment of the present application, such as Figure 7 As shown, the method includes the following contents.

[0245] Part 1: Credential storage process based on DID and credential data (VC)

[0246] The whole process includes the following modules:

[0247] First account 710: The blockchain account that wants to redeem NFT. The first account includes the first private key PriKey C 、First public key PubKey C 、First wallet addressAddr C ;

[0248] Second account 720: The blockchain account to be redeemed for the NFT. The second account includes the second private key PriKey A 、Second public key PubKey A 、Second wallet addressAddr A ;

[0249] Credential contract 730: used to store credential data and credential status issued by the first account;

[0250] NFT Contract 740: ERC721 contract for issuing and transferring NFTs;

[0251] DID contract 750: creates an account DID identifier and verifies the identity contract of the VC;

[0252] (1) Register DID

[0253] The first account and the second account each provide a private key PriKey C , PriKey A , and call DID contract 750 to register a DID identifier and a corresponding DID document respectively. When the DID contract receives the private key PriKey C and PriKey A After that, the DID document corresponding to the first account and the DID document corresponding to the second account will be calculated.

[0254] (2) The first account issues the certificate VC

[0255] The first account obtains the contract address NFT that you want to redeem Addr and tokenId (e.g. 1000), and specify the amount of resources to be exchanged (e.g. 200ZZZ, whose contract address is ZZZ Addr ) and the deadline timestamp, construct the VC original VCOrigin , then, the first account to VC Origin Perform a hash operation and then use the private key PriKey C Asymmetric encryption is performed on it, that is, signature Sig, and the generated signature is added to VC json The signature field in VC middle , then VC middle Perform hash operation to obtain the unique ID of VC and add it to VC middle id field, and then get the final voucher VC, that is, VC sell .

[0256] (3) User C uploads the certificate VC to the chain

[0257] The first account calls the voucher contract and sets VC sell Stored in the voucher contract, the voucher contract receives VC sell The following checks are performed:

[0258] 1. From DID C Take out the address part Addr C , call the NFT contract to check whether the holder of the NFT corresponding to tokenId is equal to Addr C ;

[0259] 2. The Status field is sell or unsell;

[0260] 3. Whether the deadline timestamp is greater than or equal to the current block time;

[0261] 4. Utilize DID C , call the DID contract and view the DID C exists;

[0262] 5. Check if ZZZ exists on the chain Addr The corresponding exchange resources ensure that such exchange resources can be used to meet the resource exchange quantity requirements of NFT;

[0263] 6. Call the DID contract to obtain the DID C The public key PubKey C ;

[0264] 7. Verify the signature is correct: Verify(VC sell ,PubKey C ).

[0265] The verification process is roughly as follows: First, VC sell Leave the id field blank to get VC middle Then use PubKeyC For VC middle Decryption results in a value H1, and then VC middle The signature field is left blank to get VC Origin , for VC origin Perform hash value operation to obtain H2. If H1=H2, VC verification is successful.

[0266] After completing the above verification, the voucher contract will store VC sell Information, the certificate contract has two map structuresMap NFT and Map VC , respectively as shown below. If Status = sell, the information is stored as follows:

[0267] Map NFT :NFT Addr +tokenId=>VC sell id

[0268] Map VC :VC sell ID=>VC sell

[0269] When Status = unsell, it means that the first account does not want to exchange and wants to delist, then the NFT Addr +The value corresponding to tokenId is set to empty.

[0270] Note that no matter whether the first account wants to list or unlist NFT, it needs to issue a certificate VC and put it on the chain. The difference is that when unlisting NFT, that is, Status = unsell, the NFT Addr +The value corresponding to tokenId is set to empty.

[0271] The second account wants to view the contract address NFT Addr To check whether the NFT corresponding to the tokenId is in the sale state, you can call the voucher contract to query the NFT Addr +Whether the value corresponding to tokenId is empty. If it is empty, it means that the NFT has been successfully exchanged by the upstream company. If it is not empty, the certificate VC can be obtained, that is, VC sell , which can be used in the second part to complete the resource exchange of NFT.

[0272] The second account can call the voucher contract and traverse the Map CC , you can get which NFTs in which NFT contracts are on sale.

[0273] At this point, the first account has completed an NFT order operation by issuing VC, and stored the voucher VC in the voucher contract on the chain, completing the decentralized storage of the voucher VC; anyone can obtain the latest order information of the first account through the voucher contract, avoiding the platform from monopolizing the user's order information, causing the user to be unable to complete the redemption of NFTs normally.

[0274] Part 2: Resource exchange process based on DID and credential data (VC)

[0275] First account 710: The blockchain account that sells the NFT. The first account includes the first private key PriKey C 、First public key PubKey C 、First wallet addressAddr C ;

[0276] Second account 720: The blockchain account to be redeemed for NFT. The second account includes the second private key PriKey A 、Second public key PubKey A 、Second wallet addressAddr A ;

[0277] Credential contract 730: used to store credential data and credential status issued by the first account;

[0278] NFT Contract 740: ERC721 contract for issuing and transferring NFTs;

[0279] DID contract 750: creates an account DID identifier and verifies the identity contract of the VC;

[0280] ERC20 contract 760: standard asset contract, responsible for the transfer of exchange resources to complete NFT exchange;

[0281] NFT Exchange Contract 770: used to schedule multiple smart contracts to complete NFT transactions.

[0282] (1) Use the VC to authorize the NFT exchange contract

[0283] The second account can get the VC of the first account, that is, VC sell , then it is learned that 200ZZZ is needed to redeem the NFT, then the ERC20 contract will be called, that is, ZZZ Addr The approve function of the corresponding contract authorizes 200 zzz to the NFT exchange contract. After the authorization is completed, the NFT exchange contract will be able to transfer 200 ZZZ from the second account to anyone by calling the ERC20 contract.

[0284] (2) Use the VC voucher to initiate resource exchange to the NFT exchange contract

[0285] The second account uses VC sell Initiate a transaction to the NFT exchange contract, and the exchange contract receives VC Sell When using NFT Addr +tokenId calls the voucher contract, obtains the voucher status, and obtains the voucher status from Map NFT Get the id of the VC corresponding to the current voucher, and sell The id is compared, and if they are equal, it means that VC sell is effective. After that, VC sell Verification is performed. The verification content is similar to step 3) in part (I). If the verification fails, the current transaction fails. Finally, the exchange contract obtains the initiator address of the current transaction through msg.sender, that is, the address Addr of the second account. A , and call USDC Addr The contract's allowance() function obtains whether the amount authorized by the second account to the current exchange contract is greater than 200ZZZ. If the verification fails, the current transaction fails.

[0286] (3) Call the NFT contract to complete the NFT transfer

[0287] The NFT exchange contract calls the contract address as NFT Addr The transferFrom function of the NFT contract, with from as Addr C ,to is Addr A , tokenId is tokenId, and the NFT of tokenId held by the first account is transferred to the address of the second account.

[0288] (4) Call the ERC contract corresponding to ZZZ to complete the asset transfer

[0289] The NFT exchange contract calls the contract address as USDC Addr The transferFrom function of the ERC20 contract, with from = Addr A ,to is Addr C , value is 200ZZZ, move the 200ZZZ authorized by the second account to the address Addr of the second account C C .

[0290] (5) Reset credential status

[0291] The NFT exchange contract calls the voucher contract and maps NFT The key is NFT Addr +tokenId value is set to empty. And VC sell The id is stored in Mapdone middle:

[0292] Map done :VC sell ID=>NFT Addr +tokenId

[0293] At this point, a NFT transaction from the first account to the second account is completed, transferring the NFT to the second account and the ZZZ asset to the first account.

[0294] When the first account wants to prove that it has ever owned a certain NFT or exchanged a certain NFT, it can use the VC it ​​has issued. sell , take out the id, call the voucher contract, and get the id from Map done Get the NFT corresponding to the id Addr +tokenId, then NFT Addr and tokenId and VC sell If they are the same, it means that the first account has owned a certain NFT and has successfully exchanged it. There is no need to traverse all the exchange records on the NFT exchange contract on the chain, as well as the internal exchange details of each exchange record, to complete the proof. At the same time, the platform or user can store VC on the chain to quickly obtain the circulation record of NFT.

[0295] In summary, the blockchain-based resource exchange method provided in the embodiment of the present application, after obtaining a resource data set including a resource status identifier and a voucher identifier, when the exchange status corresponding to the resource status identifier meets the exchange requirements, the on-chain resources are exchanged between the first account and the second account according to the voucher data corresponding to the voucher identifier, and after the exchange is successful, the resource status identifier is reset, and the updated resource data set is stored. That is, when the resource exchange is completed, after the resource status identifier representing the exchange status of the on-chain resource is reset, the resource data set containing the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records.

[0296] The beneficial effects achieved by this application scheme are:

[0297] 1. This application proposes an NFT decentralized order storage technology based on DID and VC. By issuing VC, an NFT order operation is completed, and the voucher VC is stored in the voucher contract on the chain, completing the decentralized storage of the voucher VC; anyone can obtain the latest order information of the first account through the voucher contract, avoiding the platform from doing evil and monopolizing the user's order information, which makes it impossible for the user to normally complete the redemption of NFT.

[0298] 2. This application proposes an NFT transaction circulation technology based on DID and VC, which completes an NFT transaction based on the issuance of VC, so that each NFT transaction on the chain is indirectly stored off-chain with VC, which can be used directly to prove that a user once owned an NFT or redeemed an NFT. This helps users or platforms to quickly build an NFT transaction record and circulation details by storing VC on the chain.

[0299] Figure 8 is a structural block diagram of a resource exchange device based on blockchain provided by an exemplary embodiment of the present application, such as Fig.10 As shown, the device includes the following parts:

[0300] The acquisition module 810 is used to acquire a resource data set corresponding to an on-chain resource, wherein the resource data set includes a resource status identifier and a credential identifier, wherein the credential identifier corresponds to credential data, wherein the on-chain resource is a resource deployed in the blockchain system by a first account, wherein the credential data is used to indicate an exchange requirement corresponding to the on-chain resource, and wherein the resource status identifier is used to indicate an exchange status of the on-chain resource;

[0301] A transfer module 820, configured to transfer the on-chain resource from the first account to the second account based on the voucher data when the exchange status meets the exchange requirements, and transfer the exchange resource corresponding to the on-chain resource in the second account to the first account;

[0302] The storage module 830 is used to reset the resource status identifier in the resource data set in response to the successful exchange of the on-chain resources, and store the updated resource data set, wherein the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to the historical exchange record that has been exchanged.

[0303] In some embodiments, Fig. 9 As shown, the storage module 830 includes:

[0304] An acquisition unit 831 is used to acquire a specified reset identifier;

[0305] An adjusting unit 832, configured to adjust the resource state identifier in the resource data set to the specified reset identifier as the reset state identifier;

[0306] The storage unit 833 is used to store the credential identifier and the reset status identifier in a key-value pair storage format.

[0307] In some embodiments, the storage unit 833 is used to use the credential identifier as a keyword and the reset status identifier as a value as a key-value pair storage result corresponding to the updated resource data set; store the key-value pair storage result on-chain in the blockchain system; or, use the credential identifier as a keyword and the reset status identifier as a value as a key-value pair storage result corresponding to the updated resource data set; store the key-value pair storage result locally.

[0308] In some embodiments, the transfer module 820 is used to call a first exchange function corresponding to a resource contract and a second exchange function corresponding to a protocol contract when the exchange status meets the exchange requirements. The resource contract is a smart contract used to transfer the on-chain resources, and the protocol contract refers to a smart contract for transferring the exchange resources; based on the first exchange function and the voucher data, the on-chain resources are transferred from the first account to the second account; based on the second exchange function and the voucher data, the exchange resources are transferred to the first account.

[0309] In some embodiments, the acquisition module 810 is also used to obtain the credential data corresponding to the on-chain resource through a resource exchange contract, which is a smart contract used to coordinate the on-chain resources for resource exchange; based on the credential data, obtain the candidate resource state identifier and candidate credential identifier corresponding to the on-chain resource; call the credential contract through the candidate resource state identifier to obtain the resource data set stored in the credential contract, which is a smart contract used to store the resource data set; in response to the candidate credential identifier successfully matching the credential identifier in the resource data set, use the candidate resource state identifier and the candidate credential identifier as the resource data set.

[0310] In some embodiments, the acquisition module 810 is also used to obtain a first private key and a first account address corresponding to the first account; generate a first account document corresponding to the first account based on the first private key and the first account address, the first account document including the account information corresponding to the first account, the account identity corresponding to the first account, and the first public key corresponding to the first private key; obtain a plurality of exchange condition parameters corresponding to the on-chain resources, the plurality of exchange condition parameters are used to indicate the exchange requirements corresponding to the on-chain resources; generate the voucher data based on the plurality of exchange condition parameters; and store the voucher data in the voucher contract.

[0311] In some embodiments, the acquisition module 810 is also used to generate a first candidate credential data based on the multiple redemption condition parameters; perform a hash operation on the first candidate credential data to obtain a first hash operation result; perform an encryption operation on the first hash operation result using the first private key to obtain a signature result; add the signature result to the signature field in the first candidate credential data to obtain a second candidate credential data; perform a hash operation on the second candidate credential data to obtain the credential identifier; add the credential identifier to the identifier field in the second candidate credential data to obtain the credential data.

[0312] In some embodiments, the acquisition module 810 is also used to call the voucher contract to perform data verification on the voucher data to obtain a data verification result; in response to the data verification result meeting a preset verification requirement, the voucher data and the voucher identifier are stored in the voucher contract.

[0313] In some embodiments, the multiple exchange condition parameters include exchange status parameters of the on-chain resources;

[0314] The storage module 830 is further used to obtain the resource state identifier based on the redemption state parameter; and store the resource state identifier and the credential identifier in a key-value pair storage format as the resource data set in the credential contract.

[0315] In summary, the blockchain-based resource exchange device provided in the embodiment of the present application, after obtaining a resource data set including a resource status identifier and a voucher identifier, exchanges on-chain resources between a first account and a second account according to the voucher data corresponding to the voucher identifier when the exchange status corresponding to the resource status identifier meets the exchange requirements, resets the resource status identifier after the exchange is successful, and stores the updated resource data set. That is, when the resource exchange is completed, after the resource status identifier representing the exchange status of the on-chain resource is reset, the resource data set including the reset resource status identifier is stored, so that subsequent accounts can directly obtain the historical exchange records corresponding to the on-chain resources through the reset resource status identifier, without having to determine the exchanged on-chain resources by analyzing the exchange content in the resource exchange process, thereby improving the query efficiency of resource exchange records.

[0316] It should be noted that the resource exchange device based on blockchain provided in the above embodiment is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the resource exchange device based on blockchain provided in the above embodiment and the resource exchange method embodiment based on blockchain belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0317] Fig.10 The schematic diagram of the structure of a server provided by an exemplary embodiment of the present application is shown. The server 1000 includes a central processing unit (CPU) 1001, a system memory 1004 including a random access memory (RAM) 1002 and a read-only memory (ROM) 1003, and a system bus 1005 connecting the system memory 1004 and the central processing unit 1001. The server 1000 also includes a large-capacity storage device 1006 for storing an operating system 1013, an application program 1014, and other program modules 1015.

[0318] The mass storage device 1006 is connected to the central processing unit 1001 through a mass storage controller (not shown) connected to the system bus 1005. The mass storage device 1006 and its associated computer readable media provide non-volatile storage for the server 1000. That is, the mass storage device 1006 may include a computer readable medium (not shown) such as a hard disk or a compact disc read only memory (CD-ROM) drive.

[0319] Without loss of generality, computer readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information such as computer readable instructions, data structures, program modules or other data. The above-mentioned system memory 1004 and mass storage device 1006 can be collectively referred to as memory.

[0320] According to various embodiments of the present application, the server 1000 can also be connected to a remote computer on the network through a network such as the Internet. That is, the server 1000 can be connected to the network 1012 through the network interface unit 1011 connected to the system bus 1005, or the network interface unit 1011 can be used to connect to other types of networks or remote computer systems (not shown).

[0321] The above-mentioned memory also includes one or more programs, and the one or more programs are stored in the memory and configured to be executed by the CPU.

[0322] An embodiment of the present application also provides a computer device, which includes a processor and a memory, wherein at least one instruction, at least one program, a code set or an instruction set is stored in the memory, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the blockchain-based resource exchange method provided by the above-mentioned method embodiments.

[0323] An embodiment of the present application also provides a computer-readable storage medium, on which is stored at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the blockchain-based resource exchange method provided in the above-mentioned method embodiments.

[0324] The embodiments of the present application also provide a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes any of the resource exchange methods based on blockchain described in the above embodiments.

[0325] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A resource exchange method based on blockchain, characterized in that: The method is executed by a node in a blockchain system, and the method includes: Obtain a resource data set corresponding to an on-chain resource, wherein the resource data set includes a resource status identifier and a credential identifier, the credential identifier corresponds to credential data, the on-chain resource is a resource deployed in the blockchain system by a first account, the credential data is used to indicate an exchange requirement corresponding to the on-chain resource, and the resource status identifier is used to indicate an exchange status of the on-chain resource; If the exchange status meets the exchange requirements, transfer the on-chain resource from the first account to the second account based on the voucher data, and transfer the exchange resource corresponding to the on-chain resource in the second account to the first account; In response to the successful exchange of the on-chain resources, the resource status identifier in the resource data set is reset, and the updated resource data set is stored, wherein the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to the historical exchange record that has been exchanged.

2. The method according to claim 1, characterized in that The resetting the resource status identifier in the resource data set and storing the updated resource data set includes: Get the specified reset identifier; Adjusting the resource status identifier in the resource data set to the specified reset identifier as the reset status identifier; The credential identifier and the reset status identifier are stored in a key-value pair storage format.

3. The method according to claim 2, characterized in that The storing of the credential identifier and the reset status identifier in a key-value pair storage format includes: Using the credential identifier as a keyword and the reset status identifier as a value as a key-value pair storage result corresponding to the updated resource data set; uploading the key-value pair storage result to the blockchain system; or, The credential identifier is used as a keyword and the reset status identifier is used as a value as a key-value pair storage result corresponding to the updated resource data set; the key-value pair storage result is stored locally.

4. The method according to any one of claims 1 to 3, characterized in that: When the exchange status meets the exchange requirements, transferring the on-chain resource from the first account to the second account based on the voucher data, and transferring the exchange resource corresponding to the on-chain resource in the second account to the first account, includes: When the exchange status meets the exchange requirements, a first exchange function corresponding to a resource contract is called, and a second exchange function corresponding to a protocol contract is called, wherein the resource contract is a smart contract for transferring the on-chain resources, and the protocol contract is a smart contract for transferring the exchange resources; Transferring the on-chain resource from the first account to the second account based on the first exchange function and the credential data; The redemption resource is transferred to the first account based on the second redemption function and the voucher data.

5. The method according to any one of claims 1 to 3, characterized in that: Before obtaining the resource data set corresponding to the on-chain resource, the method further includes: Obtaining the voucher data corresponding to the on-chain resource through a resource exchange contract, wherein the resource exchange contract is a smart contract for coordinating the on-chain resources for resource exchange; Acquire a candidate resource state identifier and a candidate credential identifier corresponding to the on-chain resource based on the credential data; Calling a voucher contract through the candidate resource state identifier to obtain the resource data set stored in the voucher contract, wherein the voucher contract is a smart contract for storing the resource data set; The step of obtaining a resource data set corresponding to the on-chain resource includes: In response to the candidate credential identifier successfully matching the credential identifier in the resource data set, the candidate resource state identifier and the candidate credential identifier are used as the resource data set.

6. The method according to claim 5, characterized in that Before obtaining the resource data set corresponding to the on-chain resource, the method further includes: Acquire multiple exchange condition parameters corresponding to the on-chain resources, where the multiple exchange condition parameters are used to indicate exchange requirements corresponding to the on-chain resources; generating the voucher data based on the plurality of redemption condition parameters; The credential data is stored in the credential contract.

7. The method according to claim 6, characterized in that Before generating the voucher data based on the multiple redemption condition parameters, the method further includes: Obtaining a first private key and a first account address corresponding to the first account; generating a first account document corresponding to the first account based on the first private key and the first account address, wherein the first account document includes account information corresponding to the first account, an account identity corresponding to the first account, and a first public key corresponding to the first private key; The generating the voucher data based on the multiple redemption condition parameters includes: generating first candidate voucher data based on the plurality of redemption condition parameters; Performing a hash operation on the first candidate credential data to obtain a first hash operation result; Performing encryption operation on the first hash operation result by using the first private key in the first account document to obtain a signature result; Adding the signature result to the signature field in the first candidate credential data to obtain second candidate credential data; Performing a hash operation on the second candidate credential data to obtain the credential identifier; The credential identifier is added to the identifier field in the second candidate credential data to obtain the credential data.

8. The method according to claim 6, characterized in that The storing the credential data in the credential contract comprises: Performing data verification on the credential data based on the first account document to obtain a data verification result; In response to the data verification result meeting the preset verification requirement, the voucher data and the voucher identifier are stored in the voucher contract.

9. The method according to claim 6, characterized in that The multiple exchange condition parameters include exchange status parameters of the on-chain resources; The method further comprises: Acquire the resource status identifier based on the exchange status parameter; The resource state identifier and the credential identifier are stored in the credential contract in a key-value pair storage format as the resource data set.

10. A resource exchange device based on blockchain, characterized in that: The device comprises: An acquisition module, used to acquire a resource data set corresponding to an on-chain resource, wherein the resource data set includes a resource status identifier and a credential identifier, wherein the credential identifier corresponds to credential data, wherein the on-chain resource is a resource deployed in the blockchain system by a first account, wherein the credential data is used to indicate an exchange requirement corresponding to the on-chain resource, and wherein the resource status identifier is used to indicate an exchange status of the on-chain resource; a transfer module, configured to transfer the on-chain resource from the first account to the second account based on the voucher data when the exchange status meets the exchange requirements, and transfer the exchange resource corresponding to the on-chain resource in the second account to the first account; A storage module is used to reset the resource status identifier in the resource data set in response to the successful exchange of the on-chain resources, and store the updated resource data set, wherein the reset resource status identifier is used to indicate that the resource data set corresponding to the on-chain resource belongs to a historical exchange record that has been exchanged.

11. A computer device, characterized in that: The computer device includes a processor and a memory, wherein at least one program is stored in the memory, and the at least one program is loaded and executed by the processor to implement the blockchain-based resource exchange method as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The storage medium stores at least one program, and the at least one program is loaded and executed by the processor to implement the blockchain-based resource exchange method as described in any one of claims 1 to 9.

13. A computer program product, characterized in that It includes computer instructions, which, when executed by a processor, implement the blockchain-based resource exchange method as described in any one of claims 1 to 9.