This application relates to the technical field of Internet, and in particular, to a blockchain-based data processing method, a device, and a computer-readable storage medium.
Characterized by decentralization and immutability, a blockchain technology can provide proof of ownership of various off-chain items (including digital items and physical items) with unique virtual resources as warrant types, and store and dispense the same in a distributed mode.
In real life, the off-chain items can be consumed. For example, game consumption resources in electronic game scenes can be integrated into equipment. If a virtual resource corresponding to the equipment (referred to as a virtual resource 1) and a virtual resource corresponding to the game consumption resources (referred to as a virtual resource 2) have been issued in a blockchain network, in order to correspond to the integration of the off-chain equipment and the game consumption resources (e.g., consumption of off-chain game consumption resources), in the related art, a virtual resource 3 will be issued in the blockchain network. The virtual resource 3 is configured for representing the warrant for the equipment in which a service attribute (derived from the consumed game consumption resource) is added, and the previously issued virtual resource 1 and virtual resource 2 are destroyed. Significantly, in the related art, for the consumed off-chain items, the blockchain will not deposit the virtual resource configured for representing the ownership of the consumed off-chain items. As a result, it may not be possible to trace the ownership of the consumed off-chain items.
Embodiments of this application provide a blockchain-based data processing method, a device, and a readable storage medium, such that ownership of consumed target items can be accurately traced.
In an aspect, an embodiment of this application provides a blockchain-based data processing method, including:
acquiring a resource consumption task, the resource consumption task including an initiating object address and a target resource identifier;
calling, according to the resource consumption task, a resource consumption function in a smart contract, and determining, based on the resource consumption function, a holding object address in the blockchain, the holding object address referring to an object address holding a target virtual resource, and the target virtual resource referring to a virtual resource represented by the target resource identifier;
consuming, according to the initiating object address and the holding object address, the target virtual resource to obtain a transaction execution result of the resource consumption task; and
broadcasting a resource consumption event corresponding to the transaction execution result to a service device corresponding to the initiating object address, so as to make the service device perform, on a target item, service processing associated with the resource consumption event, the target virtual resource being configured for representing ownership of the target item.
In an aspect, an embodiment of this application provides a blockchain-based data processing apparatus, including:
a first acquiring module, configured to acquire a resource consumption task, the resource consumption task including an initiating object address and a target resource identifier;
a function calling module, configured to call, according to the resource consumption task, a resource consumption function in a smart contract, and determine, based on the resource consumption function, a holding object address in the blockchain, the holding object address referring to an object address holding a target virtual resource, and the target virtual resource referring to a virtual resource represented by the target resource identifier;
a resource consumption module, configured to consume, according to the initiating object address and the holding object address, the target virtual resource to obtain a transaction execution result of the resource consumption task; and
a first broadcast module, configured to broadcast a resource consumption event corresponding to the transaction execution result to a service device corresponding to the initiating object address, so as to make the service device perform, on a target item, service processing associated with the resource consumption event, the target virtual resource being configured for representing ownership of the target item.
The resource consumption module includes:
a first determining unit, configured to determine an address relationship between the initiating object address and the holding object address; and
a second determining unit, configured to determine a resource consumption failure result as the transaction execution result of the resource consumption task if the address relationship is that the initiating object address is different from the holding object address,
the resource consumption event including a first resource consumption event;
the first broadcast module includes:
a first generation unit, configured to generate the first resource consumption event corresponding to the transaction execution result, the first resource consumption event being configured for indicating that the initiating object address is different from the holding object address; and
a first broadcast unit, configured to broadcast the first resource consumption event to the service device corresponding to the initiating object address, so as to make the service device generate, according to the first resource consumption event, first item consumption failure information, the first item consumption failure information being configured for indicating that the initiating object address does not hold the target item.
The resource consumption module includes:
a third determining unit, configured to determine the address relationship between the initiating object address and the holding object address;
a first acquiring unit, configured to acquire a current resource state of the target virtual resource if the address relationship is that the initiating object address is the same as the holding object address; and
a resource consumption unit, configured to consume, according to the current resource state of the target virtual resource, the target virtual resource to obtain the transaction execution result of the resource consumption task.
The resource consumption unit includes:
a first determining subunit, configured to determine the resource consumption failure result as the transaction execution result of the resource consumption task if the current resource state of the target virtual resource is a resource consumed state,
the resource consumption event including a second resource consumption event;
the first broadcast module includes:
a second generation unit, configured to generate the second resource consumption event corresponding to the transaction execution result, the second resource consumption event being configured for indicating that the current resource state of the target virtual resource is the resource consumed state; and
a second broadcast unit, configured to broadcast the second resource consumption event to the service device corresponding to the initiating object address, so as to make the service device generate, according to the second resource consumption event, second item consumption failure information, the second item consumption failure information being configured for indicating that a current item state of the target item belonging to the initiating object address is an item consumed state.
The resource consumption unit includes:
a second determining subunit, configured to update the current resource state of the target virtual resource to the resource consumed state if the current resource state of the target virtual resource is a resource to-be-consumed state; and
the second determining subunit being further configured to determine a resource consumption success result as the transaction execution result of the resource consumption task if the current resource state of the target virtual resource is successfully updated,
the resource consumption event including a third resource consumption event;
the first broadcast module includes:
a third generation unit, configured to generate the third resource consumption event corresponding to the transaction execution result, the third resource consumption event being configured for indicating that the current resource state of the target virtual resource is updated from the resource to-be-consumed state to the resource consumed state; and
a third broadcast unit, configured to broadcast the third resource consumption event to the service device corresponding to the initiating object address, so as to make the service device generate, according to the third resource consumption event, item consumption success information, the item consumption success information being configured for indicating that the target item belonging to the initiating object address is consumed successfully.
The function calling module includes:
a second acquiring unit, configured to acquire a first index key-value pair in the blockchain, the first index key-value pair including a first index key generated using a virtual resource and a first index value generated using a resource identifier;
a fourth determining unit, configured to acquire, according to the first index key-value pair and the target resource identifier, the target virtual resource; and
a fifth determining unit, configured to acquire a holding object address of the target virtual resource.
The fourth determining unit includes:
a first broadcast subunit, configured to broadcast a resource abnormality event to the service device corresponding to the initiating object address if a first target index value including the target resource identifier does not exist in the first index key-value pair, so as to make the service device generate, according to the resource abnormality event, item abnormality information, the item abnormality information being configured for indicating that the target item belongs to an abnormal item; and
a third determining subunit, configured to determine a virtual resource in a first target index key corresponding to the first target index value as the target virtual resource if the first target index value including the target resource identifier exists in the first index key-value pair.
The fifth determining unit includes:
a first acquiring subunit, configured to acquire a second index key-value pair in the blockchain, the second index key-value pair including a second index key generated using an object address and a second index value generated using a virtual resource; and
a second acquiring subunit, configured to determine, in the second index key-value pair, a second index value including the target virtual resource as a second target index value, and determine an object address in a second index key corresponding to the second target index value as the holding object address.
The blockchain-based data processing apparatus further includes:
a result returning module, configured to return, if the transaction execution result is a resource consumption success result, the resource consumption success result to a resource device corresponding to the blockchain, so as to make the resource device update, according to the resource consumption success result, the current resource state of the target virtual resource to the resource consumed state, and acquire item consumption information of the target item, the item consumption information being stored in association with a resource consumption state of the target virtual resource.
The resource consumption task includes a transaction signature.
The blockchain-based data processing apparatus further includes:
a second acquiring module, configured to acquire an address public key corresponding to the initiating object address, use the address public key to perform signature verification on the transaction signature, and obtain a first digital digest;
a second broadcast module, configured to generate a second digital digest corresponding to the resource consumption task, generate, if the first digital digest is different from the second digital digest, a transaction abnormality event configured for indicating that the resource consumption task is an abnormal transaction, and broadcast the transaction abnormality event to the service device, so as to make the service device perform, according to the transaction abnormality event, validity verification on the resource consumption task; and
a notification module, configured to notify, if the first digital digest is the same as the second digital digest, the function calling module to perform calling, according to the resource consumption task, the resource consumption function in the smart contract.
In an aspect, this application provides a computer device, including: a processor, a memory, and a network interface,
the processor being connected to the memory and the network interface, the network interface being configured to provide a data communication function, the memory being configured to store computer programs, and the processor being configured to call the computer program to make the computer device execute the method in the embodiment of this application.
In an aspect, an embodiment of this application provides a computer-readable storage medium, having computer programs stored therein, the computer program being applicable to be loaded by a processor and execute the method in the embodiment of this application.
In an aspect, an embodiment of this application provides a computer program product, including a computer program, the computer program being stored in a computer-readable storage medium; a processor of a computer device reading the computer program from the computer-readable storage medium, and the processor executing the computer program to cause the computer device to execute the method in the embodiment of this application.
In the embodiments of this application, the resource consumption function is newly added in the smart contract, so that when the resource consumption task including the initiating object address and the target resource identifier is acquired, the resource consumption function can be called according to the resource consumption task, and the holding object address holding the target virtual resource can be determined in the blockchain based on the resource consumption function, where the target virtual resource refers to the virtual resource represented by the target resource identifier. Further, according to the initiating object address and the holding object address, the target virtual resource can be consumed to obtain the transaction execution result of the resource consumption task. Further, the resource consumption event corresponding to the transaction execution result is broadcast to the service device corresponding to the initiating object address, so as to make the service device perform, on the target item, service processing associated with the resource consumption event, where the target virtual resource is configured for representing the ownership of the target item. As can be seen above, the embodiment of this application provides a blockchain-based resource consumption method. According to the resource consumption method, when the target item is consumed, the target virtual resource configured for representing the ownership of the target item in the blockchain can be consumed in real time, and in this case, there is no need to perform destruction on the target virtual resource. Therefore, after the target item is successfully consumed, the blockchain still deposits the target virtual resource, and the ownership of the target item can be accurately traced through the consumed target virtual resource.
To describe technical solutions in embodiments of this application or the related art more clearly, the following briefly introduces the accompanying drawings required for describing the embodiments or the related art. Apparently, the accompanying drawings in the following description show merely some embodiments of this application, and a person of ordinary skill in the art may derive other drawings from these accompanying drawings without creative efforts.
The technical solutions in embodiments of this application are described in the following with reference to the accompanying drawings in the embodiments of this application. The described embodiments are merely some rather than all of the embodiments of this application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of this application without making creative efforts shall fall within the protection scope of this application.
For ease of understanding, some of the terms are first briefly explained below:
1. Blockchain: In a narrow sense, the blockchain is a chained data structure with blocks as basic units, and digital digests are used in the block to verify the previously acquired transaction history, which is suitable for the needs of immutability and expandability in distributed accounting scenes; and in a broad sense, the blockchain also refers to distributed ledger technologies implemented by a blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technologies, network protocols, smart contracts, and the like. The goal of the blockchain is to implement a distributed ledger for recording data, which only allows additions, and does not allow deletions. The underlying structure of the ledger is a linear linked list. The linked list is composed of the “blocks” connected in series, a subsequent block records the Hash value of a previous block, and whether each block (and transactions in the block) is valid or not can be quickly verified in a mode of calculating the Hash value. If a node in a network proposes to add a new block, it needs to be confirmed by a consensus mechanism to reach consensus on the block.
2. Blockchain node: A blockchain network distinguishes blockchain nodes as consensus nodes (which may also be referred to as a core node) and synchronization nodes (which may include a data node and a light node). The consensus node is responsible for the consensus service of the entire blockchain network. The synchronization node is responsible for synchronizing the ledger information of the consensus node, e.g., synchronizing the latest block data. The internal structure of both the consensus node and the synchronization node includes network communication components, because the blockchain network is essentially a peer to peer (P2P) network, which needs to communicate with other nodes in the blockchain network through P2P components. Resources and services in the blockchain network are dispersed on various nodes, and the transmission of information and the implementation of the services are carried out directly between nodes, without the intervention of intermediate links or centralized servers (third parties).
3. Smart contract: It is a computer protocol aimed at disseminating, verifying, or executing contracts in an information-based mode. In a blockchain system, the smart contract (referred to as contract) is a code that may be understood and executed by each node of the blockchain, which can execute any logic and obtain results. In practice, the smart contract manages and trials through transactions on the blockchain. Each transaction is equivalent to a remote procedure call (RPC) request to the blockchain system. If the smart contract is equivalent to an executable program, the blockchain is equivalent to an operating system that provides a running environment. The blockchain may contain multiple contracts (such as the contract to which a resource consumption function in this application belongs), distinguished by a contract identity (ID), an identification number or a name.
4. Contract execution: By initiating a transaction (such as a resource consumption task of this application), a user can call the contract that has been deployed on the blockchain (such as a resource consumption function of this application, and the like). Each node in a blockchain system runs the same contract. For a contract that needs to read data, the ledger of the node itself will be accessed. Eventually each node will verify whether execution results are consistent with each other (consensus). If the execution results are consistent, each node will deposit necessary results in their respective ledgers and return the results to the user.
5. Virtual resource: It is a digital product, which refers to an on-chain product in the blockchain network of an off-chain item, and a virtual resource of this application (e.g., a target virtual resource) may represent the ownership of the off-chain item, so the virtual resource in the embodiments of this application may be understood as a warrant. For example, if the off-chain item is a piece of land, the virtual resource represents the ownership of the land; if the off-chain item is game skin, the virtual resource represents the ownership of the game skin; and if the off-chain item is a concert ticket, the virtual resource represents the ownership of the concert ticket. The embodiments of this application do not limit the total quantity of corresponding virtual resources, it may be 1, such as a piece of land that has only one virtual resource (e.g., the ownership of the land); and it may be a positive integer greater than 1, for example a game developer produces 10 identical game skins and issues, on the blockchain, virtual resources corresponding to the 10 game skins, respectively.
6. Resource identifier: It is an identifier configured for representing the on-chain product in the blockchain network of the off-chain item, e.g., an identifier configured for representing the virtual resource. If the total quantity of corresponding virtual resources is greater than 1, for example, if the game developer produces 10 identical game skins, the total quantity of virtual resources corresponding to the 10 identical game skins is equal to 10. In this case, the 10 virtual resources have the same identifier in the blockchain network, but each virtual resource may correspond to an index identifier, respectively, so as to differentiate the 10 virtual resources, and therefore the resource identifier in the embodiment of this application may carry the index identifier. For example, if the index identifier is 1, it represents the first virtual resource in the above 10 virtual resources.
Referring to
The above consensus network 101 may include one or more consensus nodes, and the quantity of the consensus nodes will not be limited herein. Referring again to
The above synchronization network 102 may include one or more synchronization nodes, and the quantity of the synchronization nodes will not be limited herein. Referring again to
Each blockchain node (including the consensus node in the consensus network 101 and the synchronization node in the synchronization network 102) may receive transaction data sent by a client when performing normal operation, generate, based on the received transaction data, a block, and then perform on-chain processing of the block. In an implementation of this application, relevant data such as user information (e.g., a resource consumption task) is involved. When the embodiment of this application is applied to a specific product or technology, a permission or consent of a user is required, and collection, use, and processing of the relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions.
In order to ensure data interoperability between the blockchain nodes, there may be a data connection between the blockchain nodes, for example, there is a data connection between the consensus node 1011 and the consensus node 1012, there is a data connection between the consensus node 1011 and the consensus node 1013, there is a data connection between the synchronization node 1021 and the synchronization node 1023, and so on. Further, there is a data connection between the consensus network 101 and the synchronization network 102, for example, there is a data connection between the consensus node 1011 and the synchronization node 1022, there is a data connection between the consensus node 1012 and the synchronization node 1023, and so on.
Data or block transmission between the blockchain nodes may be performed via the above data connections. The above data connections between the blockchain nodes may be based on node identifiers. Each blockchain node in the blockchain network has a node identifier corresponding thereto, and each of the above blockchain nodes can store node identifiers of other blockchain nodes having a connection relationship with the blockchain node itself, so that the data acquired or the block generated can be subsequently broadcast, according to the node identifiers of other blockchain nodes, to other blockchain nodes. For example, the consensus node 1011 may maintain a list of node identifiers, and node names and node identifiers of other blockchain nodes are saved in the list of node identifiers, as shown in Table 1.
The node identifier may be an Internet Protocol (IP) address between networks and any other type of information that can be configured for identifying the blockchain node in the blockchain network.
Assuming that the consensus node 1011 has a node identifier of FFFFFF, the consensus node 1011 may send a data synchronization request to the synchronization node 1021 through a node identifier CCCCC, and the synchronization node 1021 may know, through the node identifier FFFFFF, that the data synchronization request is sent by the consensus node 1011. Similarly, the synchronization node 1023 may send a resource consumption task to the consensus node 1011 through the node identifier FFFFFF, and the consensus node 1011 may know, through a node identifier EEEEE, that the resource consumption task is sent by the synchronization node 1023, and the same is true for data transmission between other nodes, so it will not be repeated one by one.
The above data connection is not limited by a connection mode and may be a direct or indirect connection performed in a wired communication mode, or a direct or indirect connection performed in a wireless communication mode, or may be achieved in other connection modes, which is not limited by this application.
The blockchain nodes in the blockchain network in
Further, referring to
Operation S101: Acquire a resource consumption task, the resource consumption task including an initiating object address and a target resource identifier.
Specifically, the resource consumption task includes a transaction signature. The blockchain node acquires an address public key corresponding to the initiating object address, uses the address public key to perform signature verification on the transaction signature, and obtains a first digital digest. The blockchain node generates a second digital digest corresponding to the resource consumption task, generates, if the first digital digest is different from the second digital digest, a transaction abnormality event configured for indicating that the resource consumption task is an abnormal transaction, and broadcasts the transaction abnormality event to the service device, so as to make the service device perform, according to the transaction abnormality event, validity verification on the resource consumption task. If first digital digest is same as the second digital digest, operation S102 is executed.
The embodiment of this application does not limit specific service scenes of the resource consumption task, which may be set according to actual application scenarios, including, but not limited to, a consumption scene configured for representing the ownership of a movie ticket, a consumption scene configured for representing the ownership of a concert ticket, and the like. Referring to
The service device 30a may be installed with an application client (such as a service application in
As shown in
If the service object 301a selects to consume the target item, as shown in
Further, the service device 30a acquires an index table 30c. As shown in
Further, the service device 30a determines, through the item identifier 301d (e.g., 2222 . . . aaaa), the target resource identifier 302d (e.g., 2222 . . . bbbb) in the index table 30c. If the service application provides the ability to compose transactions, the service device 30a may generate, according to the target resource identifier 302d, the initiating object address 302b, and item quantity (typically 1), a resource consumption task 30e. The specific content of the resource consumption task 30e may be determined according to the actual application scenarios, which is not limited by the embodiment of this application. As shown in
The above describes a scene in which the service device 30a generates the resource consumption task 30e and transmits the resource consumption task 30e to the blockchain node 30f when the service application provides the ability to compose transactions. If the service application does not provide the ability to compose transactions, referring to the description of operation S201 in the embodiment corresponding to
In order to safeguard the security of transmission of the transaction, before transmitting the resource consumption task 30e to the blockchain node 30f, the service device 30a may perform, based on an address private key associated with the initiating object address 302b (illustrated as AaaXXXX1111 in
After acquiring the resource consumption task 30e carrying the transaction signature 401b, the blockchain node 30f acquires an address public key 402a corresponding to the initiating object address 302b (illustrated as AaaXXXX1111 in
Interfaces and controls shown in
Operation S102: Call, according to the resource consumption task, a resource consumption function in a smart contract, and determine, based on the resource consumption function, a holding object address in a blockchain, the holding object address referring to an object address holding a target virtual resource, and the target virtual resource referring to a virtual resource represented by the target resource identifier.
Specifically, the blockchain node may call, according to the resource consumption task, the resource consumption function in the smart contract. The resource consumption function may refer to a function (also referred to as a method) in the smart contract. The resource consumption function is a code that can be executed repeatedly. The resource consumption function is a function that may be called inside the same smart contract or a function that may be called inside another smart contract. The resource consumption function may provide a series of functions for consuming the virtual resource, for example, by executing the resource consumption function, the following functions may be implemented: determination of the holding object address, consumption of the virtual resource (after the consumption processing, a transaction execution result may be obtained), and broadcasting of a resource consumption event corresponding to the transaction execution result, and so on. Based on the resource consumption function, a first index key-value pair may be acquired in the blockchain. The first index key-value pair includes a first index key generated using a virtual resource and a first index value generated using a resource identifier. According to the first index key-value pair and the target resource identifier, a target virtual resource and a holding object address of the target virtual resource are determined.
The specific process of the blockchain node determining, according to the first index key-value pair and the target resource identifier, the target virtual resource may include the following operations: broadcast a resource abnormality event to a service device corresponding to the initiating object address if a first target index value including the target resource identifier does not exist in the first index key-value pair, so as to make the service device generate, according to the resource abnormality event, item abnormality information, the item abnormality information being configured for indicating that the target item belongs to an abnormal item; and determine, if a first index value including the target resource identifier exists in the first index key-value pair, the first index value including the target resource identifier as a first target index value and determine a virtual resource in a first index key corresponding to the first target index value as the target virtual resource. The target virtual resource may be a digital collection, and a particular object holding the target virtual resource can have a unique right of ownership of a target item corresponding to the virtual resource; and in other words, if a particular object holds the target virtual resource, then it indicates that the target item represented by the target virtual resource belongs to the object. Specifically, the target virtual resource may be a digital asset with a unique identifier (e.g., the target resource identifier) that is generated and issued based on the blockchain technology, has passed a content compliance review, and can only be owned by a service identity that has been authenticated with a real name.
The specific process of determining the holding object address of the target virtual resource may include the following operations: acquire, based on the resource consumption function, a second index key-value pair in the blockchain, the second index key-value pair including a second index key generated using an object address and a second index value generated using a virtual resource; and acquire, in the second index key-value pair, a second index value including the target virtual resource, determine the second index value including the target virtual resource as a second target index value, and determine an object address in a second index key corresponding to the second target index value as the holding object address.
This application designs, based on protocol standards for the virtual resource (herein specifically referring to the virtual resource configured for representing the ownership of the off-chain item) of the smart contract on the blockchain, a consumable virtual resource scheme, records, by adding interface standards for consumption of the virtual resource to the above standards, consumption records of the virtual resource in the contract, and sends relevant resource consumption events. For some ticket-type off-chain items or consumption class items in games and other scenes, after the service object uses interests corresponding to the off-chain items, corresponding on-chain resources (e.g., the virtual resource in the embodiment of this application, including the target virtual resource) thereof are consumed, so as to better adapt to resource consumption service scenes.
Referring to
Further, the blockchain node 30f uses the target resource identifier 302d (illustrated as 2222 . . . bbbb in
If the to-be-retrieved index value exists in the first index key-value pair 50a, as illustrated in
Further, the blockchain node 30f uses the target virtual resource 303d (illustrated as the virtual resource 1 in
Operation S103: Consume, according to the initiating object address and the holding object address, the target virtual resource to obtain a transaction execution result of the resource consumption task.
Specifically, an address relationship between the initiating object address and the holding object address is determined; a current resource state of the target virtual resource is acquired if the address relationship is the initiating object address is the same as the holding object address; and according to the current resource state of the target virtual resource, the target virtual resource is consumed to obtain the transaction execution result of the resource consumption task.
The specific process of consuming, according to the current resource state of the target virtual resource, the target virtual resource to obtain the transaction execution result of the resource consumption task may include the following operation: determine a resource consumption failure result as the transaction execution result of the resource consumption task if the current resource state of the target virtual resource is a resource consumed state.
The specific process of consuming, according to the current resource state of the target virtual resource, the target virtual resource to obtain the transaction execution result of the resource consumption task may include the following operations: update the current resource state of the target virtual resource to the resource consumed state if current resource state of the target virtual resource is a resource to-be-consumed state; and determine a resource consumption success result as the transaction execution result of the resource consumption task if the current resource state of the target virtual resource is successfully updated.
Referring again to
If the holding object address 303b and the initiating object address 302b are the same, the blockchain node 30f acquires the current resource state of the target virtual resource 303d (illustrated as the virtual resource 1 in
Operation S104: Broadcast the resource consumption event corresponding to the transaction execution result to the service device corresponding to the initiating object address, so as to make the service device perform, on the target item, service processing associated with the resource consumption event, the target virtual resource being configured for representing ownership of the target item.
Specifically, the resource consumption event includes the second resource consumption event; the second resource consumption event corresponding to the transaction execution result is generated, where the second resource consumption event is configured for indicating that the current resource state of the target virtual resource is the resource consumed state; and the second resource consumption event is broadcast to the service device corresponding to the initiating object address, so as to make the service device generate, according to the second resource consumption event, second item consumption failure information, where the second item consumption failure information is configured for indicating that a current item state of the target item belonging to the initiating object address is an item consumed state.
Specifically, the resource consumption event includes a third resource consumption event; the third resource consumption event corresponding to the transaction execution result is generated, where the third resource consumption event is configured for indicating that the current resource state of the target virtual resource is updated from the resource to-be-consumed state to the resource consumed state; and the third resource consumption event is broadcast to the service device corresponding to the initiating object address, so as to make the service device generate, according to the third resource consumption event, item consumption success information, where the item consumption success information is configured for indicating that the target item belonging to the initiating object address is consumed successfully.
Referring again to
Further, the blockchain node 30f generates the third resource consumption event, the third resource consumption event being configured for indicating that the current resource state of the target virtual resource 303d is updated from the resource to-be-consumed state to the resource consumed state. The blockchain node 30f broadcasts the third resource consumption event to the service device 30a. After acquiring the third resource consumption event, the service device 30a may generate item consumption success information 60b. As illustrated in
Interfaces and controls shown in
In the embodiments of this application, the resource consumption function is newly added in the smart contract, so that when the resource consumption task including the initiating object address and the target resource identifier is acquired, the resource consumption function can be called according to the resource consumption task, and the holding object address holding the target virtual resource can be determined in the blockchain based on the resource consumption function, where the target virtual resource refers to the virtual resource represented by the target resource identifier. Further, according to the initiating object address and the holding object address, the target virtual resource can be consumed to obtain the transaction execution result of the resource consumption task. Further, the resource consumption event corresponding to the transaction execution result is broadcast to the service device corresponding to the initiating object address, so as to make the service device perform, on the target item, service processing associated with the resource consumption event, where the target virtual resource is configured for representing the ownership of the target item. As can be seen above, the embodiment of this application provides a blockchain-based resource consumption method. According to the resource consumption method, when the target item is consumed, the target virtual resource configured for representing the ownership of the target item in the blockchain can be consumed in real time, and in this case, there is no need to perform destruction on the target virtual resource. Therefore, after the target item is successfully consumed, the blockchain still deposits the target virtual resource, and the ownership of the target item can be accurately traced through the consumed target virtual resource.
Referring to
Operation S201: Acquire a resource consumption task, the resource consumption task including an initiating object address and a target resource identifier.
Specifically, operation S101 in the above embodiment corresponding to
As shown in
Further, the service device 30a may display the target virtual resource and a resource consumption control 80b in the blockchain application. If the service object triggers the resource consumption control 80b, the service device 30a generates, in response to a trigger operation for the resource consumption control 80b, a resource consumption request 80c that includes the initiating object address 302b, the target resource identifier 301d, and the item quantity. The service device 30a sends the resource consumption request 80c to a resource server 80d, and the resource server 80d is a collection of multiple servers such as a backend server, a data processing server, and the like corresponding to the blockchain application installed for the service device 30a. If the service object 301a authorizes the resource server 80d to have the permission to use an address public-private key pair corresponding to the initiating object address 302d, then the resource server 80d may use an address private key corresponding to the initiating object address 302d to perform signature processing on the generated resource consumption task 30e to obtain a transaction signature as described in operation S101 of the above embodiment corresponding to
In some embodiments, if the service device 30a locally stores the address public-private key pair corresponding to the initiating object address 302d, and the service object 301a does not authorize the resource server 80d to have the permission to use the address public-private key pair, the service device 30a may locally generate, through the blockchain application, the resource consumption task 30e, then use the address private key to perform signature processing on the resource consumption task 30e to obtain a transaction signature, and next transmits the resource consumption task 30e carrying the transaction signature to the blockchain node 30f.
Operation S202: Call, according to the resource consumption task, a resource consumption function in a smart contract, and determine, based on the resource consumption function, a holding object address in a blockchain, the holding object address referring to an object address holding a target virtual resource, and the target virtual resource referring to a virtual resource represented by the target resource identifier.
With the increasing frequency of financial activities on the blockchain, on-chain virtual resources configured for representing the ownership of off-chain items are widely used on the blockchain. Current on-chain virtual resources (referred to as the virtual resource in the embodiment of this application) configured for representing the ownership of the off-chain items are applied in the fields, such as games, finance, souvenirs, and the like, on the chain. However, in some scenes, some virtual resources are to be consumed after use, for example, a ticket for a concert is to be consumed after a user attends a concert, but it is not to be destroyed because the service object can still hold the ticket that has been consumed, or collect the ticket that has been consumed. Based on this, the embodiment of this application provides a consumable digital asset scheme. In this scheme, a new function, e.g., the resource consumption function, is proposed, and based on the resource consumption function, the blockchain node may execute the resource consumption task, and consume the target virtual resource represented by the target resource identifier in the resource consumption task.
For the specific process of determining the holding object address in the blockchain, referring to operation S102 in the above embodiment corresponding to
Operation S203: Consume, according to the initiating object address and the holding object address, the target virtual resource to obtain a transaction execution result of the resource consumption task.
Specifically, an address relationship between the initiating object address and the holding object address is determined; and a resource consumption failure result is determined as the transaction execution result of the resource consumption task if the address relationship is that the initiating object address is different from the holding object address.
Referring again to
Operation S204: Broadcast a resource consumption event corresponding to the transaction execution result to a service device corresponding to the initiating object address, so as to make the service device perform, on the target item, service processing associated with the resource consumption event, the target virtual resource being configured for representing ownership of the target item.
Specifically, the resource consumption event includes a first resource consumption event; the first resource consumption event corresponding to the transaction execution result is generated, where the first resource consumption event is configured for indicating that the initiating object address is different from the holding object address; and the first resource consumption event is broadcast to the service device corresponding to the initiating object address, so as to make the service device generate, according to the first resource consumption event, first item consumption failure information, where the first item consumption failure information is configured for indicating that the initiating object address does not hold the target item.
Referring again to
Operation S205: Return, if the transaction execution result is a resource consumption success result, the resource consumption success result to a resource device corresponding to the blockchain, so as to make the resource device update, according to the resource consumption success result, the current resource state of the target virtual resource to a resource consumed state, and acquire item consumption information of the target item, the item consumption information being stored in association with a resource consumption state of the target virtual resource.
Specifically, the resource device may include a service device installed with a blockchain application and a resource server corresponding to the blockchain application.
Referring to
Operation S32: The service application queries the resource server for virtual resources of the service object under the service application. The service device installed with the service application may log in a service identity of the service object, so the service device bound with the service identity may query the resource server for the virtual resources under the service identity, and the virtual resources in the embodiment of this application are on-chain virtual resources, which are configured for representing the ownership of off-chain resources (e.g., the off-chain item). Subsequently, the resource server returns the queried virtual resource to the service device.
Operation S33: The service application displays the off-chain item represented by the queried virtual resource. The service application may also display a target resource identifier corresponding to the off-chain item, e.g., an identifier corresponding to the target virtual resource.
Operation S34: The service object selects a target item in the service application to perform consumption. The embodiment of this application refers to the off-chain item selected by the service object as the target item, and the example of this application does not limit the quantity of the target item, which may be determined according to the actual application scenarios, and is usually 1.
Operation S35: The service application determines the target resource identifier and generates an item consumption request. If the service application provides the ability to generate transactions, the service device installed with the service application may locally generate a resource consumption task that includes the target resource identifier, the initiating object address, and the item quantity. If the service application does not provide the ability to generate transactions, the service device generates an item consumption request that includes the target resource identifier, the initiating object address, and the item quantity.
Operation S36: The service application sends the item consumption request to the blockchain application. The blockchain application is an entry point for the virtual resource in the blockchain. If the blockchain application provides the ability to generate transactions, the service device installed with the blockchain application may locally generate the resource consumption task that includes the target resource identifier, the initiating object address, and the item quantity. If the blockchain application does not provide the ability to generate transactions, the service device generates the resource consumption request that includes the target resource identifier, the initiating object address, and the item quantity. Specifically, the service object logs in the blockchain application, the blockchain application confirms consumption of the target virtual resource through the service object, and a front-end of the blockchain application initiates the resource consumption request for the target virtual resource.
Operation S37: The blockchain application sends the resource consumption request to the resource server.
Operation S38: The resource server generates the resource consumption task, and a transaction signature. The resource server first verifies the identity of the service object through the service identity, and then signs, after the verification is passed, the resource consumption task according to an address private key corresponding to the initiating object address (in the scene of authorization by the service object), and obtains the transaction signature. Relevant parameters contained in the resource consumption task include the initiating object address, the target resource identifier, and the item quantity.
Operation S39: The resource server sends the resource consumption task carrying the transaction signature to the blockchain node.
Operation S40: The blockchain node calls the resource consumption function and executes the resource consumption task to obtain the transaction execution result. The blockchain node calls the resource consumption function, and executes the resource consumption task, including first verifying whether the holding object address of the target virtual resource is the initiating object address, and subsequently executing the consumption logic of the target virtual resource, for the specific process, referring to the above embodiment corresponding to
Operation S41: The blockchain node generates a resource consumption event. The blockchain node generates, according to the transaction execution result, a corresponding resource consumption event. Specifically, when the initiating object address is different from the holding object address, the blockchain node determines a resource consumption failure result as the transaction execution result, and generates a first resource consumption event configured for indicating that the initiating object address is different from the holding object address. When the initiating object address is the same as the holding object address and the current resource state of the target virtual resource is a resource consumed state, the blockchain node determines the resource consumption failure result as the transaction execution result and generates a second resource consumption event configured for indicating that the current resource state of the target virtual resource is the resource consumed state. When the initiating object address is the same as the holding object address and the current resource state of the target virtual resource is a resource to-be-consumed state, the blockchain node updates the current resource state to the resource consumed state, and then, upon successfully updated, determines a resource consumption success result as the transaction execution result and generates a third resource consumption event configured for indicating that the current resource state of the target virtual resource is successfully updated to the resource consumed state.
Operation S42: The blockchain node returns the transaction execution result to the resource server.
Operation S43: The resource server records the association of the target virtual resource. The embodiment of this application does not perform destruction on the consumed target virtual resource, but updates the resource consumption state, so the resource server can synchronize the resource state of the target virtual resource on the blockchain.
Operation S44: The blockchain node broadcasts the resource consumption event. Operation S42 may be executed earlier than operation S44, or later than operation S44, or the two operations may be executed in parallel, which is not limited by an example of this application.
Operation S45: The service application generates item consumption information. The service application may generate, according to the resource consumption events of different situations, different types of item consumption information, specifically referring to the description in the above embodiment corresponding to
In the embodiments of this application, the resource consumption function is newly added in the smart contract, so that when the resource consumption task including the initiating object address and the target resource identifier is acquired, the resource consumption function can be called according to the resource consumption task, and the holding object address holding the target virtual resource can be determined in the blockchain based on the resource consumption function, where the target virtual resource refers to the virtual resource represented by the target resource identifier. Further, according to the initiating object address and the holding object address, the target virtual resource can be consumed to obtain the transaction execution result of the resource consumption task. Further, the resource consumption event corresponding to the transaction execution result is broadcast to the service device corresponding to the initiating object address, so as to make the service device perform, on the target item, service processing associated with the resource consumption event, where the target virtual resource is configured for representing the ownership of the target item. As can be seen above, the embodiment of this application provides a blockchain-based resource consumption method. According to the resource consumption method, when the target item is consumed, the target virtual resource configured for representing the ownership of the target item in the blockchain can be consumed in real time, and in this case, there is no need to perform destruction on the target virtual resource. Therefore, after the target item is successfully consumed, the blockchain still deposits the target virtual resource, and the ownership of the target item can be accurately traced through the consumed target virtual resource.
Further, referring to
The first acquiring module 11 is configured to acquire a resource consumption task, the resource consumption task including an initiating object address and a target resource identifier.
The function calling module 12 is configured to call, according to the resource consumption task, a resource consumption function in a smart contract, and determine, based on the resource consumption function, a holding object address in a blockchain, the holding object address referring to an object address holding a target virtual resource, and the target virtual resource referring to a virtual resource represented by the target resource identifier.
The resource consumption module 13 is configured to consume, according to the initiating object address and the holding object address, the target virtual resource to obtain a transaction execution result of the resource consumption task.
The first broadcast module 14 is configured to broadcast a resource consumption event corresponding to the transaction execution result to a service device corresponding to the initiating object address, so as to make the service device perform, on a target item, service processing associated with the resource consumption event, the target virtual resource being configured for representing ownership of the target item.
The specific functional implementations of the first acquiring module 11, the function calling module 12, the resource consumption module 13, and the first broadcast module 14 may refer to operation S101 to operation S104 in the above embodiment corresponding to
Referring again to
The first determining unit 131 is configured to determine an address relationship between the initiating object address and the holding object address.
The second determining unit 132 is configured to determine a resource consumption failure result as the transaction execution result of the resource consumption task if the address relationship is that the initiating object address is different from the holding object address, the resource consumption event including a first resource consumption event.
The first broadcast module 14 may include: a first generation unit 141 and a first broadcast unit 142.
The first generation unit 141 is configured to generate the first resource consumption event corresponding to the transaction execution result, the first resource consumption event being configured for indicating that the initiating object address is different from the holding object address.
The first broadcast unit 142 is configured to broadcast the first resource consumption event to the service device corresponding to the initiating object address, so as to make the service device generate, according to the first resource consumption event, first item consumption failure information, the first item consumption failure information being configured for indicating that the initiating object address does not hold the target item.
The specific functional implementations of the first determining unit 131, the second determining unit 132, the first generation unit 141, and the first broadcast unit 142 may refer to operation S203 to operation S204 in the above embodiment corresponding to
Referring again to
The third determining unit 133 is configured to determine the address relationship between the initiating object address and the holding object address.
The first acquiring unit 134 is configured to acquire a current resource state of the target virtual resource if the address relationship is that the initiating object address is the same as the holding object address.
The resource consumption unit 135 is configured to consume, according to the current resource state of the target virtual resource, the target virtual resource to obtain the transaction execution result of the resource consumption task.
The specific functional implementations of the third determining unit 133, the first acquiring unit 134, and the resource consumption unit 135 may refer to operation S103 in the above embodiment corresponding to
Referring again to
The first determining subunit 1351 is configured to determine the resource consumption failure result as the transaction execution result of the resource consumption task if the current resource state of the target virtual resource is a resource consumed state, the resource consumption event including a second resource consumption event.
The first broadcast module 14 may include: a second generation unit 143 and a second broadcast unit 144.
The second generation unit 143 is configured to generate the second resource consumption event corresponding to the transaction execution result, the second resource consumption event being configured for indicating that the current resource state of the target virtual resource is the resource consumed state.
The second broadcast unit 144 is configured to broadcast the second resource consumption event to the service device corresponding to the initiating object address, so as to make the service device generate, according to the second resource consumption event, second item consumption failure information, the second item consumption failure information being configured for indicating that a current item state of the target item belonging to the initiating object address is an item consumed state.
The specific functional implementations of the first determining subunit 1351, the second generation unit 143, and the second broadcast unit 144 may refer to operation S103 to operation S104 in the above embodiment corresponding to
Referring again to
The second determining subunit 1352 is configured to update the current resource state of the target virtual resource to the resource consumed state if the current resource state of the target virtual resource is a resource to-be-consumed state.
The second determining subunit 1352 is further configured to determine a resource consumption success result as the transaction execution result of the resource consumption task if the current resource state of the target virtual resource is successfully updated, the resource consumption event including a third resource consumption event.
The first broadcast module 14 may include: a third generation unit 145 and a third broadcast unit 146.
The third generation unit 145 is configured to generate the third resource consumption event corresponding to the transaction execution result, the third resource consumption event being configured for indicating that the current resource state of the target virtual resource is updated from the resource to-be-consumed state to the resource consumed state.
The third broadcast unit 146 is configured to broadcast the third resource consumption event to the service device corresponding to the initiating object address, so as to make the service device generate, according to the third resource consumption event, item consumption success information, the item consumption success information being configured for indicating that the target item belonging to the initiating object address is consumed successfully.
The specific functional implementations of the second determining subunit 1352, the third generation unit 145, and the third broadcast unit 146 may refer to operation S103 to operation S104 in the above embodiment corresponding to
Referring again to
The second acquiring unit 121 is configured to acquire a first index key-value pair in the blockchain, the first index key-value pair including a first index key generated using a virtual resource and a first index value generated using a resource identifier.
The fourth determining unit 122 is configured to acquire, according to the first index key-value pair and the target resource identifier, the target virtual resource.
The fifth determining unit 123 is configured to acquire a holding object address of the target virtual resource.
The specific functional implementations of the second acquiring unit 121 and the fourth determining unit 122 may refer to operation S102 in the above embodiment corresponding to
Referring again to
The first broadcast subunit 1221 is configured to broadcast a resource abnormality event to the service device corresponding to the initiating object address if a first target index value including the target resource identifier does not exist in the first index key-value pair, so as to make the service device generate, according to the resource abnormality event, item abnormality information, the item abnormality information being configured for indicating that the target item belongs to an abnormal item.
The third determining subunit 1222 is configured to determine a virtual resource in a first target index key corresponding to the first target index value as the target virtual resource if the first target index value including the target resource identifier exists in the first index key-value pair.
The specific functional implementations of the first broadcast subunit 1221 and the third determining subunit 1222 may refer to operation S102 in the above embodiment corresponding to
Referring again to
The first acquiring subunit 1223 is configured to acquire a second index key-value pair in the blockchain, the second index key-value pair including a second index key generated using an object address and a second index value generated using a virtual resource.
The second acquiring subunit 1224 is configured to determine, in the second index key-value pair, a second index value including the target virtual resource as a second target index value, and determine an object address in a second index key corresponding to the second target index value as the holding object address.
The specific functional implementations of the first acquiring subunit 1223 and the second acquiring subunit 1224 may refer to operation S102 in the above embodiment corresponding to
Referring again to
The result returning module 15 is configured to return, if the transaction execution result is a resource consumption success result, the resource consumption success result to a resource device corresponding to the blockchain, so as to make the resource device update, according to the resource consumption success result, the current resource state of the target virtual resource to the resource consumed state, and acquire item consumption information of the target item, the item consumption information being stored in association with a resource consumption state of the target virtual resource.
The specific functional implementation of the result returning module 15 may refer to operation S205 in the above embodiment corresponding to
Referring again to
The blockchain-based data processing apparatus 1 may further include: a second acquiring module 16, a second broadcast module 17, and an operation executing module 18.
The second acquiring module 16 is configured to acquire an address public key corresponding to the initiating object address, use the address public key to perform signature verification on the transaction signature, and obtain a first digital digest.
The second broadcast module 17 is configured to generate a second digital digest corresponding to the resource consumption task, generate, if the first digital digest is different from the second digital digest, a transaction abnormality event configured for indicating that the resource consumption task is an abnormal transaction, and broadcast the transaction abnormality event to the service device, so as to make the service device perform, according to the transaction abnormality event, validity verification on the resource consumption task.
The operation executing module 18 is configured to execute, if the first digital digest is the same as the second digital digest, the operation of calling, according to the resource consumption task, the resource consumption function in the smart contract.
The specific functional implementations of the second acquiring module 16, the second broadcast module 17, and the operation executing module 18 may refer to operation S101 in the above embodiment corresponding to
In the embodiments of this application, the resource consumption function is newly added in the smart contract, so that when the resource consumption task including the initiating object address and the target resource identifier is acquired, the resource consumption function can be called according to the resource consumption task, and the holding object address holding the target virtual resource can be determined in the blockchain based on the resource consumption function, where the target virtual resource refers to the virtual resource represented by the target resource identifier. Further, according to the initiating object address and the holding object address, the target virtual resource can be consumed to obtain the transaction execution result of the resource consumption task. Further, the resource consumption event corresponding to the transaction execution result is broadcast to the service device corresponding to the initiating object address, so as to make the service device perform, on the target item, service processing associated with the resource consumption event, where the target virtual resource is configured for representing the ownership of the target item. As can be seen above, the embodiment of this application provides a blockchain-based resource consumption method. According to the resource consumption method, when the target item is consumed, the target virtual resource configured for representing the ownership of the target item in the blockchain can be consumed in real time, and in this case, there is no need to perform destruction on the target virtual resource. Therefore, after the target item is successfully consumed, the blockchain still deposits the target virtual resource, and the ownership of the target item can be accurately traced through the consumed target virtual resource.
Further, referring to
In the computer device 1000 shown in
acquiring a resource consumption task, the resource consumption task including an initiating object address and a target resource identifier;
calling, according to the resource consumption task, a resource consumption function in a smart contract, and determining, based on the resource consumption function, a holding object address in the blockchain, the holding object address referring to an object address holding a target virtual resource, and the target virtual resource referring to a virtual resource represented by the target resource identifier;
consuming, according to the initiating object address and the holding object address, the target virtual resource to obtain a transaction execution result of the resource consumption task; and
broadcasting a resource consumption event corresponding to the transaction execution result to a service device corresponding to the initiating object address, so as to make the service device perform, on a target item, service processing associated with the resource consumption event, the target virtual resource being configured for representing ownership of the target item.
The computer device 1000 described in the embodiment of this application may implement the description of the blockchain-based data processing method or apparatus in the foregoing embodiments, and will not be repeated herein. In addition, the description of beneficial effects of the same method will not repeated herein.
An embodiment of this application further provides a computer-readable storage medium, having computer programs stored therein, the computer program, when executed by a processor, implementing the description of the blockchain-based data processing method or apparatus in the foregoing embodiments, which will not be repeated herein. In addition, the description of beneficial effects of the same method will not repeated herein.
The above computer-readable storage medium may be the blockchain-based data processing apparatus provided by any one of the foregoing embodiments or an internal storage unit of the above computer device, such as a hard disk or internal memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, for example, a plug-in type hard disk being equipped on the computer device, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Further, the computer-readable storage medium may further include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is configured to store other programs and data needed for the computer program and the computer device. The computer-readable storage medium may be also configured to temporarily store the data that has been outputted or will be outputted.
An embodiment of this application further provides a computer program product, including computer programs, the computer program being stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device can execute the description of the blockchain-based data processing method or apparatus in the foregoing embodiments, which will not be repeated herein. In addition, the description of beneficial effects of the same method will not be repeated herein.
The terms “first” and “second” in the specification, claims, and accompanying drawings of the embodiments of this application are used for distinguishing different objects and are not used for describing a specific sequence. In addition, the term “include” and any variant thereof are intended to cover a non-exclusive inclusion. For example, a process, method, apparatus, product or device that includes a series of operations or units is not limited to the listed operations or modules, and instead, in some embodiments, includes an operation or module that is not listed, or further in some embodiments, includes another operation or unit that is intrinsic to the process, method, apparatus, product, or device.
A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm operations may be implemented by electronic hardware, computer software, or a combination thereof. To clearly describe the interchangeability between the hardware and the software, the foregoing has generally described compositions and operations of each example according to functions. Whether the functions are executed in a mode of hardware or software depends on particular applications and design constraint conditions of the technical solution. A person skilled in the art may use different methods to implement the described functions for each particular application, but it shall not be considered that the implementation goes beyond the scope of this application.
What is disclosed above is merely exemplary embodiments of this application, and certainly is not intended to limit the scope of the claims of this application. Therefore, equivalent variations made in accordance with the claims of this application shall fall within the scope of this application.
| Number | Date | Country | Kind |
|---|---|---|---|
| 202310006792.2 | Jan 2023 | CN | national |
This application is a continuation of and claims the benefit of priority to PCT Application No. PCT/CN2023/132668, filed Nov. 20, 2023, and entitled BLOCKCHAIN-BASED DATA PROCESSING METHOD, DEVICE, AND READABLE STORAGE MEDIUM, which claims priority to Chinese Patent Application No. 202310006792.2, entitled “BLOCKCHAIN-BASED DATA PROCESSING METHOD, DEVICE, AND READABLE STORAGE MEDIUM”, filed with the China National Intellectual Property Administration on Jan. 4, 2023. The above applications are incorporated herein by reference in their entireties.
| Number | Date | Country | |
|---|---|---|---|
| Parent | PCT/CN2023/132668 | Nov 2023 | WO |
| Child | 19049956 | US |