CN115640321A - Data query method and device - Google Patents

Data query method and device Download PDF

Info

Publication number
CN115640321A
CN115640321A CN202211260192.0A CN202211260192A CN115640321A CN 115640321 A CN115640321 A CN 115640321A CN 202211260192 A CN202211260192 A CN 202211260192A CN 115640321 A CN115640321 A CN 115640321A
Authority
CN
China
Prior art keywords
intelligent contract
server
contract
information
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211260192.0A
Other languages
Chinese (zh)
Inventor
王挺
李刚锐
顾费勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202211260192.0A priority Critical patent/CN115640321A/en
Publication of CN115640321A publication Critical patent/CN115640321A/en
Pending legal-status Critical Current

Links

Images

Abstract

The application discloses a data query method and device. The method comprises the following steps: the method comprises the steps that a server receives a query instruction from a terminal, wherein the query instruction is used for querying target information associated with a first intelligent contract deployed on a block chain; the server queries a relational database according to the query instruction to obtain a query result, wherein information associated with the first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on the block chain, the information associated with the first intelligent contract comprises the target information, and the query result comprises the target information; and the server sends the query result to the terminal. The method can improve the efficiency of data query under the condition of ensuring the reliability of the data query result.

Description

Data query method and device
Technical Field
The present application relates to the field of block chain technology, and in particular, to a data query method and apparatus.
Background
The block chain technology is a technical scheme for collectively maintaining a reliable database in a decentralized and trust-removing mode, and is a bottom layer technology of digital currencies such as bitcoin, ethernet currency and the like. In other words, blockchain technology refers to a way for people to participate in billing. And the transaction confirmation on the blockchain is completed by the consensus of all the nodes on the blockchain, and the block is packed and written after the consensus is successful. The blockchain maintains a common ledger for storing all transactions on the blockchain network.
The blockchain 2.0 implements a more complex distributed Contract record, represented by etherhouses, namely a Smart Contract (Smart Contract). An intelligent contract is a computer protocol intended to propagate, validate or execute contracts in an informational manner. An intelligent contract is a set of digitally defined commitments that govern digital assets and that contain the rights and obligations promised by contract participants, which are automatically executed by a computer system. The contracts are recorded in a blockchain, and once the trigger condition of the contracts is met, the predefined code logic can be executed autonomously, and the executed result is that the chain cannot be changed. After the intelligent contract is executed on the blockchain, the data associated with the transaction can be queried from the ledger maintained by the blockchain, and the data associated with the transaction can be analyzed to obtain the specific situation of the transaction and the like. In the conventional technology, a block chain bottom platform generally adopts a storage structure of key-value to store an account book, and the storage method has the following characteristics: extremely efficient reading and writing, and difficult to support complex logic queries. Based on the storage mode, when the data of the account book maintained by the block chain is queried and analyzed, the problem of low data query efficiency exists.
Therefore, a data query method is needed, which can improve the efficiency of data query while ensuring the reliability of the data query result.
Disclosure of Invention
The application provides a data query method and a data query device, and the method can improve the efficiency of data query under the condition of ensuring the reliability of a data query result.
A first aspect of an embodiment of the present application provides a data query method, where the method includes: the method comprises the steps that a server receives a query instruction from a terminal, wherein the query instruction is used for querying target information associated with a first intelligent contract deployed on a block chain; the server queries a relational database according to the query instruction to obtain a query result, wherein information associated with the first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on the block chain, the information associated with the first intelligent contract comprises the target information, and the query result comprises the target information; and the server sends the query result to the terminal.
Optionally, in some implementations, before the server queries the relational database according to the query instruction, the method further includes: the server acquires the block from the block chain according to a preset period; the server analyzes the block to obtain information associated with the first intelligent contract; and the server updates the initial relational database according to the information associated with the first intelligent contract to obtain the relational database.
Optionally, in another implementation manner, the analyzing, by the server, the block to obtain the information associated with the first intelligent contract includes: the server analyzes the block to obtain receipt information of the transaction corresponding to the first intelligent contract, wherein the receipt information comprises a contract address of an event occurrence associated with the transaction corresponding to the first intelligent contract, a first hash value of the event associated with the transaction corresponding to the first intelligent contract, and event content associated with the transaction corresponding to the first intelligent contract; the server determines that a contract address of an intelligent contract recorded in an intelligent contract information table is matched with a contract address of an event occurrence associated with a transaction corresponding to the first intelligent contract, wherein the server locally stores the intelligent contract information table, and the contract address of any intelligent contract represents an address of any intelligent contract deployed in a block chain; the server determines that the first hash value is matched with a second hash value of a preset event; and the server analyzes the event content associated with the transaction corresponding to the first intelligent contract to obtain the information associated with the first intelligent contract.
Optionally, in further implementations, before the server updates the initial relational database according to the information associated with the first intelligent contract, the method further includes: the server creates an initial digital currency information table in the initial relational database according to a first preset query requirement, wherein the initial digital currency information table is used for recording a first mapping relation, and the first mapping relation is a mapping relation among a contract address of an intelligent contract, digital currency included by the intelligent contract and application binary interface information for calling the digital currency included by the intelligent contract; the server creates an initial user information table in the initial relational database according to a second preset query requirement for recording a second mapping relation, wherein the second mapping relation is a mapping relation among digital currency included in the intelligent contract, a contract address of the intelligent contract, user information holding the digital currency included in the intelligent contract and the number of the digital currency included in the intelligent contract held by the user information; wherein the contract address of the intelligent contract represents an address of the intelligent contract deployed in a blockchain.
Optionally, in another implementation manner, the updating, by the server, the initial relational database according to the information associated with the first intelligent contract to obtain the relational database includes: the server updates the initial user information table according to a third mapping relation to obtain a user information table, wherein the relational database comprises the user information table, the information associated with the first intelligent contract comprises the third mapping relation, and the third mapping relation is a mapping relation among the digital currency included in the first intelligent contract, the contract address of the first intelligent contract, first user information holding the digital currency included in the first intelligent contract, and the number of digital currencies included in the first intelligent contract held by the first user information; or the server updates the initial digital currency information table according to a fourth mapping relation to obtain a digital currency information table, wherein the relational database includes the digital currency information table, the information associated with the first intelligent contract includes the third mapping relation and the fourth mapping relation, and the fourth mapping relation is a mapping relation between a contract address of the first intelligent contract, the digital currency included in the first intelligent contract, and the application binary interface information for calling the digital currency included in the first intelligent contract.
Optionally, in another implementation manner, the querying, by the server, the relational database according to the query instruction to obtain a query result includes: the server inquires the digital currency information table stored in the relational database according to the contract address of the first intelligent contract included in the inquiry instruction to obtain at least one digital currency included in the first intelligent contract, wherein the target information includes the at least one digital currency included in the first intelligent contract; or the server queries the digital currency information table stored in the relational database according to the contract address of the first intelligent contract included in the query instruction, and obtains application binary interface information for calling at least one digital currency included in the first intelligent contract, wherein the target information includes the application binary interface information for calling the at least one digital currency included in the first intelligent contract; or the server inquires the user information table stored in the relational database according to the address of the user included in the inquiry instruction, and obtains the user information of the at least one digital currency included in the first intelligent contract, wherein the target information includes the user information of the at least one digital currency included in the first intelligent contract.
Optionally, in other implementations, after the server updates the initial relational database according to the information associated with the first intelligent contract, the method further includes: the server receiving a transaction request from the terminal, wherein the transaction request is used for requesting to execute transaction on at least one digital currency included in the first intelligent contract; the server then sends the transaction request to each blockchain node in the blockchain network, so that each blockchain node executes the transaction requested by the transaction request to the first intelligent contract deployed on the blockchain.
Optionally, in other implementations, the digital currency is a non-homogeneous token NFT and the blockchain is a federation blockchain.
A second aspect of the embodiments of the present application provides a data query apparatus, including: the receiving and sending unit is used for receiving an inquiry instruction from a terminal, wherein the inquiry instruction is used for inquiring target information associated with a first intelligent contract deployed on a block chain; the processing unit is configured to query a relational database according to the query instruction to obtain a query result, where information associated with the first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on the block chain, the information associated with the first intelligent contract includes the target information, and the query result includes the target information; the transceiver unit is further configured to send the query result to the terminal.
A third aspect of the embodiments of the present application further provides a data query device, including: a memory and a processor, the memory and the processor being coupled.
Wherein the memory is configured to store one or more computer instructions.
The processor is configured to execute one or more computer instructions to implement the data query method according to the first aspect.
The fourth aspect of the embodiments of the present application further provides a computer-readable storage medium, on which one or more computer instructions are stored, where the computer-readable storage medium is characterized in that the computer-readable storage medium is executed by a processor to implement the data query method according to any one of the above technical solutions.
According to the technical scheme provided by the embodiment of the application, a server receives a query instruction from a terminal, wherein the query instruction is used for querying target information associated with a first intelligent contract deployed on a block chain; the server queries the relational database according to the query instruction to obtain a query result, wherein information associated with a first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on a block chain, the information associated with the first intelligent contract comprises target information, and the query result comprises the target information; and the server sends the query result to the terminal. In the data query process, the server queries the information associated with the first intelligent contract stored in the relational database according to the query instruction so as to obtain a query result corresponding to the query instruction. The relational database is a database supporting complex logic query, and the information associated with the first intelligent contract stored in the relational database is determined by analyzing the content obtained by the blocks on the block chain, so that the information associated with the first intelligent contract recorded in the relational database is consistent with the information associated with the first intelligent contract recorded in the blocks on the block chain, and the reliability of the obtained query result can be ensured. The data query method avoids the problems that in the traditional technology, when the blocks on the block chain are directly queried according to the query instruction, the blocks on the block chain need to be analyzed for multiple times, and the query content requested by the query instruction is determined according to the analyzed content and the query instruction after the multiple times of analysis, so that the query with complex logic is difficult to support, and the query efficiency is low. In summary, the data query method provided by the embodiment of the present application can improve the efficiency of data query while ensuring the reliability of the data query result.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive exercise.
Fig. 1 is a schematic diagram of an application scenario applicable to the data query method provided in the embodiment of the present application.
Fig. 2 is a schematic diagram of the server 130 in the application scenario shown in fig. 1.
Fig. 3 is a schematic diagram of a data query method provided in an embodiment of the present application.
Fig. 3A is a schematic diagram of a method for creating a relational database described in the data query method illustrated in fig. 3 according to an embodiment of the present application.
Fig. 4 is a schematic diagram of another data query method provided in the embodiment of the present application.
Fig. 5 is a schematic structural diagram of a data query device according to an embodiment of the present application.
Fig. 6 is a schematic structural diagram of a data query device according to an embodiment of the present application.
Detailed Description
In order to enable those skilled in the art to better understand the technical solutions of the present application, the present application is clearly and completely described below with reference to the drawings in the embodiments of the present application. This application is capable of embodiments in many different forms than those described above and it is therefore intended that all such other embodiments, which would be within the scope of the present application and which are obtained by a person of ordinary skill in the art based on the embodiments provided herein without the exercise of inventive faculty, be covered by the present application.
It should be noted that the terms "first," "second," "third," and the like in the claims, the description, and the drawings of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. The data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in other sequences than described or illustrated herein. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For ease of understanding, first, technical terms that may be referred to in the embodiments of the present application are briefly described.
1, ether house (Ethereum)
An etherhouse is a common blockchain platform with intelligent contract functionality. Through intelligent contract functionality provided by etherhouses, developers can build a wide variety of decentralized applications on blockchains.
2, intelligent contract
An intelligent contract is essentially a program that can be automatically executed if conditions agreed upon in advance by the contract creator are met. The intelligent contract makes the transaction process be definite, the transaction result be irreversible, and the two parties can trust each other without third party notarization.
In an etherhouse, an intelligent contract specifies a set of code and data that exists at a particular address created by an external account or other contract account number. After a user writes an intelligent contract using a high-level language (e.g., such as Solidity), the intelligent contract needs to be compiled into bytecode that can be run by an Ethernet Virtual Machine (EVM) and deployed on an ethernet house in a manner that initiates a transaction. After the contract is deployed, the user can call a method in the intelligent contract by sending a transaction to the contract address, so that the function preset by a contract creator is realized. The method in the intelligent contract is executed only through transaction invocation, and can be invoked directly by transactions initiated by external accounts or indirectly by internal transactions triggered by other contract accounts. While the contract code cannot be modified after deployment, the operation code that executes the EVM on the contract by initiating a transaction may delete the contract code.
3, block chain (Blockchain)
A block chain refers to a chain of blocks one after another. Each block holds certain information, which are linked in a chain according to a respective generated time sequence. This chain is maintained in all servers, and as long as one server can work in the entire system, the entire blockchain is secure. These servers, referred to in the blockchain system as blockchain nodes (simply referred to as nodes), provide storage space and computational support for the entire blockchain system. If the information in the block chain is to be modified, more than half of the nodes must be authenticated and the information in all the nodes must be modified, and the nodes are usually held in different hands of different subjects, so that the information in the block chain is extremely difficult to tamper with. Compared with the traditional network, the block chain has two core characteristics: firstly, data is difficult to tamper, and secondly, decentralization is performed. Based on the two characteristics, the information recorded by the block chain is more real and reliable, and the problem that people are not trusted each other can be solved.
Blockchains are generally divided into three types: public Block Chains (Public Block Chains), alliance Block Chains (Consortium Block Chains), and Private Block Chains (Private Block Chains). Wherein, the definition of the public block chain is as follows: any individual or group in the world can send a transaction and the transaction can be validated against the blockchain, and anyone can participate in their consensus process. The federation blockchain is defined as follows: a plurality of preselected nodes are designated as bookkeepers by a group, the generation of each block is determined by all the preselected nodes (the preselected nodes participate in the consensus process), other access nodes can participate in the transaction, but the bookkeeping process is not too late (the bookkeeping process is still managed, only distributed bookkeeping is performed, the number of the preselected nodes is determined, how much bookkeepers of each block become a main risk point of the block chain is determined), and any other person can perform limited query through an API opened by the block chain. The private block chain is defined as follows: the block chain general ledger technology is only used for accounting, and the block chain general ledger technology can be a company or an individual and can solely share the writing authority of the block chain.
4, blockchain Account
The three major elements of the blockchain account include: a private key (abbreviated as private key), a public key (abbreviated as public key), and an address.
The private and public keys are the content of asymmetric cryptographic algorithms in cryptography. The public key is made public, while the private key is kept secure. The private key is generated from a random seed, and the public key is derived from the private key through an algorithm. Since the public key is too long, an "address" appears for simplicity and practicality, and the address is derived from the public key. These deductions are unidirectional and irreversible. That is, the public key cannot be derived from the address, and the private key cannot be derived from the public key.
Non-homogeneous tokens (Non-funnible Token, NFT)
NFT is also known as non-homogeneous syndrome. NFT generally refers to tokens issued by developers on an etherhouse platform according to the ERC-721 standard/protocol. NFT is a unique digital asset whose properties are indivisible, irreplaceable, and unique. NFT can value most of the real world objects under the link, such as book text, electronic certificates, electronic tickets, art collections, props in online games, etc. abstract objects.
Because the NFT is implemented by smart contracts, the NFT has versatility, invariance, and programmability, i.e., anyone can deploy the NFT's smart contracts according to published standards, and the NFT can contain more complex functionality. In theory, any article in real life can be anchored as NFT, but NFT published on a blockchain network needs to meet a certain publishing standard, and the publishing standards corresponding to different blockchain platforms are different.
Application Binary Interface (ABI)
ABI is the API of an intelligent contract. In short, an API is an interface between programs and interactions between the programs. This interface contains the functions, variables, etc. that the program needs to provide external access to. ABI is also an interface for interaction between programs, but programs are compiled binary codes. The same interface, but passing information in binary format. In summary, ABI describes how to encode or decode binary (binary) information that is passed between programs.
7,NFT metadata
The metadata of the NFT is information on various attributes of the object indicated by the NFT. For example, the metadata of an NFT may be attribute information of a drawing. For example, the metadata of an NFT may be attribute information of characters in a game.
8, transaction (transaction)
Transactions in a blockchain, generally referred to as commands and data sent to the blockchain, will alter the data and state on the blockchain.
9, NTF Identification (ID),
NFT ID, abbreviated as tokenId. Identified in the smart contract by a unique agent 265, each NFT ID is not allowed to change during the life cycle of the smart contract.
10 consensus mechanism
The consensus mechanism is that the verification and confirmation of the transaction is completed in a short time through the voting of a special node. For a transaction in a block chain, if several nodes with irrelevant benefits can achieve consensus, we can consider that the whole network can achieve consensus. Common consensus mechanisms include: a Proof of Work (POW), a Proof of stock (POS), a Practical Byzantine Fault-tolerant algorithm (PBFT), etc.
Hereinafter, an application scenario, a data query method, a data query apparatus, and a device suitable for the data query method according to the embodiments of the present application will be described in detail with reference to the accompanying drawings. It is to be understood that the embodiments and features of the embodiments described below may be combined with each other without conflict between the embodiments provided in the present application. In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited. First, an application scenario of the data query method applicable to the embodiment of the present application is described with reference to the drawings.
Fig. 1 is a schematic diagram of an application scenario applicable to the data query method provided in the embodiment of the present application. Illustratively, the application scenario as shown in fig. 1 includes: user 110, client 120, server 130, database 140, and blockchain cluster 150. Optionally, the application scenario may also include a greater number of users, clients, or servers. The client 120 and the server 130 may be connected in a wired manner, or may be connected in a wireless manner (e.g., bluetooth (bluetooth) or wireless communication technology (WIFI)), which is not limited in this application.
An application may be installed and run on client 120. User 110 may conduct various services related to blockchain cluster 150 through client 120 and server 130, for example, user 110 may deploy an intelligent contract, query information associated with the intelligent contract, invoke the intelligent contract, and the like on a blockchain commonly maintained by a plurality of blockchain nodes included in blockchain cluster 150 through client 120 and server 130. The presentation form of the client 120 is not particularly limited. For example, the client 120 may be, but is not limited to, a personal computer, a smart phone, a tablet computer, a desktop computer, a wearable device, or the like.
The server 130 may be a server having the capability of transceiving, analyzing and processing data. In some implementations, the server 130 includes the functionality of the server 130 shown in fig. 2. Referring to fig. 2, an NFT block chain service 131 is deployed in the service end 130, and the NFT block chain service 131 has the following functions: NFT smart contract opening 1311, NFT smart contract management 1312, NFT transactions 1313, and NFT data export 1314. The NFT smart contract provisioning 1311 is configured to create an NFT smart contract, and send the created NFT smart contract to each block chain node included in the block chain cluster 150, so that each block chain node successfully deploys the NFT smart contract to a block chain commonly maintained by the block chain node. NFT intelligent contract management 1312 is used to manage NFT intelligent contracts, for example, record the contract address and the like of the NFT intelligent contract. The NFT transaction 1313 is used to process a transaction request received from a client, for example, forward the transaction request received from the client to any one of the blockchain nodes included in the blockchain cluster 150. The NFT data derivation 1314 is configured to derive, from any one of the blockchain nodes included in the blockchain cluster 150, the blockchain data stored in the any one of the blockchain nodes, and parse the derived blockchain data to obtain a parsing result. The server 130 may send the result obtained by parsing the NFT data export 1314 to the database 150 for storage through the communication interface. Optionally, the server 130 may also have a memory and a processor. The processor of the server 130 may be a Central Processing Unit (CPU). Optionally, the server 130 may further include one or more of a Graphics Processing Unit (GPU), a neural Network Processing Unit (NPU), and a Field Programmable Gate Array (FPGA), and the memory of the server 130 may be a Random Access Memory (RAM) or a solid-state drive (SSD), and other devices or memory instances having a storage capability. A solid-state drive may also be referred to as a solid-state drive (SSD). The form of the server 130 is not particularly limited. The server 130 may be hardware or software. When the server 130 is hardware, it may be implemented as a distributed server cluster composed of multiple servers, or may be implemented as a single server. When the server 130 is software, it may be implemented as a plurality of software or software modules (for example, software or software modules for providing distributed services), or may be implemented as a single software or software module. The embodiment of the present application is not particularly limited to this.
The database 140 is a database supporting complex data queries, and the following information may be stored in the database 140: the server 130 processes (e.g., parses) the data obtained after the processing of the blockchain data stored at each blockchain node included in the blockchain cluster 150. The database 140 is a database that the server 130 has access to. For example, the database 140 may be a local database of the server 130, or may also be a remote database of the server 130. Note that, when the database 140 is a remote database of the server 130, it is a local database of a device other than the server 130. It should also be understood that the database 140 is not a database in a blockchain network, i.e., the database 140 is a down-link database. In the embodiment of the present application, the database 140 is also called a downlink database.
The blockchain cluster 150 includes a plurality of blockchain nodes, any two blockchain link points of the plurality of blockchain nodes may communicate to enable data interaction. Illustratively, the blockchain cluster 150 shown in fig. 1 includes 5 blockchain nodes, i.e., blockchain link points i, i =1,2,3,4,5. Optionally, the blockchain cluster 150 may further include a greater (e.g., 10) or lesser (e.g., 2) number of blockchain nodes, which is not particularly limited. A blockchain node refers to an intelligent device connected to a blockchain network. The blockchain cluster 150 includes a blockchain commonly maintained by a plurality of blockchain nodes, and NFT smart contracts created by the server 130 are deployed in the blockchain. Any one blockchain node included in blockchain cluster 150 may execute a transaction requested by a transaction request according to the transaction request on the NFT smart contract deployed in the commonly maintained blockchain.
Optionally, the wireless network or wired network described above uses standard communication techniques and/or protocols. The network is typically the internet, but can be any network including, but not limited to, a Local Area Network (LAN), a Metropolitan Area Network (MAN), a Wide Area Network (WAN), a mobile, wired or wireless network, a private network, or any combination of virtual private networks. In some embodiments, data exchanged over a network is represented using techniques and/or formats including hypertext markup language (HTML), extensible markup language (XML), and the like. In addition, all or some of the links can be encrypted using conventional encryption techniques such as Secure Socket Layer (SSL), transport Layer Security (TLS), virtual Private Network (VPN), internet protocol security (IPsec), and the like. In other embodiments, custom and/or dedicated data communication techniques can also be used in place of or in addition to the data communication techniques described above.
It should be understood that fig. 1 is only an illustration and does not constitute any limitation to an application scenario to which the data query method provided in the present application is applicable. Fig. 2 is only an illustration, and does not set any limit to the server side applicable to the data query method provided in the present application. Optionally, the service end 130 shown in fig. 2 may also have other functions besides the NFT blockchain service 131.
In the application scenario shown in fig. 1, each of the blockchain nodes included in the blockchain cluster 150 may deploy NFT smart contracts in blockchains commonly maintained by the respective blockchain nodes according to the needs of the users 110. An NFT smart contract is a contract that specifies a transaction (e.g., transfer, casting, or destruction) on a blockchain for an NFT included in the NFT smart contract. For example, an NFT included in an NFT smart contract may represent, but is not limited to, any of the following items: book characters in the real world, musical works or props in online games, etc. After the NFT smart contract is successfully deployed in the blockchain commonly maintained by each blockchain link point included in the blockchain cluster 150, the NFT indicated by the NFT smart contract deployed in the blockchain commonly maintained by each blockchain link point may be traded according to the trading demand of other users in the network. After a transaction is performed on the NFT indicated by the NFT smart contract in each blockchain node, information associated with the transaction is recorded in blockchain data stored in each blockchain node. Thereafter, a user in the network (e.g., user 110) may send a query request to each of the blockchain nodes included in blockchain cluster 150 to obtain information associated with the NFT intelligence contract for the query requested by the query request.
In the conventional block chain technology, data is permanently stored in a block form, and is sequentially generated one by one according to time sequence and connected into a chain, and transaction information occurring at corresponding time is recorded in each block. In order to ensure efficient data storage and query of the blockchain, the blockchain underlying platform generally adopts a storage structure of key-value to store data. The storage mode has the advantage of extremely high reading and writing efficiency, but the storage mode is difficult to support the inquiry of part of specific conditions or the inquiry of complex logic. Specifically, based on the underlying storage of the key-value, historical data of the business primary key (key) is stored in the distributed ledger, and the current latest state data (value) of the business primary key (key) is stored in the state base. The state data (value) is generally in the JSON format, and meanwhile, the attribute in the JSON format is generated in a service provider, so the attribute in the JSON format is not fixed for a bottom link, which results in that an upper service provider based on the bottom link cannot query the corresponding data record through the condition in the JSON-value, and therefore, the current bottom link technology cannot directly support complex query, thereby greatly limiting the service use scene of the bottom link. In addition, when a query is performed based on such a storage structure, performance (e.g., data query performance or transaction performance) of a blockchain node storing the blockchain is also affected.
The conventional etherhouse standard (e.g., ERC721 standard or ERC1155 standard) provides and supports a simple query interface. For example, the query interface may be used to query holder users of a certain NFT included in the NFT smart contract deployed on the blockchain, or to query the number of NFTs held by a certain holder user included in the NFT smart contract deployed on the blockchain. The query interface defined in the above standard is also not satisfied when the query condition indicated by the query request sent by the user is complicated (for example, the query request indicates to query the list of holders holding the NFT included in the NFT smart contract).
Therefore, the present application provides a data query method and apparatus to solve the existing problems.
Fig. 3 is a schematic diagram of a data query method provided in an embodiment of the present application. The data query method provided by the embodiment of the application can be applied to the application scenario shown in fig. 1. For example, the server illustrated in fig. 3 may be the server 130 illustrated in fig. 2, the terminal illustrated in fig. 3 may be the client 120 illustrated in fig. 2, and the user illustrated in fig. 3 may be the user 110 illustrated in fig. 2. As shown in fig. 3, the data query method provided in the embodiment of the present application includes S310 to S330. Next, details of S310 to S330 will be described.
S310, the server receives an inquiry instruction from the terminal, wherein the inquiry instruction is used for inquiring target information associated with the first intelligent contract deployed on the block chain.
The block chain is a block chain commonly maintained by a plurality of block chain link points included in a block chain cluster, and the block chain includes a plurality of blocks. For example, taking the application scenario shown in fig. 1 as an example, the blockchain may be a blockchain commonly maintained by 5 blockchain nodes included in the blockchain cluster 150. The type of block chain is not particularly limited. For example, the blockchain may be a public blockchain, a federation blockchain, or a private blockchain.
A first intelligent contract is deployed on the blockchain, and an address of the first intelligent contract, which is called a contract address of the first intelligent contract, is deployed on the blockchain. Optionally, before performing the above S310, the following steps may be further performed: the plurality of blockchain nodes included in the blockchain cluster deploy the first intelligent contract on the blockchain. The method of deploying the first intelligent contract on the blockchain is not particularly limited. Illustratively, a method of deploying the first intelligent contract on the blockchain comprises: the server generates a first intelligent contract code corresponding to a creation request according to the creation request sent by the terminal; the server sends the first intelligent contract code to a plurality of blockchain nodes included in the blockchain cluster; the plurality of block chain link points included in the block chain cluster agree on the received first intelligent contract code; each block chain link point included in the block chain cluster executes the transaction of the first intelligent contract related to the first intelligent contract code and creates a corresponding contract account; and each blockchain node included in the blockchain cluster creates a contract address for the contract account according to the same rule, the contract address created by each blockchain node for the first intelligent contract is the same, and the address is the address in the blockchain. In this way, the first intelligent contract is successfully deployed into the block chain commonly maintained by the plurality of block chain link points included in the block chain cluster. The type of the first smart contract is not particularly limited. Optionally, in the above example, the server may also create an intelligent contract information table locally, where the intelligent contract information table is used to record the following: the method comprises the steps of obtaining a contract address of a server-created intelligent contract, a blockchain identification of server-created intelligent contract deployment, and ABI information for calling data to be traded, wherein the server-created intelligent contract comprises the ABI information. In some implementations, the first smart contract is a smart contract associated with digital currency. For example, the first smart contract may be an NFT smart contract generated according to the ethernet standard protocol, and the NFT smart contract includes at least one NFT that may correspond to, but is not limited to, a drawing or a musical work in the real world, and the like. The ethernet standard protocol may be the ERC721 standard or the ERC1155 standard.
The target information associated with the first intelligent contract may be information associated with the first intelligent contract, or may be part of the information associated with the first intelligent contract, which is not particularly limited. The content of the target information associated with the first smart contract is not particularly limited. In some implementations, the target information is user information associated with the first smart contract. For example, the user information includes an address of a user holding the data to be traded included in the first intelligent contract. In other implementations, the target information is information of data to be traded associated with the first intelligent contract. For example, the first intelligent contract is an NFT intelligent contract, and the target information may be a type and a number of the NFT included in the NFT intelligent contract and ABI information for invoking the NFT.
The implementation manner of the server receiving the query instruction from the terminal is not particularly limited. For example, the terminal may actively send the query instruction to the server. For another example, after the terminal receives the trigger instruction sent by the server, the terminal sends an inquiry instruction to the server.
And S320, the server queries the relational database according to the query instruction to obtain a query result, wherein the information associated with the first intelligent contract stored in the relational database is determined by the content obtained by analyzing the blocks on the block chain, the information associated with the first intelligent contract comprises target information, and the query result comprises the target information.
A relational database, which is a database supporting complex logical queries, in which data may be stored in a table structure. The relational database is a relational database accessible by the server. The relational database that the server can access may be a relational database local to the server, or may be a relational database remote from the server, which is not specifically limited in this embodiment of the application. When the database is a relational database remote from the server, the one relational database may be a local relational database of a device other than the server. The relational database is not particularly limited. For example, the relational database may be a MySQL database or an Oracle database, or the like.
In the above step S320, the information associated with the first intelligent contract stored in the relational database is determined by analyzing the blocks in the blockchain. That is, the step of creating the relational database may be further performed before performing S320. Fig. 3A shows the steps provided by the embodiment of the present application to obtain the relational database before performing S320 described above. Referring to fig. 3A, S301 to S303 are included. S301 to S303 are described in detail below.
S301, the server obtains the blocks from the block chain according to a preset period.
The cycle length of the preset cycle is not particularly limited. In practical application, the period length of the preset period can be selected according to requirements. For example, the preset period may be 1 minute or 2 minutes, etc.
S302, the server analyzes the block to obtain information associated with the first intelligent contract.
The analyzing, by the server, the block to obtain the information associated with the first intelligent contract may include the following steps: the server analyzes the block to obtain receipt information of the transaction corresponding to the first intelligent contract, wherein the receipt information comprises a contract address of an event related to the transaction corresponding to the first intelligent contract, a first hash value of the event related to the transaction corresponding to the first intelligent contract and event content related to the transaction corresponding to the first intelligent contract; the server determines that a contract address of an intelligent contract recorded in an intelligent contract information table is matched with a contract address of an event occurrence corresponding to a transaction related to a first intelligent contract, wherein the intelligent contract information table is locally stored in the server, and the contract address of any intelligent contract represents an address of any intelligent contract deployed in a block chain; the server determines that the first hash value is matched with a second hash value of a preset event; the server analyzes the event content associated with the transaction corresponding to the first intelligent contract to obtain the information associated with the first intelligent contract. In some implementations, when the first smart contract is an NFT smart contract, the second hash value of the preset event may be a hash value of a transfer event specified in the ERC-721 standard, or may be a hash value of a transfer event specified in the ERC-1155 standard. Table 4 below shows the hash values of the transfer events specified in the ERC-721 standard and the ERC-1155 standard, and specific reference may be made to the contents shown in table 4 below, which are not described in detail herein. In the above implementation manner, the server may perform the step of determining whether the first hash value and the second hash value are matched only when it is determined that the contract address of the intelligent contract recorded in the intelligent contract information table matches the contract address of the event occurrence associated with the transaction corresponding to the first intelligent contract. The contract address of the intelligent contract recorded in the intelligent contract information table is matched with the contract address of the event occurrence associated with the transaction corresponding to the first intelligent contract, namely the first intelligent contract is the intelligent contract managed by the server. Therefore, the server can be prevented from processing the intelligent contract which is not managed by the server, and resource consumption of the server is reduced.
And S303, the server updates the initial relational database according to the information associated with the first intelligent contract to obtain the relational database.
The above-mentioned S303 is configured to update the initial relational database according to the information associated with the first intelligent contract, and obtain the relational database. Before performing S303 described above, the server may create an initial relational database. In some implementations, when the first intelligent contract is a digital currency intelligent contract, the server creates an initial relational database comprising: the server creates an initial digital currency information table in an initial relational database according to a first preset query requirement, wherein the initial digital currency information table is used for recording a first mapping relation, and the first mapping relation is a mapping relation among a contract address of an intelligent contract, digital currency included by the intelligent contract and application program binary interface information for calling the digital currency included by the intelligent contract; the server creates an initial user information table in the initial relational database according to a second preset query requirement, wherein the initial user information table is used for recording a second mapping relation, and the second mapping relation is a mapping relation among digital currency included by the intelligent contract, a contract address of the intelligent contract, user information of the digital currency included by the intelligent contract and the number of the digital currency included by the intelligent contract held by the user information; wherein the contract address of the intelligent contract represents the address of the intelligent contract deployed in the block chain. Illustratively, the steps associated with the server creating the initial digital money information table and creating the initial user information table are described in detail in S402 below. The NFT information table and the updated NFT information table in S402 below are both equivalent to the initial digital currency information table, and the NFT holding user table and the updated NFT holding user table in S402 below are both equivalent to the initial user information table, and details that are not described herein may be referred to in the related description in S402 below. It can be understood that the first mapping relationship is associated with a first preset query requirement, and the second mapping relationship is associated with a second preset query requirement. In the embodiment of the present application, the first mapping relationship and the second mapping relationship are not specifically limited. Optionally, in another implementation manner, the first mapping relationship may also be a mapping relationship between a contract address of the intelligent contract and digital currency included in the intelligent contract; the second mapping relationship may also be a mapping relationship between digital currency included in the intelligent contract, a contract address of the intelligent contract, and user information holding the digital currency included in the intelligent contract.
Executing the step S303, that is, the server updates the initial relational database according to the information associated with the first intelligent contract, to obtain the relational database, where the step S includes: the server updates the initial user information table according to a third mapping relation to obtain a user information table, wherein the relational database comprises the user information table, the information associated with the first intelligent contract comprises the third mapping relation, and the third mapping relation is the mapping relation among the digital currency included in the first intelligent contract, the contract address of the first intelligent contract, the first user information holding the digital currency included in the first intelligent contract, and the number of the digital currencies included in the first intelligent contract held by the first user information; or the server updates the initial digital currency information table according to a fourth mapping relation to obtain the digital currency information table, wherein the relational database comprises the digital currency information table, the information associated with the first intelligent contract comprises a third mapping relation and a fourth mapping relation, and the fourth mapping relation is a mapping relation among the contract address of the first intelligent contract, the digital currency included in the first intelligent contract and the application binary interface information for calling the digital currency included in the first intelligent contract. For example, S411 below shows a step of updating, by the server, the updated NFT information table and/or the updated NFT holding table again, where the updated NFT information table in S411 below is the initial user information table, and the updated NFT holding table in S411 below is the initial digital currency information table. What is not described in detail here can be referred to the relevant description in S411 below.
Optionally, in some implementations, after the server updates the initial relational database according to the information associated with the first intelligent contract, the server may further perform the following steps: the server receives a transaction request from the terminal, wherein the transaction request is used for requesting to execute transaction (such as transfer, casting or destruction) on at least one digital currency included in the first intelligent contract; under the condition that the event content related to the transaction requested by the transaction request is matched with the third mapping relation recorded in the user information table and the event content related to the transaction requested by the transaction request is matched with the fourth mapping relation recorded in the digital currency information table, the server sends the transaction request to each block chain node in the block chain network so that each block chain node executes the transaction requested by the transaction request on the first intelligent contract arranged on the block chain. In the above implementation, in the case that the transaction request is determined to be valid, the server may send the transaction request to each blockchain node in the blockchain network, so that each blockchain node executes the transaction requested by the transaction request to the first intelligent contract disposed on the blockchain. Therefore, invalid transaction requests can be prevented from being linked up, and further, the influence on the performance of the blockchain node where the blockchain is located due to too many invalid transaction requests being linked up can be avoided.
In this embodiment, the server performs the above S301 to S303, that is, the server continuously derives the tile data from the tile chain, and updates the initial relational database according to the result of the tile data analysis to obtain the relational database, so as to maintain the content stored in the relational database to be consistent with the content of the tile data on the tile chain. In the subsequent data query process, the server can rapidly query the related entries recorded in the relational database so as to query the information related to the first intelligent contract deployed on the block chain.
In some implementations, the step S320 is executed, in which the server queries the relational database according to the query instruction to obtain a query result, where the step S includes: the server inquires a digital currency information table stored in the relational database according to a contract address of the first intelligent contract, wherein the contract address is included in the inquiry instruction, and at least one digital currency included in the first intelligent contract is obtained, and the target information includes the at least one digital currency included in the first intelligent contract; or the server inquires a digital currency information table stored in the relational database according to a contract address of the first intelligent contract included in the inquiry instruction to obtain application program binary interface information for calling at least one digital currency included in the first intelligent contract, wherein the target information includes the application program binary interface information for calling the at least one digital currency included in the first intelligent contract; or the server inquires a user information table stored in the relational database according to the address of the user included in the inquiry instruction to obtain the user information of the at least one digital currency included in the first intelligent contract, wherein the target information includes the user information of the at least one digital currency included in the first intelligent contract.
S330, the server sends the query result to the terminal. Correspondingly, the terminal receives the query result from the server.
It should be understood that the data query method shown in fig. 3 is only an illustration, and does not constitute any limitation on the data query method provided in the embodiment of the present application.
In the embodiment of the application, the server queries the information associated with the first intelligent contract stored in the relational database according to the query instruction to obtain a query result corresponding to the query instruction. The relational database is a database supporting complex logic query, and the information associated with the first intelligent contract stored in the relational database is determined by analyzing the blocks on the block chain, so that the information associated with the first intelligent contract recorded in the relational database is consistent with the information associated with the first intelligent contract recorded in the blocks on the block chain, and the reliability of the obtained query result can be ensured. The data query method avoids the problems that in the traditional technology, when the blocks on the block chain are directly queried according to the query instruction, the blocks on the block chain need to be analyzed for multiple times, and the query content requested by the query instruction is determined according to the analyzed content and the query instruction after the multiple times of analysis, so that the query with complex logic is difficult to support, and the query efficiency is low. In summary, the data query method provided by the embodiment of the present application can improve the efficiency of data query while ensuring the reliability of the data query result.
Next, another data query method provided by the present application is described with reference to fig. 4. It is understood that the data query method described in fig. 4 is a specific example of the data query method described in fig. 3 above. Specifically, the first intelligent contract described in fig. 3 is the intelligent contract 1 described in fig. 4, the relational database described in fig. 3 is the database 1 described in fig. 4, the digital currency information table described in fig. 3 is the NFT information table described in fig. 4, and the user information table described in fig. 3 is the NFT holding user table described in fig. 4.
Fig. 4 is a schematic diagram of another data query method provided in the embodiment of the present application. It should be understood that the example of fig. 4 is only for assisting the person skilled in the art in understanding the embodiments of the present application, and is not intended to limit the embodiments of the present application to the specific values or specific scenarios illustrated. It will be apparent to those skilled in the art that various equivalent modifications or variations are possible in light of the example of fig. 4 given below, and such modifications and variations also fall within the scope of the embodiments of the present application. As shown in fig. 4, the method includes S401 to S413. Next, S401 to S413 are described in detail.
S401, the terminal sends a create request 1 to the server. Accordingly, the server receives the creation request 1 sent by the terminal.
For example, when the application scenario of the method shown in fig. 4 is the application scenario shown in fig. 1, the terminal described in fig. 4 may be the client 120 shown in fig. 1, the server described in fig. 4 may be the server 130 shown in fig. 1, and the blockchain cluster 1 described in fig. 4 may be the blockchain cluster 150 shown in fig. 1, where the blockchain cluster 150 may include only two blockchain nodes, and the two blockchain nodes correspond to the blockchain node 1 and the blockchain node 2 included in the blockchain cluster 1 described in fig. 4, respectively.
The creation request 1 is used for requesting that an intelligent contract 1 corresponding to data to be traded 1 created according to the etherhouse standard is deployed in a blockchain commonly maintained by each blockchain link point included in the blockchain cluster 1, and the etherhouse standard is a standard for generating NFT. Optionally, the creation request 1 may carry one or more of the following information: the blockchain cluster 1 identifies the addresses at which the smart contracts 1 are located in the various nodes comprised by the blockchain cluster 1. Wherein one blockchain cluster identifier is used for uniquely identifying the one blockchain cluster. In the embodiment of the present application, the intelligent contract 1 is deployed at an address in the blockchain 1, and the address in the blockchain 1 is also referred to as the contract address 1 of the intelligent contract 1.
The data to be traded 1 is obtained by performing hash calculation on the original data to be traded 1. The content of the original data 1 to be traded and the source of the original data 1 to be traded are not particularly limited. For example, the original data 1 to be traded may be a painting, book text, or musical composition, etc. For example, the original data 1 to be traded may be stored in an interplanetary file system (IPFS). Optionally, the original data 1 to be traded may further include generation time identification of the data.
The server, the terminal, the block link point 1, and the block link point 2 in S401 are not the same device. The blockchain node 1 and the blockchain link node 2 are different nodes in the blockchain network, and the blockchain node 1 and the blockchain node 2 jointly maintain the blockchain 1.
S402, the server creates an intelligent contract 1 according to the creation request 1, and updates an NFT intelligent contract information table, an NFT information table and an NFT holding user table stored in the database 1 according to the intelligent contract 1.
Database 1 is a database that the server has access to, and database 1 is a database that supports complex data queries. The database that can be accessed by the server may be a database local to the server, or may be a database remote from the server, which is not specifically limited in this embodiment of the present application. When database 1 is a database remote from a server, the one database may be a local database of a device other than the server. The type of the database 1 is not particularly limited. For example, the database 1 may be a relational database, such as a MySQL database or an Oracle database, etc. The database 1 stores an NFT smart contract information table, an NFT information table, and an NFT holding user table, and the manner in which these data tables are stored in the database 1 is not specifically described. For example, the NFT smart contract information table, the NFT information table, and the NFT holding user table may be stored in database 1 in a paged manner.
The intelligent contract 1 comprises intelligent contract 1 code and user requested account storage capacity corresponding to the intelligent contract 1. The account storage capacity corresponding to the intelligent contract 1 requested by the user comprises the capacity of storage resources allocated to the intelligent contract account created by the intelligent contract 1 code. For example, the smart contract 1 sent by the user a is a contract for transferring 5 pieces of pictorial work created by the user a, in this scenario, the smart contract 1 code is a code capable of describing "a contract for transferring 5 pieces of pictorial work created by the user a", and the account storage capacity corresponding to the smart contract 1 is 5.
The server creates an intelligent contract 1 according to the creation request 1, and the method comprises the following steps: the server generates a task code corresponding to the intelligent contract 1 according to the data to be traded 1, the storage address identifier of the data to be traded 1, the identifier of the owner of the data to be traded 1 and an Etheng standard protocol, wherein the Etheng standard protocol is used for generating NFT; the server compiles the task code corresponding to the intelligent contract 1 through the compiler to generate an intelligent contract 1 code corresponding to the intelligent contract 1, wherein the intelligent contract 1 code is a byte code intelligent contract code. For example, the task code corresponding to the intelligent contract 1 may be a identity type code. In the embodiment of the present application, the type of the etherhouse standard used for generating the NFT is not specifically limited. For example, the etherhouse standard for generating NFT may be the ERC721 standard or the ERC1155 standard. The storage address identifier of the data to be transacted may be a Uniform Resource Locator (URL) or a Uniform Resource Identifier (URI) corresponding to the storage address of the data to be transacted, or may be other identifiers, which is not specifically limited in this embodiment of the present application.
The NFT intelligent contract information table is used to record the following information: contract address, blockchain identification, and ABI information for the intelligent contract. And an association relation exists among the contract address, the block chain identification and the ABI information of the intelligent contract. The contract address of the intelligent contract represents a specific address of the intelligent contract which is arranged on the blockchain; a blockchain identification is used for indicating a blockchain deployed by the intelligent contract; the ABI information is used for indicating the information for calling the NFT included in the intelligent contract. That is, the information of the NFT may be called according to the ABI information. In some implementations, the ABI information may include a URL of each NFT included in smart contract 1, i.e., each NFT may be successfully invoked via the URL of that NFT. There may be a one-to-one correspondence between ABI information and NFT. That is, the corresponding NFT can be uniquely called by one ABI information. For example, the smart contract 1 includes NFT1, and the ABI information indicates information for calling the metadata of NFT1 included in the smart contract 1, and the metadata of NFT1 may be called according to the ABI information. Optionally, the NFT smart contract information table may further record an ethernet standard protocol used when creating the NFT smart contract. The presentation form of any ABI information is not particularly limited. For example, the ABI information may include an NFT identifier, and the metadata of the NFT indicated by the NFT identifier includes a picture and a hash value (hash), and in this implementation, the code of the ABI information may be as follows:
Figure BDA0003890678280000191
Figure BDA0003890678280000201
after the above S402 is executed, at least the following information is recorded in the updated NFT smart contract information table: contract address, block chain identification # and ABI information # of intelligent contract 1. Wherein, an association relationship exists among the contract address, the block chain identification # and the ABI information # of the intelligent contract 1. Contract address # of intelligent contract 1 represents the specific address where intelligent contract 1 is deployed on the blockchain; the blockchain identification # is used for indicating a blockchain deployed by the intelligent contract 1; ABI information # is information indicating that the NFT included in the smart contract 1 is called.
Optionally, before executing S402, the server further performs the following operations: an NFT smart contract information table is created in database 1. Illustratively, the pseudo code for the server to create the NFT smart contract information table is as follows:
Figure BDA0003890678280000202
the NFT information table is used to record the following information: the contract address of the NFT intelligent contract, the NFT included in the NFT intelligent contract, and the ABI information invoking the NFT. The method comprises the steps that association relations exist among a contract address of an NFT intelligent contract, an NFT included in the NFT intelligent contract and ABI information for calling the NFT. There is no particular limitation on the type and/or number of NFTs that an NFT intelligence contract includes, i.e., an NFT intelligence contract may include one or more NFTs and may include one or more shares of an NFT. Optionally, in some implementations, the NFT information table may further include extension information of the NFT included in the NFT smart contract (for example, an address of a holding user of the NFT, and the like).
After executing the above S402, at least the following information is recorded in the updated NFT information table: the contract address of the intelligent contract 1, the NFT included in the intelligent contract 1, and the ABI information invoking the NFT.
Optionally, before executing S402, the server further performs the following operations: an NFT information table is created in the database 1. Illustratively, the pseudo code for the server to create the NFT smart contract information table is as follows:
illustratively, the pseudo code for the server to create the NFT information table is as follows:
Figure BDA0003890678280000211
the NFT holds a user table for recording the following information: a contract address of an NFT intelligent contract, an NFT included in the NFT intelligent contract, an address of a user holding the NFT, and a number of the users holding the NFT. The method comprises the steps that association relations exist among contract addresses of NFT intelligent contracts, NFTs included in the NFT intelligent contracts, addresses of users holding the NFTs included in the NFT intelligent contracts and the number of the NFTs held by the users.
In step S402, at least the following information is recorded in the updated held user information table: the number of the NFTs held by the user identity and the user identity of the NFT included in the intelligent contract 1 are held.
Optionally, before executing S402, the server further performs the following operations: an NFT holding user table is created in database 1. Illustratively, the pseudo code for the server to create the NFT holding user table is as follows:
illustratively, the pseudo code for the server to create the NFT holding user table is as follows:
Figure BDA0003890678280000221
and S403, the server sends the intelligent contract 1 to each block chain link point included in the block chain cluster 1, so that the intelligent contract 1 is successfully deployed into the block chain 1 commonly maintained by each block chain link point included in the block chain cluster 1.
The number of the block chain link points included in the block chain cluster 1 is not particularly limited. Illustratively, fig. 4 shows a blockchain cluster 1 comprising 2 blockchain nodes, respectively, blockchain node 1 and blockchain node 2. The method for each block link point included in the block chain cluster 1 to successfully deploy the received intelligent contract 1 into the block chain 1 commonly maintained by the block link points is not particularly limited. For example, after each block link node included in the block chain cluster 1 receives the intelligent contract 1, a consensus is achieved on data corresponding to the intelligent contract 1; each block chain node included in the block chain cluster 1 can execute the transaction of the intelligent contract 1 and create a corresponding contract account; and creating contract addresses for the contract accounts according to the same rule, wherein the contract addresses created by each blockchain node for the intelligent contract 1 are the same, and the contract addresses are the addresses in the blockchain 1. In this way, the purpose of successfully deploying the intelligent contract 1 into the blockchain 1 commonly maintained by the individual blockchain link points included in the blockchain cluster 1 is achieved. After the above S401 to S403 are executed, the intelligent contract 1 has been successfully deployed to the corresponding address in the block chain 1, and the NFT intelligent contract information table, the NFT information table, and the NFT holding user table stored in the database 1 are obtained after being updated according to the intelligent contract 1. For convenience of description, data tables obtained by updating the NFT smart contract information table, the NFT information table, and the NFT holding user table according to the smart contract 1 are hereinafter referred to as an updated NFT smart contract information table, an updated NFT table, and an updated NFT holding user table, respectively. For example, the updated NFT intelligent contract information table, the NFT information table, and the NFT holding user table may be respectively shown in tables 1 to 3 below:
TABLE 1
Figure BDA0003890678280000231
Table 1 shows the information recorded in the updated NFT intelligent contract information table. In table 1, contract address 1 represents an address where the intelligent contract 1 is deployed in the blockchain 1, and the blockchain 1 identifier is used to identify the blockchain 1. The ABI information # A1 and the ABI information # A2 are different. The NFT included in the intelligent contract 1 can be deployed on the blockchain 1 by the ABI information. Optionally, the table 1 may also record relevant information of intelligent contracts other than the intelligent contract 1, which is not limited in particular.
TABLE 2
Figure BDA0003890678280000232
Table 2 shows the information recorded in the updated NFT information table, where ABI information # A1 and ABI information # A2 are different. Optionally, the NFT related information of the smart contract other than the smart contract 1 may also be recorded in the table 2, which is not particularly limited.
TABLE 3
Figure BDA0003890678280000241
Table 3 shows information recorded in the updated NFT holding user table. Optionally, the content of the held user associated with the intelligent contract other than the intelligent contract 1 is recorded in the table 3, which is not particularly limited.
After executing the above S401 to S403, the user may invoke, through the client and the server, the intelligent contract 1 deployed in the blockchain 1 commonly maintained by the blockchain link points included in the blockchain cluster 1, and invoke the intelligent contract 1 to initiate a transaction directed to the intelligent contract 1 address. For example, the transaction may be casting, transfer, or destruction.
S404, the terminal sends a transaction request 1 to the server, where the transaction request 1 is used to request to execute transaction 1 on NFT1 included in the smart contract 1. Accordingly, the server receives the transaction request 1.
The type of transaction for which NFT1 performs transaction 1 is not particularly limited. For example, in the case where smart contract 1 is generated according to the ERC-721 standard (i.e., NFT1 is generated according to the ERC-721 standard), transaction 1 may be a transaction of casting, transferring, or destroying NFT1 (e.g., NFT1 held by user a in table 3 above). As another example, where smart contract 1 is generated according to the ERC-1155 standard (i.e., NFT1 is generated according to the ERC-1155 standard), transaction 1 may be a transaction that transfers multiple shares of NFT1 (e.g., NFT1 held by user B in table 3 above) included in smart contract 1.
S405, the server determines that the transaction request 1 is valid according to the transaction request 1 and the updated NFT information table.
The server determines that the transaction request 1 is valid according to the transaction request 1 and the updated NFT information table, and the method includes the following steps: the server determines the content requested by the transaction request 1 according to the transaction request and the updated NFT information table, and determines that the transaction request 1 is valid if the content is matched with the content stored in the updated NFT information table. That is, in the case where the transaction request 1 is for requesting execution of the transaction 1 on the NFT1 included in the smart contract 1, the server determines that the transaction request 1 is valid if the following condition is satisfied: the smart contract 1 includes NFT1, and NFT1 is actually stored in the address of the original NFT1 indicated by transaction 1.
S406, the server sends the transaction request 1 to each blockchain node included in the blockchain cluster 1, so that each blockchain node included in the blockchain cluster 1 executes the transaction 1 requested by the transaction request 1. Accordingly, each of the blockchain nodes included in the blockchain cluster 1 receives the transaction request 1.
In the embodiment of the present invention, after the server performs the above-mentioned S405, the server will continue to perform S406 only when the transaction request is determined to be valid, so that an invalid transaction request uplink (i.e. a block chain) can be prevented, and further, the performance of a block chain node where the block chain is located can be prevented from being affected after the uplink is performed due to too many invalid transaction requests.
S407, each blockchain node included in the blockchain cluster 1 executes the transaction 1 requested by the transaction request 1, and generates the receipt information of the transaction 1.
Each block chain node included in the block chain cluster 1 executes the transaction 1 requested by the transaction request 1, and generates the receipt information of the transaction 1, including: all the block chain link points included in the block chain cluster 1 agree on a transaction 1 requested by the transaction request 1 based on a consensus mechanism; each block link point included in the block chain cluster 1 executes the transaction 1 requested by the transaction request 1 to the intelligent contract 1 deployed in the block chain 1, and generates receipt information of the transaction 1. In the above manner, before each blockchain node generates the receipt information of transaction 1, each blockchain node verifies and confirms the transaction requested by transaction request 1 based on the consensus mechanism, so as to determine that the transactions 1 requested by transaction requests 1 received by different blockchain nodes are consistent, that is, not tampered. The receipt information of transaction 1 is data generated based on a consensus mechanism, and the receipt information of transaction 1 is also called on-chain data. After each block chain node included in the block chain cluster 1 executes the transaction 1 requested by invoking the intelligent contract 1 to execute the transaction request 1 according to the transaction request 1, corresponding receipt information (receipt) is generated, and the receipt information is used for recording information related to executing the intelligent contract (for example, the intelligent contract 1). In this way, the relevant information of the intelligent contract execution result can be obtained by inquiring the response piece information of the transaction. The smart contract execution result may be represented as an event (event) in the response piece information. The message mechanism can realize message passing through an event in the receipt information so as to trigger the blockchain node to execute corresponding processing.
For example, the structure of an event may be:
event:
[topic 1][data 1]
[topic 2][data 2]
[topic 3][data 3]
……
in the above illustrated structure of events, the number of events may be one or more; wherein, each event respectively comprises fields of a theme (topics) and data (data). The block link node may perform a preset process by listening to topics of an event, in case that predefined topics is listened to, or read related contents from a data field of a corresponding event, and may perform a preset process based on the read contents.
In the embodiment of the present application, the transaction request 1 is for requesting execution of the transaction 1 on the NFT1 included in the smart contract 1. That is, the response piece information for transaction 1 may include: for recording information about the execution of transaction 1 on NFT1 comprised by smart contract 1. In some implementations, the receipt information for transaction 1 includes the following information: contract address where the event corresponding to transaction 1 occurred and topic (topics) corresponding to transaction 1. The subject corresponding to transaction 1 includes: the hash value of the event corresponding to transaction 1, and the content of the event corresponding to transaction 1. The hash value of the event corresponding to transaction 1 is used to indicate the event, and the event may be any one of the following events: a transfer event specified in the ERC721 standard, a single transfer event specified in the ERC1155 standard, or a batch transfer event specified in the ERC1155 standard. The content of the event corresponding to transaction 1 is not particularly limited. For example, the content of the event corresponding to transaction 1 is to transfer NFT1 included in the smart contract 1 from user a (the address of user a is address 1) to user C (the address of user C is address 2), that is, to transfer NFT1 from address 1 to address 2, any one of address 1 and address 2 may be an address 0 (that is, an empty address), and address 1 and address 2 are not simultaneously an address 0.
S408, the server acquires the block from at least one block chain node included in the block chain cluster 1, and analyzes the block to obtain receipt information for executing the transaction 1 to the intelligent contract 1.
The server obtains a block from at least one block chain node included in the block chain cluster 1, including: after the timer built in the server reaches the preset time, the server derives the block from at least one blockchain node included in the blockchain cluster 1 by calling the interface of the at least one blockchain node. For example, the interface for a block link point may be a "getBlockByNumber" interface. The data is stored in the block link points in an encryption mode, and the server analyzes the block to obtain the receipt information of the transaction 1, and the method comprises the following steps: the server decrypts the block and obtains the receipt information of the transaction 1.
For example, continuing with the examples in tables 1 to 3 shown in S403, in a case where the transaction request 1 is specifically used to request transfer of NFT1 included in the smart contract 1 held by the user a at the address 1 to the address 2 held by the user C, where the user a and the user C are two different users, the receipt information of the transaction 1 described in S408 includes: the contract address at which the transfer event corresponding to transaction 1 occurs is contract address 1, and the subject (topics) corresponding to transaction 1. The subject corresponding to transaction 1 includes: the hash value of the transfer event corresponding to transaction 1, and the content of the transfer event corresponding to transaction 1 (i.e., transferring NFT1 from the address of user a to the address of user C.
S409, the server inquires the updated NFT contract information table according to the contract address of the event corresponding to the transaction 1, and determines that the contract address of the event corresponding to the transaction 1 is matched with the contract address recorded in the NFT contract information table.
The above S409 is executed, i.e., the server determines whether the server has the authority to manage the smart contract 1. Specifically, if the server determines that the contract address recorded in the updated NFT contract information table matches the contract address of the event corresponding to transaction 1, the server determines that it has the authority to manage intelligent contract 1. If the server determines that the contract address recorded in the updated NFT contract information table does not match the contract address of the event corresponding to the transaction 1, the server determines that the server does not have the authority to manage the intelligent contract 1.
S410, the server determines that the event corresponding to the transaction 1 is a transfer event specified in an Ethernet standard protocol according to the hash value of the event corresponding to the transaction 1, wherein the Ethernet standard protocol is a protocol for generating NFT.
In this embodiment of the present application, after the server executes the foregoing S409, that is, in a case where it is determined that the contract address of the event corresponding to the transaction 1 matches the contract address recorded in the NFT contract information table, the server will continue to execute the foregoing S410, so that the server may be prevented from performing query processing on the transaction 1 that is not managed by itself, which is beneficial to reducing resource consumption of the server.
In some implementations, the ethernet standard protocol may be the ERC721 standard or the ERC1155 standard. Illustratively, table 4 shows details of the transfer events specified in the ERC721 standard and the transfer events specified in the ERC1155 standard:
TABLE 4
Figure BDA0003890678280000271
Figure BDA0003890678280000281
In table 4 above, the value of the from address field is used to indicate the source address of the NFT indicated by the store transaction (e.g., transaction 1), and the value of the to address field is used to indicate the destination address of the NFT indicated by the store transaction (e.g., transaction 1). For example, taking ERC-721 standard and transaction 1 as an example, if the value of the from address field is equal to address 1 and the value of the to address field is equal to address 2, the event corresponding to transaction 1 is a transfer event for transferring NFT1 from address 1 to address 2. Tokenid in table 4 above, NFT identification. For example, taking ERC-721 transfers an event as an example, an event hash value of "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" is used to indicate that ERC-721 transfers the event.
The server determines that the event corresponding to the transaction 1 is an assignment event specified in an Ethernet standard protocol according to the hash value of the event corresponding to the transaction 1, and the method comprises the following steps: the server compares the hash value of the event corresponding to the transaction 1 with the hash values of a plurality of assignment events specified by the Ethenhouse standard protocol, determines the hash value of one assignment event in the plurality of assignment events specified by the Ethenhouse standard protocol, and matches the hash value of the event corresponding to the transaction 1; the server determines that the event corresponding to transaction 1 is a transfer event specified in the etherhouse standard protocol. For example, taking the ethernet protocol in the above S410 as the ERC-721 protocol as an example, if the hash value of the event corresponding to the transaction 1 is "0xddf252ad1be2c89b 2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", the server may determine that the event corresponding to the transaction 1 is the assignment event specified in the ERC-721 standard after executing the above S410.
And S411, the server updates the updated NFT information table and/or the updated NFT holding user table again according to the content of the event corresponding to the transaction 1.
For convenience of description, the updated NFT information table and the updated NFT holding user table obtained after updating again according to the content pair of the event corresponding to transaction 1 are collectively denoted as: the NFT information table after the update, and the NFT holding user table after the update.
In this embodiment of the present application, the server performs, according to the content of the event corresponding to transaction 1, re-update on the NFT information table and/or the updated NFT holding user table stored in database 1, to obtain the re-updated NFT information table and/or the re-updated NFT holding user table. Wherein, the content recorded in the NFT information table after being updated again or the NFT holding user table after being updated again is obtained is related to the following information: the etherhouse protocol followed by the event corresponding to transaction 1, and the specific content of the event corresponding to transaction 1. Next, the description is given of the content recorded in the re-updated NFT information table and/or the re-updated NFT holding user table obtained after the server executes the above-described S411, in combination with the ethernet house protocol followed by the event corresponding to the transaction 1 and the specific content of the event corresponding to the transaction 1.
In a first implementation, the event corresponding to transaction 1 is a transfer event specified in the ERC-721 standard.
In the first implementation manner, the content of the event corresponding to the transaction 1 is to transfer NFT1 included in the smart contract 1 held by the user a from the address 1 where the user a is located to the address 2 where the user C is located. In this implementation, the content of the event corresponding to transaction 1 may include: address 1 of user a originally holding NFT1, address 2 of user C holding NFT1, and NFT1 identifier. Here, any one of the address 1 and the address 2 may be a 0 address (i.e., a null address), and the address 1 and the address 2 are not 0 addresses at the same time. Specifically, when address 1 is not 0 address and address 2 is not 0 address, transaction 1 is performed by the block link node, that is, NFT1 is assigned by the block link node; when address 1 is 0 address and address 2 is not 0 address, the block link point executes transaction 1, i.e. the block link point casts NFT 1; when address 1 is not 0 address and address 2 is 0 address, transaction 1 is performed by the block link point, i.e. NFT1 is destroyed by the block link point.
In the first implementation manner, the updating, by the server, the updated NFT information table and/or the updated NFT holding user table again according to the content of the event corresponding to the transaction 1 includes: the server determines that the content indication of the event corresponding to the transaction 1 transfers to the NFT1, updates the updated NFT holding user table again, and obtains the updated NFT holding user table again; or, the server determines that the content of the event corresponding to transaction 1 indicates casting or destroying NFT1, updates the updated NFT information table and the updated NFT holding user table again, and obtains the updated NFT holding user table and the updated NFT information table. Wherein, the content of the event corresponding to the transaction 1 indicates that the NFT1 is transferred, casted or destroyed, and whether the address of the address 1 and the address of the address 2 indicated by the content of the event corresponding to the transaction 1 are related to each other by 0 address. Next, the table updated when the server executes the above-described S411, and the contents recorded in the obtained table after being updated again, are described in conjunction with whether or not the address of address 1 and the address of address 2 are 0 addresses.
In the first example, address 1 is not 0 address, and address 2 is 0 address, and the block node executes transaction 1, that is, the NFT1 stored at address 1 where user a is located is destroyed.
In an example, the server executes the above S411, that is, the server updates the updated NFT information table and the updated NFT holding user table again according to the content of the event corresponding to the transaction 1, and obtains the updated NFT information table and the updated NFT holding user table. Specifically, the server updating the updated NFT information table and the updated NFT-holding user table again includes: the server deletes all information related to the NFT1 stored in the address 1 where the user A is located in the updated NFT holding user table; and the server deletes the ABI information of the metadata of the NFT1 stored in the address 1 of the calling user A from the updated NFT information table.
Illustratively, continuing with the above table 2 and table 3 as examples, table 2 shows the content of the updated NFT table record, and table 3 shows the content of the updated NFT holding user table record. In this scenario, after the server updates the updated NFT information table and the updated NFT holding user table again, the table 5 and the table 6 show that the NFT information table and the NFT holding user table that are obtained after the NFT information table and the NFT holding user table that are updated again are obtained:
TABLE 5
Figure BDA0003890678280000301
TABLE 6
Figure BDA0003890678280000302
In example two, address 1 is 0 address, while address 2 is not 0 address, and the block link node performs transaction 1, i.e. casting NFT1 stored at address 1 where user a is located.
In example two, the server executes the above S411, that is, the server updates the updated NFT information table and the updated NFT holding user table again according to the content of the event corresponding to the transaction 1, and obtains the updated NFT information table and the updated NFT holding user table. Specifically, the server updating the updated NFT information table and the updated NFT-holding user table again includes: the server adds the information related to the address 2 where the user C is located and stores the NFT1 in the updated NFT holding user table; the server adds the ABI information of the metadata of the NFT1 stored at the address 2 where the calling user C is located to the updated NFT information table.
Illustratively, continuing with the above table 2 and table 3 as examples, table 2 is an updated NFT table, table 3 is an updated NFT holding user table, and ABI information # A1 shown in table 2 is information of the NFT1 stored at the address 1 where the calling user a is located, and ABI information # A2 shown in table 2 is information of the NFT1 stored at the address where the calling user B is located. In this scenario, after the server updates the updated NFT information table and the updated NFT holding user table again, the table 7 and the table 8 show that the NFT information table and the NFT holding user table that are obtained after the NFT holding user table are updated again:
TABLE 7
Figure BDA0003890678280000311
Here, NFT1 stored at address 2 of user C can be called according to ABI information # A3 shown in table 7 described above.
TABLE 8
Figure BDA0003890678280000312
Example three, address 1 is not 0 address, while address 2 is not 0 address, and the block node performs transaction 1, that is, transfers NFT1 stored at address 1 of user a.
In the third example, the server performs the above S411, that is, the server updates the updated NFT holding user table again according to the content of the event corresponding to the transaction 1, and obtains the updated NFT holding user table again. Specifically, the updating, by the server, the updated NFT holding user table again includes: the server deletes the information associated with the address 1 storage NFT1 of the user A recorded in the updated NFT holding user table, and adds the information associated with the address 2 storage NFT1 of the user C in the updated NFT holding user table.
For example, continuing with the above table 3 as an example, that is, table 3 shows the content recorded in the updated NFT holding user table, in this scenario, after the server updates the updated NFT holding user table again, the updated NFT holding user table 9 is obtained:
TABLE 9
Figure BDA0003890678280000321
In the first implementation manner, when the event corresponding to the transaction 1 is casting or destroying the NFT1, the server executes the above S411, that is, the server updates the updated NFT information table and the updated NFT holding user table again according to the content of the event corresponding to the transaction 1. When the event corresponding to transaction 1 is an assignment to NFT1, the server performs the above-mentioned S411, that is, the server updates the updated NFT holding user table again according to the content of the event corresponding to transaction 1.
In the second implementation, the event corresponding to transaction 1 is a transfer event specified in the ERC-1155 standard.
In the second implementation manner, the content of the event corresponding to transaction 1 is to transfer 5 NFT1 pieces included in smart contract 1 held by user B from address 3 of user B to address 2 of user C. Since the event corresponding to transaction 1 is a transfer event as specified in the ERC-1155 standard, N is equal to 1 or 5.
In this implementation, the content of the event corresponding to transaction 1 may include: address 3 of user B originally holding 5 NFT1, address 2 of user C holding NFT1, NFT1 id, and number of transfers of NFT1. Here, any one of the address 3 and the address 2 may be a 0 address (i.e., a null address), and the address 3 and the address 2 are not simultaneously 0 addresses. Specifically, when the address 3 is not the address 0 and the address 0 is not the address 0, the block link point executes transaction 1, that is, the block link point assigns NFT 1; when the address 3 is 0 address and the address 0 is not 0 address, the block link point executes transaction 1, that is, the block link point casts NFT 1; when address 3 is not 0 address and address 0 is 0 address, transaction 1 is executed by the block link point, i.e. NFT1 is destroyed by the block link point.
In the second implementation manner, the updating, by the server, the updated NFT information table and/or the updated NFT holding user table again according to the content of the event corresponding to the transaction 1 includes: the server determines that the content of the event corresponding to the transaction 1 indicates that 5 parts of NFT1 are transferred or part of NFT1 in the 5 parts of NFT1 is destroyed, updates the updated NFT holding user table again, and obtains the updated NFT holding user table; or the server determines that the content of the event corresponding to transaction 1 indicates casting or destroying 5 NFT1 shares, updates the updated NFT information table and the updated NFT holding user table again, and obtains the updated NFT holding user table and the updated NFT information table. Wherein, the content of the event corresponding to the transaction 1 indicates that the NFT1 is transferred, casted, totally destroyed or partially destroyed, and whether the address of the address 3 and the address of the address 2 indicated by the content of the event corresponding to the transaction 1 are related to each other is 0 address.
It can be understood that, in the second implementation manner, the principle that the server updates the updated NFT information table and/or the updated NFT holding user table again according to whether the address of the address 3 and the address of the address 2 are 0 addresses is consistent with the principle that the server updates the updated NFT information table and/or the updated NFT holding user table again according to whether the address of the address 1 and the address of the address 2 are 0 addresses in the first implementation manner, and details which are not described herein in detail may refer to relevant descriptions in the first implementation manner. For example, if the address 3 of the user B holds 5 parts of NFT1 and the number of destroyed parts is 3 parts of NFT1, the address 3 of the user B holds 2 parts of NFT1 after the block link point executes the transaction 1. At this time, S411 is executed, that is, the server updates the updated NFT holding user table again, obtains the updated NFT holding user table, and records that user a holds 1 NFT1 in the updated NFT holding user table. For example, if the address 3 of the user B holds 5 NFT1 copies and the number of destroyed NFT1 copies is 5 NFT1 copies, the address 3 of the user B does not hold NFT1 any more after the transaction 1 is executed. At this time, the above S411 is executed, that is, the server deletes the ABI information of 5 parts of NFT1 recorded in the updated NFT information table, which calls the address 3 where the user B is located, and obtains the updated NFT information table again; and deleting the record of 5 shares of NFT1 held by the user B recorded in the NFT holding user table after updating, and obtaining the NFT holding user table after updating again.
S412, the terminal sends a query request to the server, where the query request is used to request to query information associated with NFT1 included in the intelligent contract 1. Correspondingly, the server receives the query request sent by the terminal.
Wherein, the query request may carry at least one of the following information: a contract address of the intelligent contract 1, a subscriber identity holding NFT1, or an NFT1 identity.
S413, the server generates a query result according to the query request and the NFT information table and the NFT holding user table stored in the database 1.
The NFT table and the NFT holding user table described in S413 are tables obtained after the server executes S411. In some implementations, if the server updates the updated NFT information table or the updated NFT holding user table again in S411, the NFT information table described in S413 is a table obtained by updating the updated NFT information table again when the server executes S411, and the NFT holding user table described in S413 is a table obtained by updating the updated NFT holding user table again when the server executes S411. In another implementation manner, if the server does not update the updated NFT information table or the updated NFT holding user table again in S411, the NFT information table described in S413 is the updated NFT information table described above, and the NFT holding user table described in S413 is the updated NFT holding user table described above.
The server generates a query result according to the query request and the NFT information table and the NFT holding user table stored in the database 1, and includes: the server inquires the record information matched with the inquiry request from the NFT information table and the NFT holding user table according to the inquiry request; and the server generates a query result according to the record information, wherein the query result comprises part or all of the content of the record information. Illustratively, when the query request queries all NFTs included in the intelligent contract 1 and all users holding the intelligent contract 1, and the query request carries a contract address of the intelligent contract 1, the server generates a query result corresponding to the query request according to the query request and an NFT information table and an NFT holding user table stored in the database 1, including: the server acquires all NFTs included in the intelligent contract 1 from the NFT contract information table according to the contract address of the intelligent contract 1; and the server acquires the user identifications of all NFTs included in the intelligent contract 1 from the NFT holding user table according to the contract address of the intelligent contract 1.
In the embodiment of the present application, the length of time required for the server to execute the above S406 to the above S413 is in the order of minutes (e.g., 1 minute, etc.). That is, the server can finish the above S406 to S413 in a short time. It should also be understood that when the server executes the above-described S406 to S413 within the minute level, each blockchain node included in the blockchain cluster 1 does not execute other transactions other than transaction 1 for the smart contract 1. That is to say, when the server determines the query result corresponding to the query request according to the NFT information table and the NFT holding user table stored in the offline database 1, the content associated with the smart contract 1 recorded in the NFT information table and the NFT holding user table stored in the database 1 can truly reflect the content associated with the smart contract 1 recorded in the block chain stored in each block chain link point included in the current block chain cluster 1.
It should be understood that the data query method shown in fig. 4 is only an illustration, and does not constitute any limitation on the data query method provided in the embodiment of the present application.
In the embodiment of the application, the server creates an NFT intelligent contract information table, an NFT information table, and an NFT holding user table in the accessible database 1 supporting complex queries (for example, the database 1 is a database in a local server of the server), and the data tables are used for recording information associated with the intelligent contract 1 after the transaction is executed by the intelligent contract 1 deployed in the block chain 1 commonly maintained by the block chain link points included in the block chain cluster 1. It will be appreciated that the database 1 described above is not a database stored on a blockchain network. The server derives block data from a block chain stored at a block link point included in the block chain cluster 1 (for example, derives block data from the block chain 1 periodically or aperiodically), and updates the information associated with the smart contract 1 recorded in the NFT smart contract information table, the NFT information table, and the NFT holding user table stored in the database 1 by the latest information associated with the smart contract 1 obtained by parsing the block data, so that the information associated with the smart contract 1 stored in the updated database 1 coincides with the information associated with the smart contract 1 recorded in the block chain 1. That is, the server maintains the information associated with the intelligent contract 1 stored in the down-link database 1 by continuously deriving the information associated with the intelligent contract 1 matched on the blockchain 1. Information associated with intelligent contracts 1 stored on blockchain 1 and information associated with intelligent contracts 1 stored in downlinker database 1 may be considered consistent within the minute level. That is, the server performs the above-described data derivation, table update operation in the database 1, and query result generation based on the NFT information table, the NFT holding user table, and the query request stored in the offline database 1 within the minute level after the transaction of the smart contract 1 is performed by each block link node included in the block chain cluster 1, and at this time, the query result is reliable and reliable. That is, in this case, the query result generated from the NFT information table and the NFT holding user table stored in the downlink database 1 is identical to the result obtained by directly querying the block chain stored in each block chain link point included in the block chain cluster 1 according to the query request. In the data query process, the data table stored in the database 1 is queried according to the query request, so that the content requested to be queried by the query request can be quickly found from the NFT information table and the NFT holding user table stored in the database 1 according to the query request. No matter the query request requests to query the NFT information, the ABI information or the user information associated with the intelligent contract 1, the corresponding content can be quickly found based on the query mode, so that the query requirement of the client can be better responded. In the data query process, the server queries the database 1 to obtain a query result, and the database 1 is a linked database, so that the influence on the performance of the blockchain node can be avoided. In summary, the data query method provided by the embodiment of the present application can improve the efficiency of data query while ensuring the reliability of the data query result. Meanwhile, the method can also avoid the influence on the performance of the block chain node.
In the above, an application scenario and a data query method to which the data query method provided by the present application is applicable are described in detail with reference to fig. 1 to 4. Next, a data query apparatus and a data query device provided by the present application are described with reference to fig. 5 and 6. It should be understood that the above data query method corresponds to the data query apparatus and the data query device in the following. What is not described in detail below can be referred to the relevant description in the above-described method embodiments.
Fig. 5 is a schematic structural diagram of a data query device according to an embodiment of the present application. As shown in fig. 5, the apparatus includes a transceiving unit 501 and a processing unit 502,
a transceiving unit 501, configured to receive an inquiry instruction from a terminal, where the inquiry instruction is used to inquire target information associated with a first intelligent contract deployed on a block chain;
a processing unit 502, configured to query a relational database according to the query instruction, and obtain a query result, where information associated with the first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on the blockchain, the information associated with the first intelligent contract includes the target information, and the query result includes the target information;
the transceiver unit 501 is further configured to send the query result to the terminal.
Optionally, in some implementations, the processing unit 502 is further configured to, before the server queries the relational database according to the query instruction, perform the following operations: acquiring the blocks from the block chain according to a preset period; analyzing the block to obtain information associated with the first intelligent contract; and updating the initial relational database according to the information associated with the first intelligent contract to obtain the relational database.
Optionally, in other implementations, the processing unit 502 is further configured to: analyzing the block to obtain receipt information of the transaction corresponding to the first intelligent contract, wherein the receipt information comprises a contract address of an event occurrence associated with the transaction corresponding to the first intelligent contract, a first hash value of the event associated with the transaction corresponding to the first intelligent contract, and event content associated with the transaction corresponding to the first intelligent contract; determining that a contract address of an intelligent contract recorded in an intelligent contract information table is matched with a contract address of an event occurrence associated with a transaction corresponding to the first intelligent contract, wherein the server locally stores the intelligent contract information table, and the contract address of any intelligent contract represents an address of any intelligent contract deployed in a block chain; determining that the first hash value is matched with a second hash value of a preset event; and analyzing the event content associated with the transaction corresponding to the first intelligent contract to obtain the information associated with the first intelligent contract.
Optionally, in other implementation manners, the processing unit 502 is further configured to, before the server updates the initial relational database according to the information associated with the first intelligent contract, perform the following operations: creating an initial digital currency information table in the initial relational database according to a first preset query requirement, wherein the initial digital currency information table is used for recording a first mapping relation, and the first mapping relation is a mapping relation among a contract address of an intelligent contract, digital currency included by the intelligent contract and application program binary interface information for calling the digital currency included by the intelligent contract; according to a second preset query requirement, creating an initial user information table in the initial relational database for recording a second mapping relation, wherein the second mapping relation is the mapping relation among the digital currency included by the intelligent contract, the contract address of the intelligent contract, the user information holding the digital currency included by the intelligent contract and the quantity of the digital currency included by the intelligent contract held by the user information; wherein the contract address of the intelligent contract represents an address of the intelligent contract deployed in a blockchain.
Optionally, in other implementations, the processing unit 502 is further configured to: updating the initial user information table according to a third mapping relation to obtain a user information table, wherein the relational database comprises the user information table, the information associated with the first intelligent contract comprises the third mapping relation, and the third mapping relation is a mapping relation among the digital currency included in the first intelligent contract, the contract address of the first intelligent contract, first user information holding the digital currency included in the first intelligent contract, and the number of digital currencies included in the first intelligent contract held by the first user information; or updating the initial digital currency information table according to a fourth mapping relation to obtain a digital currency information table, wherein the relational database includes the digital currency information table, the information associated with the first intelligent contract includes the third mapping relation and the fourth mapping relation, and the fourth mapping relation is a mapping relation between a contract address of the first intelligent contract, the digital currency included in the first intelligent contract, and application binary interface information for calling the digital currency included in the first intelligent contract.
Optionally, in other implementations, the processing unit 502 is further configured to: querying the digital currency information table stored in the relational database according to the contract address of the first intelligent contract included in the query instruction to obtain at least one digital currency included in the first intelligent contract, wherein the target information includes the at least one digital currency included in the first intelligent contract; or, according to the contract address of the first intelligent contract included in the query instruction, querying the digital currency information table stored in the relational database to obtain application binary interface information for calling at least one digital currency included in the first intelligent contract, wherein the target information includes the application binary interface information for calling the at least one digital currency included in the first intelligent contract; or inquiring the user information table stored in the relational database according to the address of the user included in the inquiry instruction to obtain the user information of the at least one digital currency included in the first intelligent contract, wherein the target information includes the user information of the at least one digital currency included in the first intelligent contract.
Optionally, in another implementation manner, the transceiver unit 501 is further configured to, after the server updates the initial relational database according to the information associated with the first intelligent contract, perform the following operations: receiving a transaction request from the terminal, wherein the transaction request is for requesting that a transaction be performed in at least one digital currency included in the first smart contract; in the case that the event content associated with the transaction requested by the transaction request matches the third mapping relation recorded in the user information table, and the event content associated with the transaction requested by the transaction request matches the fourth mapping relation recorded in the digital currency information table, sending the transaction request to each blockchain node in the blockchain network, so that each blockchain node executes the transaction requested by the transaction request on the first smart contract disposed on the blockchain.
Optionally, in other implementations, the digital currency is a non-homogeneous token NFT and the blockchain is a federation blockchain.
Fig. 6 is a schematic structural diagram of a data query device according to an embodiment of the present application. As shown in fig. 6, includes a memory 601, a processor 602, a communication interface 603, and a communication bus 604. The memory 601, the processor 602, and the communication interface 603 are communicatively connected to each other via a communication bus 604.
The memory 601 may be a Read Only Memory (ROM), a static memory device, a dynamic memory device, or a Random Access Memory (RAM). The memory 601 may store a program, and the processor 602 and the communication interface 603 are used to perform the steps of the data query method of the embodiment of the present application when the program stored in the memory 601 is executed by the processor 602.
The processor 602 may be a general-purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), a Graphics Processing Unit (GPU) or one or more integrated circuits, and is configured to execute related programs to implement the functions required to be executed by the units in the data processing apparatus according to the embodiment of the present application, or to execute the steps of the data query method according to the embodiment of the present application.
The processor 602 may also be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the data query method provided in the present application may be implemented by integrated logic circuits of hardware or instructions in the form of software in the processor 602. The processor 602 may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 601, and the processor 602 reads the information in the memory 601, and performs the functions required to be performed by the units included in the data processing apparatus according to the embodiment of the present application, or performs the data query method according to the embodiment of the present application, in combination with the hardware thereof.
The communication interface 603 enables communication between the device shown in fig. 6 and other devices or communication networks using transceiver means such as, but not limited to, a transceiver. For example, a processing result corresponding to the first request and the like may be output through the communication interface 603.
A communication bus 604 may include a pathway to transfer information between various components of the device shown in fig. 6, such as the memory 601, the processor 602, and the communication interface 603.
The embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium includes computer instructions, and the computer instructions, when executed by a processor, are used to implement a technical solution of any one of the data query methods in the embodiment of the present application.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored on a computer-readable medium and include several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device) to execute the method according to the embodiments of the present disclosure.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
1. Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage media, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
2. As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application, and those skilled in the art can make variations and modifications without departing from the spirit and scope of the present application, therefore, the scope of the present application should be determined by the claims that follow.

Claims (11)

1.A method of querying data, comprising:
the method comprises the steps that a server receives a query instruction from a terminal, wherein the query instruction is used for querying target information associated with a first intelligent contract deployed on a block chain;
the server queries a relational database according to the query instruction to obtain a query result, wherein information associated with the first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on the block chain, the information associated with the first intelligent contract comprises the target information, and the query result comprises the target information;
and the server sends the query result to the terminal.
2. The method of claim 1, wherein before the server queries the relational database according to the query instruction, the method further comprises:
the server acquires the blocks from the block chain according to a preset period;
the server analyzes the block to obtain information associated with the first intelligent contract;
and the server updates the initial relational database according to the information associated with the first intelligent contract to obtain the relational database.
3. The method of claim 2, wherein the server parsing the block to obtain information associated with the first intelligent contract comprises:
the server analyzes the block to obtain receipt information of the transaction corresponding to the first intelligent contract, wherein the receipt information comprises a contract address of an event occurrence associated with the transaction corresponding to the first intelligent contract, a first hash value of the event associated with the transaction corresponding to the first intelligent contract, and event content associated with the transaction corresponding to the first intelligent contract;
the server determines that a contract address of an intelligent contract recorded in an intelligent contract information table is matched with a contract address of an event occurrence associated with a transaction corresponding to the first intelligent contract, wherein the server locally stores the intelligent contract information table, and the contract address of any intelligent contract represents the address of any intelligent contract deployed in a block chain;
the server determines that the first hash value is matched with a second hash value of a preset event;
and the server analyzes the event content associated with the transaction corresponding to the first intelligent contract to obtain the information associated with the first intelligent contract.
4. The method of claim 2 or 3, wherein prior to the server updating an initial relational database in accordance with information associated with the first intelligent contract, the method further comprises:
the server creates an initial digital currency information table in the initial relational database according to a first preset query requirement, wherein the initial digital currency information table is used for recording a first mapping relation, and the first mapping relation is a mapping relation among a contract address of an intelligent contract, digital currency included in the intelligent contract and application binary interface information for calling the digital currency included in the intelligent contract;
the server creates an initial user information table in the initial relational database according to a second preset query requirement, wherein the initial user information table is used for recording a second mapping relation, and the second mapping relation is the mapping relation among the digital currency included by the intelligent contract, the contract address of the intelligent contract, the user information holding the digital currency included by the intelligent contract and the number of the digital currency included by the intelligent contract held by the user information;
wherein the contract address of the intelligent contract represents an address of the intelligent contract deployed in a blockchain.
5. The method of claim 4, wherein the server updates an initial relational database according to the information associated with the first intelligent contract to obtain the relational database, and comprises:
the server updates the initial user information table according to a third mapping relation to obtain a user information table, wherein the relational database comprises the user information table, the information associated with the first intelligent contract comprises the third mapping relation, and the third mapping relation is a mapping relation among the digital currency included in the first intelligent contract, the contract address of the first intelligent contract, first user information holding the digital currency included in the first intelligent contract, and the number of digital currencies included in the first intelligent contract held by the first user information; alternatively, the first and second electrodes may be,
and the server updates the initial digital currency information table according to a fourth mapping relation to obtain a digital currency information table, wherein the relational database comprises the digital currency information table, the information associated with the first intelligent contract comprises the third mapping relation and the fourth mapping relation, and the fourth mapping relation is a mapping relation among a contract address of the first intelligent contract, the digital currency included in the first intelligent contract and application binary interface information for calling the digital currency included in the first intelligent contract.
6. The method of claim 5, wherein the server queries the relational database according to the query instruction to obtain a query result, comprising:
the server inquires the digital currency information table stored in the relational database according to the contract address of the first intelligent contract included in the inquiry instruction to obtain at least one digital currency included in the first intelligent contract, wherein the target information includes the at least one digital currency included in the first intelligent contract; alternatively, the first and second electrodes may be,
the server inquires the digital currency information table stored in the relational database according to the contract address of the first intelligent contract, wherein the contract address comprises the contract address, and the digital currency information table calls at least one type of digital currency, wherein the target information comprises the application binary interface information calling the at least one type of digital currency, and the application binary interface information calls the first intelligent contract; alternatively, the first and second electrodes may be,
and the server inquires the user information table stored in the relational database according to the address of the user included in the inquiry instruction to obtain the user information of at least one digital currency included in the first intelligent contract, wherein the target information includes the user information of the at least one digital currency included in the first intelligent contract.
7. The method of claim 5 or 6, wherein after the server updates an initial relational database according to the information associated with the first intelligent contract, the method further comprises:
the server receiving a transaction request from the terminal, wherein the transaction request is used for requesting to execute transaction on at least one digital currency included in the first intelligent contract;
in a case where the event content associated with the transaction requested by the transaction request matches the third mapping relationship recorded in the user information table, and the event content associated with the transaction requested by the transaction request matches the fourth mapping relationship recorded in the digital currency information table, the server sends the transaction request to each blockchain node in the blockchain network, so that each blockchain node executes the transaction requested by the transaction request on the first smart contract disposed on the blockchain.
8. The method according to any of the claims 4 to 7, characterized in that the digital currency is a non-homogeneous token NFT and the blockchain is a federation blockchain.
9. A data query apparatus, comprising:
the receiving and sending unit is used for receiving an inquiry instruction from a terminal, wherein the inquiry instruction is used for inquiring target information associated with a first intelligent contract deployed on a block chain;
the processing unit is configured to query a relational database according to the query instruction to obtain a query result, where information associated with the first intelligent contract stored in the relational database is determined by content obtained by analyzing a block on the block chain, the information associated with the first intelligent contract includes the target information, and the query result includes the target information;
the transceiver unit is further configured to send the query result to the terminal.
10. A data query device, comprising: a memory and a processor, the memory and the processor coupled;
the memory is to store one or more computer instructions;
the processor is configured to execute the one or more computer instructions to implement the method of any of claims 1 to 8.
11. A computer-readable storage medium having stored thereon one or more computer instructions for execution by a processor to perform the method of any one of claims 1 to 8.
CN202211260192.0A 2022-10-14 2022-10-14 Data query method and device Pending CN115640321A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211260192.0A CN115640321A (en) 2022-10-14 2022-10-14 Data query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211260192.0A CN115640321A (en) 2022-10-14 2022-10-14 Data query method and device

Publications (1)

Publication Number Publication Date
CN115640321A true CN115640321A (en) 2023-01-24

Family

ID=84944275

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211260192.0A Pending CN115640321A (en) 2022-10-14 2022-10-14 Data query method and device

Country Status (1)

Country Link
CN (1) CN115640321A (en)

Similar Documents

Publication Publication Date Title
TWI737944B (en) Block chain-based transaction execution method and device, and electronic equipment
US11431486B2 (en) System or method to implement consensus on read on distributed ledger/blockchain
US11824864B2 (en) Systems, methods, and apparatuses for implementing a declarative and metadata driven blockchain platform using distributed ledger technology (DLT)
US11811769B2 (en) Systems, methods, and apparatuses for implementing a declarative, metadata driven, cryptographically verifiable multi-network (multi-tenant) shared ledger
US20220006705A1 (en) Systems, methods, and apparatuses for implementing a metadata driven rules engine on blockchain using distributed ledger technology (dlt)
US11398914B2 (en) Blockchain-based data authorization method and apparatus
US11971874B2 (en) Systems, methods, and apparatuses for implementing efficient storage and validation of data and metadata within a blockchain using distributed ledger technology (DLT)
TWI724391B (en) Node management method and device based on blockchain
US20200169407A1 (en) Blockchain-based data authorization method and apparatus
TW202101440A (en) Cross-blockchain resource transmission
TW201820199A (en) Data access method, system and apparatus
US20220004539A1 (en) Privacy preserving architecture for permissioned blockchains
CN112182096A (en) Cross-link data subscription method and device
WO2022161181A1 (en) Data processing method and apparatus based on blockchain, and electronic device
US11615078B2 (en) Blockchain-based transaction methods
CN110032598B (en) Method and device for updating field and electronic equipment
TWI714414B (en) Method and device for obtaining block chain data in stages
CN111753335A (en) Editing method and device for block content
US20210256012A1 (en) Methods and apparatuses for reading and updating data structures, and electronic devices
US20230045056A1 (en) Database system public trust ledger architecture
WO2022206210A1 (en) Blockchain-based asset management
CN113077260A (en) Data access method and device based on block chain and electronic equipment
WO2020257123A1 (en) Systems and methods for blockchain-based authentication
WO2022206209A1 (en) Blockchain-based asset management
US20230367776A1 (en) Distributed metadata definition and storage in a database system for public trust ledger smart contracts

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination