Data query method and device based on block chain, equipment and medium
By deploying aggregation query contracts on the blockchain, users can query all their digital assets at one time, solving the problems of difficult operation and missed asset risks in the existing technology, and achieving efficient and accurate asset query.
Patent Information
- Application Number
- CN202311004356.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-09
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, users need to manually search and import the contract address of on-chain assets, resulting in increased operational difficulty and possible missing some on-chain assets.
By deploying an aggregation query contract on the blockchain, users can query all their digital assets at once through the contract, reducing the steps of manual operations and improving query efficiency.
It realizes efficient query of multiple digital assets of users, reduces operation difficulty and reduces the risk of missing assets.
Smart Images

Figure CN119474143A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of blockchain, and in particular to a data query method, device, equipment, medium and program product based on blockchain. Background Art
[0002] As financial activities on the blockchain (abbreviated as on-chain) become increasingly frequent, people's activities on the chain are increasing, the standards of on-chain assets (digital assets) are diverse, and the digital assetization of off-chain assets on the blockchain is widely used in many fields.
[0003] In the related technology, on-chain assets are stored by using contracts. Users add the contract address and standard type corresponding to the on-chain assets in the wallet program, and then query the on-chain assets they own through the query interface of the contract.
[0004] However, this query method requires users to first search for the contract address corresponding to the on-chain asset, and then manually import the corresponding information of the on-chain asset, which increases the difficulty of user operation and may miss some on-chain assets. Summary of the invention
[0005] The present application provides a data query method, device, equipment, medium and program product based on blockchain, and the technical solution at least includes:
[0006] According to one aspect of an embodiment of the present application, a data query method based on blockchain is provided, the method being executed by a node in the blockchain, the method comprising:
[0007] Receiving a query request sent by a terminal device, where the query request is used by the terminal device to request to query at least two digital assets of a user of the terminal device on the blockchain;
[0008] Execute the aggregate query contract based on the query request to obtain the query result. The aggregate query contract is a contract deployed on the blockchain for querying at least two digital assets;
[0009] The query result is sent to the terminal device, where the query result includes information of at least two digital assets.
[0010] According to another aspect of an embodiment of the present application, a data query device based on blockchain is provided, the device comprising:
[0011] A receiving module, used to receive a query request sent by a terminal device, where the query request is used by the terminal device to request to query at least two digital assets of a user of the terminal device on the blockchain;
[0012] An acquisition module, used to execute an aggregate query contract based on a query request and obtain a query result. The aggregate query contract is a contract deployed on a blockchain for querying at least two digital assets;
[0013] The sending module is used to send the query result to the terminal device, and the query result includes information of at least two digital assets.
[0014] According to another aspect of an embodiment of the present application, a computer device is provided, comprising: a processor and a memory, wherein at least one program is stored in the memory; the processor is used to execute at least one program in the memory to implement the blockchain-based data query method of the above-mentioned various aspects.
[0015] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one program is stored, and the at least one program is loaded and executed by a processor to implement a blockchain-based data query method as described in the above aspects.
[0016] According to another aspect of an embodiment of the present application, a computer program product (or computer program) is provided, which includes computer instructions, which are stored in a computer-readable storage medium, and a processor obtains the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to implement the blockchain-based data query method as described in the above aspects.
[0017] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0018] This method queries the user's multiple digital assets by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query. 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 A schematic diagram of a computer system provided by an exemplary embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram of a computer system provided by an exemplary embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram showing a block structure provided by an exemplary embodiment of the present application is shown;
[0023] Figure 4 A schematic diagram showing the types of digital assets provided by an exemplary embodiment of the present application;
[0024] Figure 5 A schematic diagram of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown;
[0025] Figure 6 A flowchart of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown;
[0026] Figure 7 A flowchart of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown;
[0027] Figure 8 A flowchart of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown;
[0028] Fig. 9 A schematic diagram of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown;
[0029] Fig.10 A block diagram of a data query device based on blockchain provided by an exemplary embodiment of the present application is shown;
[0030] Fig.11 A schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION
[0031] 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.
[0032] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0033] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0034] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0035] It should be understood that, although the terms first, second, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first parameter may also be referred to as the second parameter, and similarly, the second parameter may also be referred to as the first parameter. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0036] First, some of the terms used in this application are explained:
[0037] Blockchain: Blockchain includes 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. Blockchain usually consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information feature value, version number, timestamp and difficulty value, and the block body stores the input information; the next block of the genesis block uses the genesis block as the parent block, and the next block also includes a block header and a block body. The block header stores the input information feature value of the current block, the block header feature value, version number, timestamp and difficulty value of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.
[0038] Hash value: Also known as information characteristic value or characteristic value, the hash value is generated by converting input data of any length into a password and performing a fixed output through a hash algorithm. The original input data cannot be retrieved by decrypting the hash value. It is a one-way encryption function. In the blockchain, each block (except the initial block) contains the hash value of the previous block, which is called the parent block of the current block. The hash value is the potential core foundation and the most important aspect of blockchain technology. It preserves the authenticity of recorded and viewed data, as well as the integrity of the blockchain as a whole.
[0039] Evidence storage: For example, when information is stored in a blockchain, the node where the blockchain is located verifies the input information when it receives it. After verification, the input information is stored in the memory pool and the hash tree used to record the input information is updated. After that, the update timestamp is updated to the time when the input information is received, and different random numbers are tried to calculate the eigenvalue multiple times so that the calculated eigenvalue can satisfy the following formula:
[0040] SHA256(SHA256(version+prev_hash+merkle_root+ntime+
[0041] nbits+x))<TARGET;
[0042] Among them, SHA256 is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value within a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, which can be determined based on nbits.
[0043] In this way, when the random number that satisfies the above formula is calculated, the information can be stored accordingly, the block header and block body can be generated, and the current block can be obtained. Subsequently, the node where the blockchain is located sends the newly generated block to other nodes in the data sharing system according to the node identification of other nodes in the data sharing system. Other nodes verify the newly generated block and add the newly generated block to the blockchain stored in them after the verification is completed.
[0044] Blockchain contract: referred to as contract, is a computerized protocol that can execute the terms of a contract. It is implemented by deploying code on a shared ledger to execute when certain conditions are met. The code is used to complete automated transactions according to actual business needs. For example, query the logistics status of the goods purchased by the buyer, and transfer the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Blockchain contracts are not limited to executing contracts for transactions, but are also used to execute contracts for processing received information.
[0045] Figure 1 A schematic diagram of a computer system 100 provided by an exemplary embodiment of the present application is shown. The computer system 100 includes: a terminal device 120 and a data sharing system 140 .
[0046] The terminal device 120 may be an electronic device such as a mobile phone, a tablet computer, a vehicle-mounted terminal (vehicle computer), a wearable device, a personal computer (PC), etc.
[0047] The data sharing system 140 refers to a system for sharing data between nodes, and the data sharing system may include multiple nodes 130, and the multiple nodes 130 may refer to various clients in the data sharing system 140. Each node 130 can receive input information when performing normal work, and maintain the shared data in the data sharing system 140 based on the received input information. In order to ensure the information intercommunication within the data sharing system 140, there may be an information connection between each node 130 in the data sharing system 140, and the nodes 130 may transmit information through the above information connection. For example, when any node 130 in the data sharing system 140 receives input information, the other nodes 130 in the data sharing system 140 obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes 130 in the data sharing system 140 are consistent.
[0048] Each node 130 in the data sharing system 140 has a node identifier corresponding thereto, and each node 130 in the data sharing system 140 can store the node identifiers of other nodes 130 in the data sharing system 140, so that the generated blocks can be broadcast to other nodes in the data sharing system 140 according to the node identifiers of other nodes. A node identifier list as shown in Table 1 can be maintained in each node 130, and the node name and the node identifier are stored in the node identifier list accordingly. Among them, the node identifier can be an Internet Protocol (IP) address for interconnection between networks and any other information that can be used to identify the node. Table 1 only uses the IP address as an example for explanation.
[0049] Table 1
[0050] Node Name Node ID Node 1 117.114.151.174 Node 2 117.116.189.145 … … Node N xxx.xxx.xxx.xxx
[0051] Each node 130 in the data sharing system 140 stores an identical blockchain. The terminal device 120 and the data sharing system 140 can communicate via a network, such as a wired network or a wireless network.
[0052] Figure 2 A schematic diagram of a distributed system 200 provided by an exemplary embodiment of the present application is shown, and the distributed system 200 includes: a node 210 and a client 220. The node 210 is any form of computing device in an access network, such as a server, a user terminal, and Figure 1 The node 130 in the embodiment has the same meaning as the client 220. Figure 1 The terminal devices 120 in the embodiments have the same meaning.
[0053] Taking the distributed system 200 as a blockchain system as an example, it is formed by multiple nodes 210 and clients 220. In the distributed system 200, any machine such as a server or a terminal can join and become a node 210. The node 210 includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.
[0054] See also Figure 3 The functions of each node 210 in the distributed system 200 shown include at least one of the following functions:
[0055] (1) Routing: a basic function of the node 210, used to support communication between nodes 210.
[0056] (2) Application: used to be deployed in the blockchain to implement specific business according to actual business needs, record data related to the implementation of the function to form record data, carry a digital signature in the record data to indicate the source of the task data, and send the record data to other nodes 210 in the distributed system 200, so that other nodes 210 can add the record data to the temporary block when the source and integrity of the record data are successfully verified.
[0057] For example, the services implemented by the application include:
[0058] (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 210 in the distributed system 200. After the other nodes 210 successfully verify the transaction, as a response to acknowledge the validity of the transaction, the transaction record data is stored in the temporary block of the blockchain; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address.
[0059] (2.2) Shared ledger: used to provide functions such as storage, query and modification of account data, and send the record data of the operation on the account data to other nodes 210. After the other nodes 210 verify the validity, as a response to acknowledge 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 210 that initiated the operation.
[0060] (2.3) Smart Contract: A computerized protocol that can execute the terms of a contract. It is 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 the goods purchased by the buyer and transferring the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.
[0061] (3) Blockchain: It includes 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 node 210 in the distributed system 200.
[0062] The blockchain consists of multiple blocks, such as Figure 3 As shown, the genesis block 310 includes a block body 311 and a block header 312, in which a version number 3121, an input information feature value 3122, a timestamp 3123 and a difficulty value 3124 are stored, and the block body 311 stores input information; the next block 320 of the genesis block 310 takes the genesis block 310 as a parent block, and the next block 320 also includes a block body 321 and a block header 322, in which the block header 322 stores a block header feature value 3221, an input information feature value 3222, a version number 3223, a timestamp 3224 and a difficulty value 3225 of the parent block of the current block (next block 320), and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, thereby ensuring the security of the input information in the block.
[0063] In the data query method based on blockchain provided in the embodiment of the present application, the execution subject of each step may be a node device corresponding to any node 130 in the data sharing system 140, and the node device may be a computer device. A computer device refers to an electronic device with data calculation, processing and storage capabilities, and a computer device includes a server, which may be a physical server or a cloud server. Figure 1Taking the implementation environment shown as an example, the blockchain-based data query method can be executed by a node device corresponding to any node 130 in the data sharing system 140, or can be executed by the terminal device 120 and the node device corresponding to the node 130 in the data sharing system 140 in an interactive manner, and the embodiments of the present application are not limited to this.
[0064] Those skilled in the art will appreciate that the number of the above-mentioned terminal devices or node devices may be more or less. For example, the above-mentioned terminal device or node device may be only one, or the above-mentioned terminal devices or node devices may be dozens or hundreds, or more. The embodiment of the present application does not limit the number and device type of terminal devices and node devices.
[0065] As financial activities on the blockchain (referred to as on-chain) become more frequent, people's activities on the blockchain are increasing, and the asset standards on the chain are diverse. The digital assetization of off-chain assets on the blockchain is widely used in many fields. The relevant applications are mainly in the financial field, including securities and financial derivatives. Most of the digital assets issued on the blockchain are based on Ethereum standards (Ethereum Request for Comments, ERC) 20, ERC721, and ERC1155. Figure 4 As shown in Figure 1, digital assets include virtual resources and digital collections. Virtual resources and digital collections are two different types of digital assets. Virtual resources refer to each unit is interchangeable, that is, each unit is the same and has no difference. However, each unit of digital collections is unique and has its own unique attributes and identifiers. This feature means that each unit can be regarded as unique, and their value and characteristics may be different.
[0066] The Ethereum blockchain platform is currently the mainstream smart contract platform on the public chain. Most of the digital collections on the public chain are currently issued on the Ethereum platform based on the ERC721 and ERC1155 standards. In the ERC721 standard, only one digital collection can be issued on the chain for one off-chain digital collection, while in the ERC1155 standard, multiple digital collections can be issued on the chain for one off-chain digital collection.
[0067] Among them, the main interfaces of ERC20 include:
[0068] Core
[0069] {{IERC20}}: The core operation interface in ERC20.
[0070] {{IERC20Metadata}}: ERC20 metadata.
[0071] {{ERC20}}: Core operations in ERC20.
[0072] Extensions
[0073] {{ERC20Burnable}}: ERC20 virtual resource destruction.
[0074] {{ERC20Capped}}: Sets an upper limit for ERC20 virtual resources.
[0075] {{ERC20Pausable}}: ERC20 contract is paused.
[0076] {{ERC20Snapshot}}: ERC20 contract status snapshot.
[0077] {{ERC20Votes}}: ERC20 virtual resource voting.
[0078] {{ERC20VotesComp}}: ERC20 delegated virtual resource voting.
[0079] {{ERC20FlashMint}}: ERC20 virtual resource flash loan.
[0080] A “ / / ” at the beginning of a line indicates a code comment, and a line without a “ / / ” at the beginning indicates a code. The codes defined by ERC20 Core include:
[0081] function totalSupply()view returns(uint256 totalSupply);
[0082] / / Total amount of virtual resources.
[0083] function balanceOf(address_owner)view returns(uint256 balance);
[0084] / / Query the virtual resource balance under the specified address.
[0085] function transfer(address_to,uint256_value)returns(bool success);
[0086] / / Transfer a specified amount of virtual resources to the specified address, and return true if the transfer is successful.
[0087] / / If the source address does not have enough virtual resources, the function should throw an exception.
[0088] / / Even if zero virtual resources are transferred, the transfer event should be triggered.
[0089] / / A transfer function similar to transfer. The difference is that you can specify a transfer address.
[0090] function transferFrom(address_from,address_to,uint256_value)
[0091] returns(bool success);
[0092] / / If the current address is authorized by the outgoing address, the transfer operation can be performed on behalf of it.
[0093] function approve(address_spender,uint256_value)returns(bool success);
[0094] / / Authorize a specific transfer amount for the specified address.
[0095] / / The authorized address can call the transferFrom function multiple times to transfer money instead of the source address, and the total value does not exceed _value.
[0096] / / In actual use, approve(_spender,0) should be called before resetting the credit limit each time.
[0097] / / Wait for the transaction to be confirmed before calling approve(_spender,newAllowance).
[0098] / / If approve is called directly once, the authorized address has the opportunity to transfer virtual resources exceeding the specified amount.
[0099] function allowance(address_owner,address_spender)view returns(uint256remaining);
[0100] / / Query the remaining transfer amount of the specified authorized address.
[0101] The core events in the ERC20 standard include:
[0102] event Transfer(address indexed_from,address indexed_to,uint256_value);
[0103] / / Transfer event. Must be triggered when the transfer is successful.
[0104] event Approval(address indexed_owner,address indexed_spender,uint256_value);
[0105] / / Authorization event. Must be triggered when authorization is successful.
[0106] The main interfaces of ERC721 include:
[0107] core
[0108] ERC721: Main contract interface.
[0109] ERC721Enumerable: Enumeration data query interface, count all digital asset identifiers (Identity Document, ID) in the contract, and which user's account the digital asset ID belongs to.
[0110] ERC721Receiver: Receiver callback implementation, verifying the receiver contract address to avoid accounts that cannot respond.
[0111] ERC721MetaData: Main contract metadata interface (name, symbol, tokenURI).
[0112] extensions
[0113] ERC721Pausable: The contract is paused.
[0114] ERC721Burnable: Destruction of digital assets.
[0115] ERC721URIStorage: digital asset uniform resource identifier (token Uniform Resource Identifier, token URI) storage.
[0116] presets
[0117] ERC721PresetMinterPauserAutoId: The contract owner authorizes the creator (Minter) and pauser (Pauser) roles.
[0118] utilities
[0119] ERC721Holder: The default implementation of ERC721Receiver, which receives any digital asset.
[0120] The main interfaces of ERC1155 include:
[0121] core
[0122] ERC1155: Main contract interface.
[0123] ERC1155MetadataURI: Main contract metadata interface URI.
[0124] ERC1155Receiver: Receiver callback implementation, verifying the receiver contract address to avoid accounts that cannot respond.
[0125] extensions
[0126] ERC1155Pausable: The contract is paused.
[0127] ERC1155Burnable: Digital asset destruction.
[0128] ERC1155Supply: The total supply statistics interface for each digital asset.
[0129] presets
[0130] ERC1155PresetMinterPauserAutoId: The contract owner authorizes the creator (Minter) and pauser (Pauser) roles.
[0131] utilities
[0132] ERC1155Holder: The default implementation of ERC721Receiver, which receives any digital asset.
[0133] The differences between ERC1155 and ERC721 are:
[0134] (1) ERC1155 supports batch transfer and batch minting;
[0135] (2) When minting digital collections through ERC1155, one off-chain digital collection can be minted into multiple digital collections on the chain, while when minting digital collections through ERC721, one off-chain digital collection can only be minted into one digital collection on the chain.
[0136] In the related art, the method of airdropping (sending to users) digital collections includes at least one of the following:
[0137] 1) On-chain whitelist: The whitelist is hard-coded in the contract code, that is, the airdrop object (user) is specified in the contract code. This method consumes more contract deployment fuel (gas);
[0138] 2) Off-chain whitelist: the business party will airdrop designated digital collections to users, and the business party will pay for fuel (gas) for on-chain transactions;
[0139] 3) Off-chain whitelist, users obtain the credentials of the business party. Users submit the credentials when minting digital collections, and then obtain their own digital collections. Users have a process of obtaining the credentials of the business party off-chain.
[0140] In the related art, each digital asset (on-chain asset) is stored in a contract. When a user has multiple digital assets, there may be management problems. For example, N assets owned by a user may be stored in N different contracts. The user can add the contract address corresponding to the digital asset and the standard type of the digital asset in the wallet program, and then the wallet program can obtain the digital asset of the user in the contract address through the query interface of the contract address. In the above process, the user must first search for the contract address of the digital asset, and then manually import the digital asset, and can only import one digital asset at a time, which increases the difficulty of the user's operation, and the user may miss some digital assets. Based on the above problems, the embodiment of the present application proposes a data query method based on blockchain, by deploying a public aggregate query contract (referred to as contract) on the chain, and the developer writes the on-chain address of the supported digital assets and the standard type of the digital asset in the contract before the contract is deployed. Based on the above-deployed aggregate query contract, the wallet program can query the user's digital assets at one time through the contract interface and display them in the wallet program, and since the query interface on the chain does not involve write operations, the user does not need to consume the user's fuel (gas) resources each time the query is made.
[0141] Figure 5 A schematic diagram of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown, and the method is executed by a terminal device 120 and a node device corresponding to a node 130 in a data sharing system. In this embodiment, the node 130 and the node device corresponding to the node 130 have the same meaning. The method includes:
[0142] Step 510 : The terminal device 120 sends a query request to the node 130 .
[0143] In some embodiments, the query request is used to request node 130 to query the digital assets of terminal device 120 on the blockchain.
[0144] In some embodiments, the terminal device 120 performs operations to query digital assets through a digital asset wallet program (referred to as wallet or wallet program).
[0145] In some embodiments, after receiving the query request, node 130 executes the aggregate query contract. The aggregate query contract can be called a digital asset aggregate query smart contract, a digital asset aggregate query contract, etc. The embodiments of the present application do not limit this and take the aggregate query contract as an example for explanation.
[0146] In some embodiments, the digital asset issuer writes an aggregate query contract off-chain according to a specified digital asset standard, such as ERC20, ERC721, ERC1155, etc., and generates a contract deployment transaction by uploading the aggregate query contract to the wallet program.
[0147] The digital asset issuer uses its own private key in the wallet program to sign the contract deployment transaction, and finally sends the contract deployment transaction to the blockchain for deployment.
[0148] The digital asset issuer initiates a digital asset registration request and initiates a digital asset addition request to the blockchain through the wallet program. The digital asset addition request includes information related to the digital asset issuer, the digital asset contract chain address, the digital asset identifier, the digital asset type, and other information.
[0149] The blockchain administrator reviews the relevant information of the digital asset initiator. After confirming the relevant information of the digital asset issuer, the administrator uses the management private key to sign the digital asset transaction, and finally executes the signed digital asset transaction on the chain.
[0150] The digital asset initiator executes the digital asset addition transaction through the aggregate query contract, and records the added digital asset information in the storage space of the aggregate query contract: [tokenSymbol, tokenAddress, tokenType], where tokenSymbol is the symbol of the digital asset, tokenAddress is the on-chain address of the digital asset, and tokenType is the asset type of the querying user, such as ERC20, ERC721, ERC1155.
[0151] The user obtains the on-chain address of the account held by the user through the wallet program according to the user's key custody type. In this embodiment, the on-chain address of the account held by the user has the same meaning as the on-chain address of the account, the user's on-chain address, the user's address, and the account address.
[0152] Blockchain key escrow is a service or mechanism for securely keeping and managing account private keys. In blockchain, private keys are the key factor used to control accounts and execute transactions. It is a password used to encrypt and decrypt data, which can be used to prove the identity of the account holder and digitally sign transactions. If the user is key escrow, the account's on-chain address is saved in the node used as a server; if the user is key non-escrow, the account's on-chain address is stored in the wallet program.
[0153] Through the wallet program, the user can query the information of all the digital assets of the user according to the user's on-chain address. After receiving the query request, the aggregate query contract loops through the contract addresses corresponding to all the digital assets registered in the contract and returns the information of the user's digital assets. The aggregate query contract summarizes the information of digital assets and returns the information to the wallet program.
[0154] The wallet program periodically queries the aggregate query contract to update the information of all the user's digital assets.
[0155] In some embodiments, the implementation of the aggregate query contract is as follows, where " / / " at the beginning of a line indicates a code comment, and no " / / " at the beginning of a line indicates code:
[0156] interface TokenFactory{
[0157] / / The mapping relationship between the digital asset symbol and the digital asset owned by the user. tokenSymbol is the symbol of the digital asset, where tokenAsset is the structure of the digital asset, tokenAddress is the address on the digital asset chain, tokenId is the digital asset ID (if it is ERC721 and ERC1155, it has the tokenId, if it is ERC20, it is empty), and amount represents the amount of digital assets owned by the user.
[0158] / / The general structure is as follows:
[0159] / / tokenSymbol=>tokenAddress tokenId amount
[0160] mapping(string=>tokenAsset)public asset;
[0161] / / mapping(string=>tokenAsset) represents the data structure type.
[0162] / / tokenType=>tokenSymbol
[0163] function QueryTokenFactory(
[0164] address addr,
[0165] string tokenType
[0166] / / QueryTokenFactory: Query the digital asset type specified by the user, where addr is the user address and tokenType is the asset type of the querying user (such as ERC20, ERC721, ERC1155).
[0167] / / mapping(string=>tokenAssetArray) returns the data structure, which returns the user asset mapping table, where key=>value is an asset mapping relationship, key is tokenSymbol, and value is the tokenAsset structure. For specific explanation, refer to the above.
[0168] )public returns(mapping(string=>tokenAsset))
[0169] / / public is a public function, returns represents the return value
[0170] }
[0171] ERC20
[0172] core:function balanceOf(address_owner)view returns(uint256 balance);
[0173] / / Query the digital asset balance under the specified address.
[0174] ERC721
[0175] core:function balanceOf(address_owner)external view returns(uint256);
[0176] / / Get the number of digital collections owned by the user address in ERC721.
[0177] ERC721Enumerable:function tokenOfOwnerByIndex(address_owner,uint256_index)external view returns(uint256);
[0178] / / Read the tokenId of each digital collection of the user in turn.
[0179] ERC1155
[0180] core:function balanceOf(address_owner)external view returns(uint256);
[0181] / / Get the number of digital collections owned by the user address in the ERC1155 standard contract.
[0182] core:function balanceOf(address_owner,uint256_id)external viewreturns(uint256);
[0183] / / Get the number of specified digital collections owned by the user address in the ERC1155 standard contract.
[0184] ERC1155Enumerable:function tokenIdByIndexOfOwner(address_owner,uint256_tokenIndex)external view returns(uint256);
[0185] / / Read the tokenId of each digital collection of the user in turn.
[0186] Step 520: Send the query result.
[0187] After executing the aggregate query contract, node 130 obtains the query results and sends the query results to the terminal device 120. The query results include at least one of the following: the types of virtual resources under ERC20 and the quantity of each virtual resource, and digital collections under ERC721 and ERC1155.
[0188] In some embodiments, when the wallet program is opened, the terminal device 120 sends a query request to the node 130. For example, when the wallet program is opened, the relevant information of the account is automatically displayed, and the relevant information of the account includes at least one of the following: the types of virtual resources held by the user under ERC20 and the quantity of each virtual resource, the digital collections held by the user under ERC721 and ERC1155, and the total assets of the user.
[0189] In some embodiments, when the wallet program is opened, the user clicks the query control to send a query request to the node 130, such as Figure 5As shown, if the query control 533 is not clicked, the interface corresponding to the wallet program does not display the relevant information of the account. If the query control 533 is clicked and the interface corresponding to the virtual resource 531 is selected for viewing, the types of virtual resources held by the user and the quantity of each virtual resource are displayed. For example, it is displayed that the number of virtual resources A held by the user is 100, and the corresponding assets are 10,000 units; the number of virtual resources B is 5,000, and the corresponding assets are 5,000 units, and the total assets are 15,000 units. If the query control 533 is clicked and the interface corresponding to the digital collection 532 is selected for viewing, the digital collection held by the user is displayed, for example, it is displayed that the user currently holds image A 5351 and image B 5352.
[0190] In some embodiments, the wallet program periodically queries the aggregate query contract to update the relevant information of the account, for example, automatically updating the relevant information of the account every 30 seconds.
[0191] When the refresh control 534 is clicked, the terminal device queries the aggregate query contract again to update the relevant information of the account. For example, after clicking the refresh control 534, the interface corresponding to the virtual resource 531 shows that the number of virtual resources A held by the user is 100, and the corresponding assets are 10,000 units; the number of virtual resources B is 10,000, and the corresponding assets are 10,000 units, and the total assets are 20,000 units. The interface corresponding to the digital collection 532 shows that the digital collection held by the user remains unchanged.
[0192] In summary, the method provided in this embodiment queries multiple digital assets of the user by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query.
[0193] The method provided in this embodiment also periodically sends query requests to regularly update the user's digital asset information, thereby ensuring the timeliness of the digital asset information.
[0194] The method provided in this embodiment also flexibly controls the time of querying digital asset information by clicking a query control to query digital asset information and clicking a refresh control to refresh digital asset information, thereby reducing the power consumption of the terminal device.
[0195] Figure 6 A flowchart of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown. The method is executed by a node in the blockchain, and the method includes:
[0196] Step 610: Receive a query request sent by a terminal device.
[0197] In some embodiments, the query request is used by a terminal device to request a query of at least two digital assets of a user of the terminal device on the blockchain.
[0198] The blockchain includes 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. The blockchain is usually composed of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information feature value, version number, timestamp and difficulty value, and the block body stores the input information; the next block of the genesis block uses the genesis block as the parent block, and the next block also includes a block header and a block body. The block header stores the input information feature value of the current block, the block header feature value, version number, timestamp and difficulty value of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.
[0199] Digital assets refer to all assets that exist and are traded electronically in a digital environment. These assets can include securities, stocks, virtual goods, artwork, real estate, domain names, and other ownable interests. Digital assets are secured and immutable through the use of blockchain technology and cryptography. Blockchain technology allows the ownership and transaction history of digital assets to be recorded and verified, ensuring the authenticity and traceability of assets. The trading and management of digital assets are usually achieved through blockchain contracts or similar mechanisms that enable transparent, programmable, and automated exchange of digital assets on a distributed network.
[0200] In some embodiments, the query request is used by a terminal device to request a query of the digital assets of a user of the terminal device on the blockchain.
[0201] In some embodiments, the terminal device sends the query request through a wallet program, which is an application for managing and executing cryptocurrency and digital assets. It allows users to create, store and manage one or more cryptocurrency accounts to receive, send and store digital assets.
[0202] In some embodiments, the node receives a query request periodically sent by the terminal device. In order to ensure the timeliness of the digital asset information obtained by the terminal device, the terminal device periodically sends a query request, for example, sends a query request once every 10 seconds, so that the digital asset information is updated every 10 seconds.
[0203] Step 620: Execute the aggregate query contract based on the query request to obtain the query results.
[0204] In some embodiments, the aggregate query contract is a contract deployed on a blockchain for querying at least two digital assets.
[0205] In the related art, each digital asset is stored in a contract. When a user owns multiple digital assets, there may be management problems. For example, N assets owned by a user may be stored in N different contracts. The user can add the contract address corresponding to the digital asset and the standard type of the asset in the wallet program, and then the wallet program can obtain the user's digital assets in the contract address through the query interface of the contract address. In the above process, the user must first search for the contract address of the digital asset, and then manually import the digital asset, and can only import one digital asset at a time, which increases the difficulty of the user's operation, and the user may miss some digital assets.
[0206] The embodiment of the present application can query all the digital assets of the user and display them in the wallet program by executing the aggregate query contract. The aggregate query contract is implemented by the developer before deployment by writing the on-chain address of the supported digital assets and the standard type of the digital assets in the contract. For example, if a digital asset under the ERC20 standard is supported, its corresponding on-chain address and standard type are written into the aggregate query contract. When the aggregate query contract is executed, it will query whether the digital asset is included in all the digital assets of the user.
[0207] Step 630: Send the query result to the terminal device.
[0208] In some embodiments, the query results include information of at least two digital assets.
[0209] In some embodiments, the query results include at least one of the following: types of virtual resources under ERC20 and the quantity of each virtual resource, and digital collections under ERC721 and ERC1155.
[0210] In summary, the method provided in this embodiment queries multiple digital assets of the user by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query.
[0211] The method provided in this embodiment also periodically sends query requests to regularly update the user's digital asset information, thereby ensuring the timeliness of the digital asset information.
[0212] Figure 7 A flowchart of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown, and the method includes:
[0213] Step 610: Receive a query request sent by a terminal device.
[0214] Step 622: Based on the query request, at least two contracts are called through the aggregate query contract to traverse and query at least two digital assets to obtain the query results.
[0215] In the related art, each digital asset is stored in a contract. The embodiment of the present application calls at least two contracts through an aggregate query contract to traverse and query the information of at least two digital assets held by the user.
[0216] In some embodiments, when at least two contracts include contracts corresponding to all digital assets, a query result is obtained, and the query result includes information on at least two digital assets held by the user.
[0217] In some embodiments, based on the query request, at least two contracts in the whitelist are called by the aggregate query contract to traverse and query at least two digital assets to obtain query results;
[0218] Among them, the whitelist is a list of contracts corresponding to digital assets that are supported by the aggregate query contract for storage.
[0219] In some embodiments, the developer pre-sets a whitelist, and the contracts in the whitelist are all contracts corresponding to digital assets that the aggregate query contract supports querying.
[0220] When the whitelist includes contracts corresponding to at least two digital assets, obtaining query results, the query results including information of at least two digital assets;
[0221] In the case where the whitelist includes contracts corresponding to some of the at least two digital assets, the query result is obtained, and the query result includes information about some of the digital assets. For example, a user holds two digital assets, namely digital asset A and digital asset B, and the aggregate query contract supports querying the contract corresponding to digital asset A, but does not support querying the contract corresponding to digital asset B. Then the query result obtained includes information about digital asset A, but does not include information about digital asset B. The user can manually add information corresponding to digital asset B, or can apply to the developer to add the contract corresponding to digital asset B to the whitelist.
[0222] Step 630: Send the query result to the terminal device.
[0223] In summary, the method provided in this embodiment queries multiple digital assets of the user by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query.
[0224] The method provided in this embodiment also improves the query efficiency of digital assets by calling at least two contracts or whitelists and traversing and querying at least two digital assets.
[0225] Figure 8 A flowchart of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown, and the method includes:
[0226] Step 610: Receive a query request sent by a terminal device.
[0227] Step 6242: Based on the information of the digital asset type carried in the query request, retrieve the data structure types of at least two digital assets in at least two contracts in the whitelist through the first function part.
[0228] In some embodiments, executing an aggregate query contract based on a query request to obtain query results includes:
[0229] Obtain query results based on the digital asset type information carried in the query request;
[0230] The information on the digital asset type includes at least one of the following: the on-chain address of the account corresponding to the user, and the type of digital asset held by the account corresponding to the user.
[0231] The aggregate query contract obtains the user's account information through the on-chain address of the account corresponding to the user (user), and determines the types of digital assets held by the user through the types of digital assets held by the user's corresponding account, such as virtual resources under ERC20, digital collections under ERC721 or ERC115.
[0232] In some embodiments, the aggregate query contract includes a first function portion and a second function portion.
[0233] In some embodiments, data structure types of at least two digital assets are stored in an aggregate query contract or other contract.
[0234] In some embodiments, the user address has the same meaning as the on-chain address of the user's corresponding account, the user's asset type has the same meaning as the digital asset type held by the user's corresponding account, " / / " at the beginning of a line indicates a comment on the code, and no " / / " at the beginning of a line indicates a code. The implementation of the aggregate query contract is as follows:
[0235] interface TokenFactory{
[0236] / / The mapping relationship between the digital asset symbol and the digital asset owned by the user. tokenSymbol is the symbol of the digital asset, where tokenAsset is the structure of the digital asset, tokenAddress is the address on the digital asset chain, tokenId is the digital asset ID (if it is ERC721 and ERC1155, it has the tokenId, if it is ERC20, it is empty), and amount represents the amount of digital assets owned by the user.
[0237] / / The general structure is as follows:
[0238] / / tokenSymbol=>tokenAddress tokenId amount
[0239] mapping(string=>tokenAsset)public asset;
[0240] / / mapping(string=>tokenAsset) represents the data structure type.
[0241] / / tokenType=>tokenSymbol
[0242] function QueryTokenFactory(
[0243] address addr,
[0244] string tokenType
[0245] / / QueryTokenFactory: Query the digital asset type specified by the user, where addr is the user address and tokenType is the asset type of the querying user (such as ERC20, ERC721, ERC1155).
[0246] / / mapping(string=>tokenAssetArray) returns the data structure, which returns the user asset mapping table, where key=>value is an asset mapping relationship, key is tokenSymbol, and value is the tokenAsset structure.
[0247] )public returns(mapping(string=>tokenAsset))
[0248] / / public is a public function, returns represents the return value
[0249] }
[0250] ERC20
[0251] core:function balanceOf(address_owner)view returns(uint256 balance);
[0252] / / Query the virtual resource balance under the specified address.
[0253] ERC721
[0254] core:function balanceOf(address_owner)external view returns(uint256);
[0255] / / Get the number of digital collections owned by the user address in ERC721.
[0256] ERC721Enumerable:function tokenOfOwnerByIndex(address_owner,uint256_index)external view returns(uint256);
[0257] / / Read the tokenId of each digital collection of the user in turn.
[0258] ERC1155
[0259] core:function balanceOf(address_owner)external view returns(uint256);
[0260] / / Get the number of digital collections owned by the user address in the ERC1155 standard contract.
[0261] core:function balanceOf(address_owner,uint256_id)external viewreturns(uint256);
[0262] / / Get the number of specific digital collections owned by the user address in the ERC1155 standard contract.
[0263] ERC1155Enumerable:function tokenIdByIndexOfOwner(address_owner,uint256_tokenIndex)external view returns(uint256);
[0264] / / Read the tokenId of each digital collection of the user in turn.
[0265] Among them, the first function part includes "mapping(string=>tokenAsset)public asset;" to "public returns(mapping(string=>tokenAsset))", the user address (addr) represents the on-chain address of the account corresponding to the user, and the digital asset type (tokenType) represents the type of digital asset held by the account corresponding to the user.
[0266] Step 6244: Based on the information of the digital asset type carried in the query request, obtain information of at least two digital assets that conform to the data structure type through the second function part.
[0267] In some embodiments, the digital asset includes a virtual resource, the second function portion includes a virtual resource function portion, and the method includes:
[0268] Based on the on-chain address of the user's corresponding account and the type of digital assets held by the user's corresponding account, the virtual resource information is obtained through the virtual resource function part;
[0269] The information of the virtual resource includes at least one of the following: the on-chain address of the virtual resource and the quantity of the virtual resource.
[0270] In some embodiments, based on the user address (addr) and the digital asset type (tokenType), the information of the virtual resource is obtained through the virtual resource function part.
[0271] According to step 6242, the virtual resource function part includes: "core: function balanceOf (address_owner) view returns (uint256 balance);", for the specific protocol meaning, refer to Figure 4 The implementation examples and the main interface parts of ERC20 mentioned above will not be repeated here.
[0272] In some embodiments, the digital asset comprises a digital collectible, the second functional portion comprises a digital collectible functional portion, and the method comprises:
[0273] Based on the information of the digital asset type carried in the query request, the information of the digital collection is obtained through the digital collection function part;
[0274] The information of the digital collection includes at least one of the following: the on-chain address of the digital collection, the digital asset ID of the digital collection, the number of digital collections, and the number of types of digital collections.
[0275] In some embodiments, the digital collection function portion includes a first sub-function portion and / or a second sub-function portion, and the method includes at least one of the following:
[0276] Based on the information of the digital asset type carried in the query request, the number of digital collections and the digital asset ID of each digital collection under the first blockchain standard are obtained through the first sub-function part;
[0277] Based on the information of the digital asset type carried in the query request, the number of types of digital collections, the number of each type of digital collections and the digital asset ID of each digital collection under the second blockchain standard are obtained through the second sub-function part;
[0278] Among them, the first blockchain standard is the standard that only one digital collection asset is issued on the blockchain for an off-chain digital collection asset, and the second blockchain standard is the standard that at least one digital collection asset is issued on the blockchain for an off-chain digital collection asset.
[0279] In some embodiments, based on the user address (addr) and the digital asset type (tokenType), the number of digital collections and the digital asset ID of each digital collection under ERC721 are obtained through the first sub-function part;
[0280] Based on the user address (addr) and the digital asset type (tokenType), the second sub-function part obtains the number of types of digital collections, the number of each digital collection and the digital asset ID of each digital collection under ERC1155.
[0281] Taking the first blockchain standard as ERC721 and the second blockchain standard as ERC1155 as an example, according to step 6242, the first sub-function part includes: "core: function balanceOf(address_owner) external view returns(uint256);" to "ERC721Enumerable: function tokenOfOwnerByIndex(address_owner,uint256_index) external view returns(uint256);"; the second sub-function part includes "core: function balanceOf(address_owner) external view returns(uint256);" to "ERC1155Enumerable: function tokenIdByIndexOfOwner(address_owner,uint256_tokenIndex) external view returns(uint256);", and the specific meaning of the protocol is referenced. Figure 4 The embodiments and the main interface parts of ERC721 and ERC1155 mentioned above will not be repeated here.
[0282] Step 630: Send the query result to the terminal device.
[0283] In summary, the method provided in this embodiment queries multiple digital assets of the user by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query.
[0284] The method provided in this embodiment also obtains information about virtual resources through the virtual resource function part, thereby improving the accuracy of querying virtual resources.
[0285] The method provided in this embodiment also obtains the information of the digital collection under ERC721 through the first sub-function part and obtains the information of the digital collection under ERC1155 through the second sub-function part, thereby improving the accuracy of querying the digital collection.
[0286] In the above embodiment, steps with the same sequence number can be considered as the same step. Figure 6 The corresponding embodiments, Figure 7 The corresponding embodiments and Figure 8 The corresponding embodiments may be implemented individually or in combination, and this application does not limit this.
[0287] Fig. 9 A schematic diagram of a data query method based on blockchain provided by an exemplary embodiment of the present application is shown, and the method includes:
[0288] Step 901: The digital asset issuer 91 logs into the wallet program 93.
[0289] Step 902: The digital asset issuer 91 writes a digital asset contract.
[0290] The digital asset issuer 91 writes an aggregate query contract 95 off-chain according to the specified digital asset standards, such as ERC20, ERC721, ERC1155, etc., and generates a contract deployment transaction by uploading the aggregate query contract 95 to the wallet program 93.
[0291] Step 903: The digital asset issuer 91 uses the private key to sign in the wallet program 93.
[0292] The digital asset issuer 91 uses its own private key in the wallet program 93 to sign the contract deployment transaction. In the blockchain, the private key is a key factor for controlling accounts and executing transactions. It is a password used to encrypt and decrypt data, which can be used to prove the identity of the account holder and digitally sign transactions.
[0293] Step 904: The digital asset issuer 91 deploys the digital asset contract through the digital asset server 94.
[0294] The digital asset issuer 91 uses the wallet program 93 to deploy the digital asset contract through the digital asset server 94.
[0295] Step 905: The digital asset server 94 puts the digital asset contract on the chain.
[0296] The digital asset issuer 91 sends the digital asset contract to the blockchain for deployment through the digital asset server 94, and adds the digital asset contract to the aggregate query contract 95.
[0297] Step 906: Aggregate query contract 95 sends a contract deployment transaction return.
[0298] Aggregate query contract 95 sends a contract deployment transaction return to the wallet program, which includes at least one of the following: transaction hash, fuel consumption (fuel required for transaction execution) and event log (events triggered by the contract during execution). Among them, the transaction hash is used to query the detailed information of the transaction in the blockchain, such as transaction status, block confirmation number, transaction fee, etc. The transaction hash is used to confirm whether the contract is successfully deployed and obtain information about the deployment process.
[0299] Step 907: The digital asset issuer 91 initiates a digital asset registration request to the wallet program 93.
[0300] Step 908: The digital asset issuer 91 initiates a digital asset adding request to the digital asset server 94 through the wallet program 93.
[0301] A digital asset addition request is initiated to the blockchain through the wallet program 93, and the digital asset addition request includes information related to the digital asset issuer 91, the digital asset contract chain address, the digital asset identifier, the digital asset type and other information.
[0302] Step 909: The digital asset server 94 queries the administrator's signature.
[0303] The administrator of the blockchain reviews the relevant information of the digital asset initiator 91 through the digital asset server 94. After confirming the relevant information of the digital asset issuer 91, the administrator uses the management private key to sign the digital asset transaction.
[0304] Step 910: The digital asset server 94 puts the digital asset transaction on the chain.
[0305] After the administrator signs, the signed digital asset transaction is executed on the chain through the digital asset server 94.
[0306] Step 911: The aggregate query contract 95 returns the digital asset setting result.
[0307] The digital asset initiator 91 executes the digital asset addition transaction through the aggregate query contract 95, and records the added digital asset information in the storage space of the aggregate query contract 95: [tokenSymbol, tokenAddress, tokenType], where tokenSymbol is the symbol of the digital asset, tokenAddress is the on-chain address of the digital asset, and tokenType is used to query the asset type of user 92, such as ERC20, ERC721, ERC1155.
[0308] Step 912: User 92 logs into wallet program 93.
[0309] User 92 obtains the on-chain address of the account held by user 92 through the wallet program according to the key custody type of user 92. In this embodiment, the on-chain address of the account held by user 92 has the same meaning as the on-chain address of the account, the user on-chain address, the user address, and the account address.
[0310] Step 913: The wallet program 93 obtains the on-chain address of user 92 according to the key custody type of user 92.
[0311] The key escrow of blockchain is a service or mechanism for securely keeping and managing the private key of an account. In blockchain, the private key is the key factor for controlling accounts and executing transactions. It is a password used to encrypt and decrypt data, which can be used to prove the identity of the account holder (user 92) and digitally sign transactions. If user 92 is a key escrow, the on-chain address of the account is stored in the node used as the server; if user 92 is a non-key escrow, the on-chain address of the account is stored in the wallet program.
[0312] Step 914: The wallet program 93 queries the digital assets based on the on-chain address of the user 92.
[0313] In some embodiments, the wallet program 93 periodically queries the digital assets according to the on-chain address of the user 92. For example, the cycle is 10 seconds, and the digital assets of the user 92 are queried every 10 seconds.
[0314] In some embodiments, user 92 uses wallet program 93 to query information about all digital assets of the user based on the user's on-chain address.
[0315] Step 915: The aggregate query contract 95 loops through and queries the registered digital assets.
[0316] After receiving the query request, the aggregate query contract 95 loops through and queries the contract addresses corresponding to all digital assets registered in the contract.
[0317] Step 916: Aggregate query contract 95 returns the digital asset balance.
[0318] After the aggregate query contract 95 completes the query, it returns the information of the digital assets of the user 92, such as the balance of virtual resources and the specific content of the digital collection.
[0319] Step 917: The wallet program 93 displays the digital assets.
[0320] The wallet program 93 displays the digital assets held by the user 92, such as the balance of virtual resources and the specific content of digital collections. For specific display details, refer to Figure 4 The embodiments are not described in detail here.
[0321] In summary, the method provided in this embodiment queries multiple digital assets of the user by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query.
[0322] The method provided in this embodiment also periodically sends query requests to regularly update the user's digital asset information, thereby ensuring the timeliness of the digital asset information.
[0323] Fig.10A block diagram of a blockchain-based data query device provided by an exemplary embodiment of the present application is shown. The device can be implemented as a computer device, or as a part of a computer device, through software or hardware or a combination of both. The device includes a receiving module 1010, an acquisition module 1020 and a sending module 1030.
[0324] A receiving module 1010 is used to receive a query request sent by a terminal device, where the query request is used by the terminal device to request to query at least two digital assets of a user of the terminal device on the blockchain;
[0325] An acquisition module 1020 is used to execute an aggregate query contract based on a query request to obtain a query result. The aggregate query contract is a contract deployed on a blockchain for querying at least two digital assets.
[0326] The sending module 1030 is used to send the query result to the terminal device, where the query result includes information of at least two digital assets.
[0327] In a possible design of this embodiment, the acquisition module 1020 is used to traverse and query at least two digital assets by calling at least two contracts through an aggregate query contract based on the query request to obtain the query result;
[0328] Among them, at least two contracts include contracts corresponding to at least two digital assets.
[0329] In a possible design of this embodiment, the acquisition module 1020 is used to traverse and query at least two digital assets by calling at least two contracts in the whitelist through the aggregate query contract based on the query request to obtain the query result;
[0330] Among them, the whitelist is a list of contracts corresponding to digital assets that are supported by the aggregate query contract for storage.
[0331] In a possible design of this embodiment, the aggregate query contract includes a first function part and a second function part; an acquisition module 1020 is used to retrieve data structure types of at least two digital assets from at least two contracts in the whitelist through the first function part based on the information of the digital asset type carried in the query request;
[0332] The acquisition module 1020 is used to acquire information of at least two digital assets that conform to the data structure type through the second function part based on the information of the digital asset type carried in the query request.
[0333] In a possible design of this embodiment, the digital asset includes a virtual resource, the second function part includes a virtual resource function part, and the acquisition module 1020 is used to acquire the information of the virtual resource through the virtual resource function part based on the information of the digital asset type carried in the query request;
[0334] The information of the virtual resource includes at least one of the following: the on-chain address of the virtual resource and the quantity of the virtual resource.
[0335] In a possible design of this embodiment, the digital asset includes a digital collection, the second function part includes a digital collection function part, and the acquisition module 1020 is used to acquire the information of the digital collection through the digital collection function part based on the information of the digital asset type carried in the query request;
[0336] The information of the digital collection includes at least one of the following: the on-chain address of the digital collection, the digital asset ID of the digital collection, the number of digital collections, and the number of types of digital collections.
[0337] In a possible design of this embodiment, the digital collection function part includes a first sub-function part and / or a second sub-function part, and the acquisition module 1020 is used to acquire the number of digital collections and the digital asset ID of each digital collection under the first blockchain standard through the first sub-function part based on the information of the digital asset type carried in the query request;
[0338] Based on the information of the digital asset type carried in the query request, the second sub-function part is used to obtain the number of types of digital collections, the number of each type of digital collections and the digital asset ID of each digital collection under the second blockchain standard;
[0339] Among them, the first blockchain standard is the standard that only one digital collection asset is issued on the blockchain for an off-chain digital collection asset, and the second blockchain standard is the standard that at least one digital collection asset is issued on the blockchain for an off-chain digital collection asset.
[0340] In a possible design of this embodiment, the acquisition module 1020 is used to acquire the query result based on the information of the digital asset type carried in the query request;
[0341] The information on the digital asset type includes at least one of the following: the on-chain address of the account corresponding to the user, and the type of digital asset held by the account corresponding to the user.
[0342] In a possible design of this embodiment, the receiving module 1010 is used to receive query requests periodically sent by the terminal device.
[0343] In summary, the device provided in this embodiment queries multiple digital assets of the user by executing an aggregate query contract. The user does not need to query the digital assets he holds one by one, which improves the query efficiency and reduces the problem of missing some digital assets during the query.
[0344] The device provided in this embodiment also periodically sends query requests to regularly update the user's digital asset information, thereby ensuring the timeliness of the digital asset information.
[0345] In this embodiment, the acquisition module 1020 can be divided into multiple acquisition modules, such as a first acquisition module and a second acquisition module. The first acquisition module is used to acquire information about virtual resources, and the second acquisition module is used to acquire information about digital collections; or the first acquisition module is used to acquire information about digital collections, and the second acquisition module is used to acquire information about virtual resources. This embodiment does not limit the functions of different acquisition modules.
[0346] This embodiment is described by taking one acquisition module 1020 as an example, and the number of acquisition modules 1020 is not limited.
[0347] For an introduction to the functions of the receiving module 1010, please refer to Figure 6 The content of step 610 in the embodiment;
[0348] For an introduction to the functions of acquisition module 1020, please refer to Figure 6 The content of step 620 in the embodiment, Figure 7 The content of step 622 in the embodiment, Figure 8 The contents of step 6242 and step 6244 in the embodiment.
[0349] For an introduction to the functions of the sending module 1030, please refer to Figure 6 The content of step 630 in the embodiment.
[0350] An embodiment of the present application also provides a computer device, which includes: a processor and a memory, wherein at least one program is stored in the memory; the processor is used to execute at least one program in the memory to implement the blockchain-based data query method provided by the above-mentioned method embodiments.
[0351] Fig.11 11 is a block diagram of a computer device 1100 provided by an exemplary embodiment of the present application. Generally, the computer device 1100 includes: a processor 1101 and a memory 1102 .
[0352] The processor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1101 may be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 1101 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 1101 may include a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1101 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0353] The memory 1102 may include one or more computer-readable storage media, which may be non-transitory. The memory 1102 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1102 is used to store at least one instruction, which is used to be executed by the processor 1101 to implement the data query method based on blockchain provided in the method embodiment of the present application.
[0354] In some embodiments, the server 1100 may also optionally include: an input interface 1103 and an output interface 1104. The processor 1101, the memory 1102, and the input interface 1103 and the output interface 1104 may be connected via a bus or a signal line. Each peripheral device may be connected to the input interface 1103 and the output interface 1104 via a bus, a signal line or a circuit board. The input interface 1103 and the output interface 1104 may be used to connect at least one peripheral device related to input / output to the processor 1101 and the memory 1102. In some embodiments, the processor 1101, the memory 1102, the input interface 1103, and the output interface 1104 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1101, the memory 1102, the input interface 1103, and the output interface 1104 may be implemented on a separate chip or circuit board, which is not limited in the embodiments of the present application.
[0355] Those skilled in the art will appreciate that the structure shown above does not constitute a limitation on the computer device 1100 , and may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0356] In an exemplary embodiment, a chip is also provided, which includes a programmable logic circuit and / or program instructions. When the chip runs on a computer device 1100, it is used to implement the blockchain-based data query method provided in an embodiment of the present application.
[0357] In an exemplary embodiment, a computer program product is also provided, the computer program product including computer instructions, the computer instructions being stored in a computer-readable storage medium. The processor reads the computer instructions from the computer-readable storage medium, and the processor reads and executes the computer instructions from the computer-readable storage medium to implement the blockchain-based data query method provided in the embodiment of the present application.
[0358] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one program is stored, and the at least one program is loaded and executed by a processor to implement the blockchain-based data query method provided in an embodiment of the present application.
[0359] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0360] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.
[0361] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A data query method based on blockchain, characterized in that: The method is performed by a node in the blockchain, and the method includes: Receiving a query request sent by a terminal device, wherein the query request is used by the terminal device to request to query at least two digital assets of a user of the terminal device on the blockchain; Executing an aggregate query contract based on the query request to obtain a query result, wherein the aggregate query contract is a contract deployed on the blockchain for querying the at least two digital assets; The query result is sent to the terminal device, where the query result includes information of the at least two digital assets.
2. The method according to claim 1, characterized in that The executing the aggregate query contract based on the query request to obtain the query result includes: Based on the query request, the aggregate query contract calls at least two contracts to traverse and query the at least two digital assets to obtain the query result; The at least two contracts include contracts corresponding to the at least two digital assets.
3. The method according to claim 2, characterized in that The step of invoking at least two contracts to traverse and query the at least two digital assets based on the query request and obtaining the query result by the aggregate query contract includes: Based on the query request, the aggregate query contract calls the at least two contracts in the whitelist to traverse and query the at least two digital assets, and obtains the query result; Among them, the whitelist is a list of contracts corresponding to digital assets supported by the aggregate query contract for storage.
4. The method according to claim 3, characterized in that The aggregate query contract includes a first function part and a second function part; The step of invoking the at least two contracts in the whitelist through the aggregate query contract based on the query request to traverse and query the at least two digital assets to obtain the query result includes: Based on the information of the digital asset type carried in the query request, searching the data structure types of the at least two digital assets in the at least two contracts in the whitelist through the first function part; Based on the information of the digital asset type carried in the query request, information of the at least two digital assets conforming to the data structure type is acquired through the second function part.
5. The method according to claim 4, characterized in that The digital asset includes a virtual resource, the second function part includes a virtual resource function part, and the information of the digital asset type carried in the query request, obtaining the information of the at least two digital assets that conform to the data structure type through the second function part, includes: Based on the information of the digital asset type carried in the query request, obtaining the information of the virtual resource through the virtual resource function part; The information of the virtual resource includes at least one of the following: the on-chain address of the virtual resource and the quantity of the virtual resource.
6. The method according to claim 4, characterized in that The digital asset includes a digital collection, the second function part includes a digital collection function part, and the information of the digital asset type carried in the query request, obtaining the information of the at least two digital assets that conform to the data structure type through the second function part, includes: Based on the information of the digital asset type carried in the query request, obtaining the information of the digital collection through the digital collection function part; The information of the digital collection includes at least one of the following: the on-chain address of the digital collection, the digital asset identification ID of the digital collection, the quantity of the digital collection, and the number of types of the digital collection.
7. The method according to claim 6, characterized in that The digital collection function part includes a first sub-function part and / or a second sub-function part, and the obtaining of the information of the digital collection through the digital collection function part based on the information of the digital asset type carried in the query request includes at least one of the following: Based on the information of the digital asset type carried in the query request, obtaining, through the first sub-function part, the number of the digital collections and the digital asset ID of each digital collection under the first blockchain standard; Based on the information of the digital asset type carried in the query request, obtaining, through the second sub-function part, the number of types of the digital collections, the number of each type of digital collections, and the digital asset ID of each digital collection under the second blockchain standard; Among them, the first blockchain standard is a standard that only one digital collection of an off-chain digital collection asset is issued on the blockchain, and the second blockchain standard is a standard that at least one digital collection of an off-chain digital collection asset is issued on the blockchain.
8. The method according to any one of claims 4 to 7, characterized in that: The executing the aggregate query contract based on the query request to obtain the query result includes: Acquire the query result based on the information of the digital asset type carried in the query request; The information on the digital asset type includes at least one of the following: the on-chain address of the account corresponding to the user, and the type of digital asset held by the account corresponding to the user.
9. The method according to any one of claims 1 to 7, characterized in that: The receiving a query request sent by a terminal device includes: Receive the query request periodically sent by the terminal device.
10. A data query device based on blockchain, characterized in that: The device comprises: A receiving module, configured to receive a query request sent by a terminal device, wherein the query request is used by the terminal device to request to query at least two digital assets of a user of the terminal device on the blockchain; An acquisition module, configured to execute an aggregate query contract based on the query request to obtain a query result, wherein the aggregate query contract is a contract deployed on the blockchain for querying the at least two digital assets; A sending module is used to send the query result to the terminal device, where the query result includes information of the at least two digital assets.
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; the processor is used to execute the at least one program in the memory to implement the blockchain-based data query method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable 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 data query method as described in any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. The processor obtains the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to implement the blockchain-based data query method as described in any one of claims 1 to 9.