Smart contract processing method and device, equipment, medium and product

By receiving client registration requests and simulating operating condition checks, it solves the problem that smart contracts in the blockchain network cannot be automatically executed, realizes automatic contract execution, reduces human errors, and improves the reliability and efficiency of the contract.

CN118779377APending Publication Date: 2024-10-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310396344.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-06
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

Smart contracts in existing blockchain networks cannot be automatically executed and require manual call of contract functions, resulting in failure of business functions to function normally and errors caused by human factors.

Method used

By receiving the registration request sent by the client, the business contract is simulated and the conditions are checked. If it passes, the transaction information is sent to the blockchain network to automatically execute the contract and avoid manual calls.

Benefits of technology

It realizes the automatic execution of smart contracts in the blockchain network, reduces human errors, and improves the reliability and efficiency of business contracts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779377A_ABST
    Figure CN118779377A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an intelligent contract processing method and device, equipment, a medium and a product, and the method comprises the steps that a server receives a registration request which is sent by a client and contains a business contract address, and the registration request is initiated after the client deploys a business contract in a block chain network; simulating and running the business contract according to the business contract address so as to perform condition check on the business contract; and if the condition check of the business contract is passed, transaction information is sent to the block chain network, so that the block chain network automatically executes the business contract based on the transaction information. According to the technical scheme provided by the embodiment of the invention, the block chain network can automatically execute the business contract, a contract function does not need to be manually called, and errors caused by human factors are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and more specifically, to a smart contract processing method, a smart contract processing device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In the related technology, smart contracts in blockchain networks cannot be executed automatically. If the business functions of the contract are to be exerted, the contract function needs to be called to trigger the execution. The current method requires manual construction and sending of transactions to call the contract function. The manual calling method is cumbersome and has uncertain human factors, which results in the failure to properly exert the business functions of the contract. Summary of the invention

[0003] To solve the above technical problems, the embodiments of the present application provide a smart contract processing method, a smart contract processing device, an electronic device, a computer-readable storage medium and a computer program product, which can enable the blockchain network to automatically execute business contracts without manually calling contract functions, thereby avoiding errors caused by human factors.

[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0005] According to one aspect of an embodiment of the present application, a smart contract processing method is provided, including: receiving a registration request containing a business contract address sent by a client, wherein the registration request is initiated by the client after deploying the business contract on a blockchain network; simulating the operation of the business contract according to the business contract address to perform a condition check on the business contract; if the condition check on the business contract passes, sending transaction information to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

[0006] According to one aspect of an embodiment of the present application, a smart contract processing method is also provided, including: obtaining a business contract address deployed in a blockchain network; sending a registration request to a server based on the business contract address, so that the server simulates the operation of the business contract through the business contract address to perform a condition check on the business contract, and after the condition check on the business contract passes, sending transaction information to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

[0007] According to one aspect of an embodiment of the present application, a smart contract processing device is provided, comprising: a receiving module for receiving a registration request containing a business contract address sent by a client, wherein the registration request is initiated by the client after deploying the business contract on a blockchain network; an operation module for simulating the operation of the business contract according to the business contract address to perform a conditional check on the business contract; and a sending module for sending transaction information to the blockchain network if the conditional check on the business contract passes, so that the blockchain network automatically executes the business contract based on the transaction information.

[0008] In one embodiment of the present application, the registration request also includes the triggering condition of the business contract; the operation module is further used to obtain the contract information of the business contract according to the business contract address, and locally build the execution environment of the business contract based on the contract information to register the business contract locally; if it is detected that the current execution environment parameters meet the triggering condition of the business contract, the business contract is simulated to perform a condition check on the business contract.

[0009] In one embodiment of the present application, the operation module is further used to simulate the operation of the business contract to obtain a condition check function in the business contract for performing a condition check; obtain an external data source, and check the condition check function according to the external data source to obtain a check result; if the check result indicates that the condition check function complies with a preset check logic, it is determined that the condition check on the business contract has passed.

[0010] In one embodiment of the present application, the sending module is further used to execute the business function of the business contract based on the acquired external data source if the condition check of the business contract is passed; if the execution result of the business function matches the expected execution result, the transaction information is sent to the blockchain network.

[0011] In one embodiment of the present application, the device also includes a processing module for obtaining a pending business corresponding to the business contract; if the pending business is a business that requires a resource amount greater than a preset resource amount, the pending business is executed according to the business function corresponding to the business contract to obtain a processing result; and the processing result is sent to the business contract deployed in the blockchain network for storage.

[0012] According to one aspect of an embodiment of the present application, a smart contract processing device is provided, including: an acquisition module, used to acquire a business contract address deployed in a blockchain network; a request module, used to send a registration request to a server based on the business contract address, so that the server simulates running the business contract through the business contract address to perform a condition check on the business contract, and after the condition check on the business contract is passed, sends transaction information to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

[0013] In one embodiment of the present application, the device also includes a deployment module, which is used to deploy a management contract in the blockchain network, and the management contract is used to record the contract information of each business contract; send a deployment transaction for the business contract to the blockchain network, so that the blockchain network writes the contract information of the business contract into the management contract based on the deployment transaction.

[0014] In one embodiment of the present application, the device also includes an update module, which is used to detect whether the current version of the business contract is deployed in the blockchain network if the local cache includes the contract information of the business contract; if it is detected that the current version of the business contract is not deployed in the blockchain network, send a version update transaction to the blockchain network to write the contract information of the current version of the business contract into the management contract.

[0015] In one embodiment of the present application, the device also includes a calling module, which is used to obtain the application binary interface information of the business contract from the management contract and write it into the local cache if it is determined that the local cache does not contain the application binary interface information of the business contract during the process of the blockchain network automatically executing the business contract; if it is determined that the local cache contains the application binary interface information of the business contract, call the business contract based on the application binary interface information of the business contract and obtain the calling result.

[0016] In one embodiment of the present application, the calling module is further used to obtain the interface to be called and the parameters of the interface in the business contract according to the application binary interface information; generate a calling transaction according to the interface to be called and the parameters of the interface, and send the calling transaction to the blockchain network to call the business contract.

[0017] In one embodiment of the present application, the calling module is further used to send a query request to the management contract of the blockchain network based on the contract name and contract version of the business contract, so that the management contract determines the corresponding business contract based on the contract name and contract version of the business contract; and receives the application binary interface information of the business contract sent by the management contract of the blockchain network.

[0018] According to one aspect of an embodiment of the present application, there is provided an electronic device, comprising one or more processors; and a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the smart contract processing method as described above.

[0019] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor of an electronic device, the electronic device executes the smart contract processing method as described above.

[0020] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the smart contract processing method as described above.

[0021] In the technical solution provided in the embodiments of the present application, the server receives a registration request including a business contract address sent by a client. The registration request is initiated by the client after deploying the business contract on the blockchain network. The server further simulates the operation of the business contract according to the business contract address to perform a condition check on the business contract. After the condition check on the business contract passes, the server sends transaction information to the blockchain network, and the blockchain network automatically executes the business contract based on the transaction information. In other words, the client only needs to deploy the business contract on the blockchain network, and the server performs a condition check through simulated operation to ensure the correctness of the business contract. After that, the blockchain network automatically executes the business contract through transaction triggering. There is no need to manually call the contract function to execute the business contract, thereby avoiding errors caused by human factors.

[0022] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0024] Figure 1 It is a schematic diagram of the structure of the blockchain network;

[0025] Figure 2 It is a schematic diagram of the connection relationship between blocks in the blockchain;

[0026] Figure 3 It is a schematic diagram of an implementation environment involved in this application;

[0027] Figure 4 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0028] Figure 5 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0029] Figure 6 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0030] Figure 7 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0031] Figure 8 is a flowchart of another smart contract processing method shown in an exemplary embodiment of the present application;

[0032] Fig. 9 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0033] Fig.10 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0034] Fig.11 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0035] Fig.12 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0036] Fig.13 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0037] Fig.14 is a flow chart of a smart contract processing method shown in an exemplary embodiment of the present application;

[0038] Fig.15 It is a schematic diagram of an overall framework of smart contract deployment and invocation shown in another exemplary embodiment of the present application;

[0039] Fig.16 is a flowchart of deploying and calling a smart contract shown in another exemplary embodiment of the present application;

[0040] Fig.17 is a schematic diagram of a storage implementation of a management contract shown in another exemplary embodiment of the present application;

[0041] Fig.18 is a flowchart of deploying a service contract shown in another exemplary embodiment of the present application;

[0042] Fig.19 is a flowchart of calling a business contract shown in another exemplary embodiment of the present application;

[0043] Fig. 20 is a schematic diagram of a framework for automatically executing a smart contract as shown in yet another exemplary embodiment of the present application;

[0044] Fig.21 is a flowchart of an automatic execution of a smart contract shown in another exemplary embodiment of the present application;

[0045] Fig. 22 is a schematic diagram of an interface description of a node in a server shown in yet another exemplary embodiment of the present application;

[0046] Fig.23 is a structural block diagram of a smart contract processing device shown in an exemplary embodiment of the present application;

[0047] Fig.24 is a structural block diagram of a smart contract processing device shown in an exemplary embodiment of the present application;

[0048] Fig.25 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0049] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0050] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0051] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0052] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.

[0053] The technical solution of the embodiment of the present application relates to the field of blockchain technology. Before introducing the technical solution of the embodiment of the present application, a brief introduction to blockchain technology is first given.

[0054] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks (i.e. blocks) generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0055] As mentioned above, blockchain is essentially a decentralized database, and the blockchain is maintained by the nodes in the blockchain network. Figure 1 ,exist Figure 1The blockchain network shown may include multiple nodes 101, and the multiple nodes 101 may be various servers and terminals forming the blockchain network. Each node 101 may receive input information during normal operation, and maintain the shared data in the blockchain network based on the received input information. In order to ensure the information intercommunication within the blockchain network, there may be an information connection between each node in the blockchain network, and the nodes may transmit information through the above information connection. For example, when any node in the blockchain network receives input information, other nodes in the blockchain network obtain the input information according to the consensus algorithm, and store the input information as shared data, so that the data stored on all nodes in the blockchain network are consistent.

[0056] Each node in the blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes, so that the generated blocks can be broadcast to other nodes in the blockchain network according to the node identifiers of other nodes. A node identifier list can be maintained in each node, and the node name and node identifier are stored in the node identifier list accordingly. The node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the node.

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

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

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

[0060] Among them, the business implemented by the application includes: smart contracts. Smart contracts are a computerized protocol that can execute the terms of a contract. They are implemented through codes deployed on a shared ledger for execution when certain conditions are met. The codes are used to complete automated transactions based on actual business needs. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received data.

[0061] See also Figure 2The blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores input information feature values, version numbers, timestamps, and difficulty values, and the block body stores input information. The next block of the genesis block uses the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores the input information feature values ​​of the current block, the block header feature values, version numbers, timestamps, and difficulty values ​​of the parent block, and so on. This ensures that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, thereby ensuring the security of the input information in the block.

[0062] It is understandable that each node in the blockchain network can be a server or a terminal. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing (Cloud Computing), cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and intelligent platforms. The terminal can be a smart phone, a tablet computer, a laptop, a desktop computer, a smart speaker, a smart watch, a terminal used in a car, an aircraft, etc., but is not limited to this. Each node can be directly or indirectly connected by wired or wireless communication, and this application is not limited here.

[0063] The technical solution of the embodiment of the present application specifically relates to blockchain technology. The technical solution of the embodiment of the present application is described in detail below:

[0064] See also Figure 3 , Figure 3 30 is a schematic diagram of an implementation environment involved in the present application. The implementation environment mainly includes a client 301, a server 302 and a blockchain network 303.

[0065] Among them, the client 301 is used to deploy smart contracts in the blockchain network and obtain the contract address of the smart contract deployed in the blockchain network. The smart contract can be a business contract or a management contract for managing various business contracts; the client includes but is not limited to smart phones, tablets, laptops, computers, intelligent voice interaction devices, smart home appliances, terminals used in cars, aircraft, etc. The client includes a remote procedure call module, which is connected to the blockchain network through this module.

[0066] The server 302 receives the registration request including the business contract address sent by the client, and then simulates the operation of the business contract according to the business contract address to perform a condition check on the business contract. If the condition check on the business contract passes, the transaction information is sent to the blockchain network. Among them, the server can be a server that provides various services, which can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and intelligent platforms. This is not limited here.

[0067] Blockchain network 303 is the aforementioned blockchain network, which automatically executes the business contract based on the transaction information sent by the server. Blockchain network 303 may be one or more, and this is not limited here.

[0068] In an embodiment of the present application, the client is also used to call a business contract in the blockchain network and obtain the call result.

[0069] It should be noted that in the specific implementation of this application, if the business contract involves objects, when the embodiments of this application are applied to specific products or technologies, it is necessary to obtain the permission or consent of the object, and the collection, use and processing of relevant data need to comply with the relevant regulations and standards of relevant countries and regions.

[0070] The following is a detailed description of various implementation details of the technical solution of the embodiment of the present application:

[0071] like Figure 4 As shown, Figure 4 is a flowchart of a smart contract processing method shown in an embodiment of the present application, which can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 The smart contract processing method may include steps S410 to S430, which are described in detail as follows:

[0072] S410: Receive a registration request including a business contract address sent by a client, where the registration request is initiated by the client after deploying the business contract on the blockchain network.

[0073] In the embodiment of the present application, the business contract refers to the program code running on the node that can perform any calculation and realize complex logic. The program code indicates the execution process and processing logic of the business contract, such as input, output, intermediate conversion logic, etc. The client deploys the business contract in the blockchain network and can obtain the business contract address of the business contract in the blockchain network. The business contract address is used to uniquely identify the location of the business contract.

[0074] In one example, the business contract is developed and compiled by the client, for example, through an application programming interface (API) to develop a smart contract, and the API is used to implement business functions. Since the business contract runs in the virtual machine of the blockchain network and the business contract is in the form of bytecode on the blockchain, after the business contract file in a compiled programming language is developed, the business contract file needs to be compiled to obtain the business contract.

[0075] It should be noted that after the business contract is deployed on the blockchain network, the blockchain network does not immediately run the business contract, and the client needs to perform a conditional check through the server. Therefore, the server will receive a registration request sent by the client, which includes the business contract address. The registration request is used to instruct the server to perform a conditional check on the business contract.

[0076] S420. Simulate and run the business contract according to the business contract address to perform a condition check on the business contract.

[0077] In the embodiment of the present application, the server can obtain the relevant information of the corresponding business contract based on the business contract address, and simulate the business contract locally based on the relevant information of the business contract to realize the conditional check of the business contract. Among them, the simulated operation refers to the complete simulation reproduction of various states in the real environment in a virtual environment that is very realistic with the real situation, so as to run in accordance with the situation consistent with the real state to achieve the purpose of inspection; that is to say, the simulated operation is a virtual operation of the real business contract, not the real business contract is run locally.

[0078] In an embodiment of the present application, the server can fully simulate and reproduce the various states in the operation process of the business contract by simulating the operation of the business contract, and then perform a conditional check on the business contract, wherein the conditional check refers to checking whether the conditions defined in the business contract are met, including checking the conditions that trigger the execution process and processing logic of the business contract.

[0079] S430. If the condition check of the business contract passes, the transaction information is sent to the blockchain network so that the blockchain network automatically executes the business contract based on the transaction information.

[0080] In an embodiment of the present application, if the condition check of the business contract passes, it means that the business contract can be triggered and executed normally. At this time, the server sends transaction information to the blockchain network. The transaction information can reflect the correctness of the business contract and is used to instruct the blockchain network to automatically execute the business contract, and then the blockchain network can automatically execute the business contract based on the transaction information. In some embodiments, if the condition check of the business contract fails, the server can simulate the business conditions for multiple times. If the number of times the condition check of the business contract fails is greater than the preset number threshold, the server can send fault information to the client and the blockchain network respectively. The fault information is used to indicate that there is a problem with the business contract, and then the client and the blockchain network perform corresponding processing on the business contract.

[0081] In one example, the blockchain network automatically executes a business contract based on transaction information. The blockchain network responds to the transaction information and automatically runs the business contract. The business contract can automatically execute the corresponding business function based on condition checks to achieve the business function.

[0082] In an embodiment of the present application, the server receives a registration request including a business contract address sent by a client, the registration request is initiated by the client after deploying the business contract on the blockchain network, and further simulates the operation of the business contract according to the business contract address to perform a condition check on the business contract. After the condition check on the business contract passes, the server sends transaction information to the blockchain network, and the blockchain network automatically executes the business contract based on the transaction information; that is, the client only needs to deploy the business contract on the blockchain network, and the server performs a condition check through simulated operation to ensure the correctness of the business contract, and then triggers the transaction to enable the blockchain network to automatically execute the business contract, without the need to manually call the contract function, thereby avoiding errors caused by human factors.

[0083] In one embodiment of the present application, another smart contract processing method is provided, which can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the server Figure 5 As shown in Figure 4On the basis of, S420 is expanded to S510~S520. The registration request in S410 also includes the triggering condition of the business contract, which is used to indicate how to trigger the simulated operation of the business contract. In one example, the triggering condition can be set by the client, for example, the triggering condition is the time to trigger the simulated operation of the business contract, such as simulating the operation of the business contract once every certain period of time; for another example, the triggering condition can be other custom conditions, which correspond to the business function corresponding to the business contract, such as the business function resource transaction corresponding to the business contract, and the triggering condition is that the resource conversion ratio corresponding to the resource to be traded reaches a threshold.

[0084] Steps S510 to S520 are described in detail as follows:

[0085] S510. Obtain the contract information of the business contract according to the business contract address, and build an execution environment of the business contract locally based on the contract information to register the business contract locally.

[0086] In the embodiment of the present application, the server extracts the business contract address from the registration request, and can obtain the contract information of the business contract from the blockchain network through the business contract address, which includes but is not limited to the name of the business contract, the deployment transaction hash, the contract's application binary interface (ABI) and other information. The server constructs a virtual execution environment that is very realistic with the actual situation of the on-chain business contract locally through the business contract address, and runs the business contract in the execution environment to realize the registration of the business contract locally. Among them, the execution environment of the business contract includes but is not limited to the time environment, the number of executions of the business contract, and other set environmental information.

[0087] S520: If it is detected that the current execution environment parameters meet the triggering conditions of the business contract, the business contract is simulated and run to perform a condition check on the business contract.

[0088] It is understandable that if the registration request includes the triggering conditions of the business contract, it is necessary to detect whether the current execution environment parameters meet the triggering conditions of the business contract. If the current execution environment parameters meet the triggering conditions of the business contract, such as the triggering conditions of the business contract are 15:00-14:00, and the current execution environment parameters are the current time; if the current time is detected to be 15:02, it means that the triggering conditions of the business contract are met, then the business contract is simulated and run to implement the conditional check of the business contract.

[0089] In other embodiments of the present application, if it is detected that the current execution environment parameters do not meet the triggering conditions of the business contract, the current execution environment parameters are detected in a loop; in one example, in the process of detecting the current execution environment parameters in a loop, if the current execution environment parameters do not meet the triggering conditions of the business contract, the server can send a trigger failure message to the client, so that the client can modify the triggering conditions of the business contract.

[0090] It should be noted that Figure 5 For more detailed description of steps S410 and S430, see Figure 4 Steps S410 and S430 shown are not repeated here.

[0091] In the embodiment of the present application, after obtaining the contract information of the business contract, the server constructs an execution environment for the business contract locally to register the business contract locally, and then simulates the operation of the business contract only after the current execution environment parameters meet the triggering conditions of the business contract to ensure the reliability of the triggering of the business contract.

[0092] The present application embodiment provides another smart contract processing method, which can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the server Figure 6 As shown, the smart contract processing method will Figure 5 The S520 shown in FIG. 1 is extended to steps S610 to S630. Steps S610 to S630 are described in detail as follows:

[0093] S610: If it is detected that the current execution environment parameters meet the triggering conditions of the business contract, the business contract is simulated and run to obtain a condition check function in the business contract for condition check.

[0094] In an embodiment of the present application, the business contract includes a conditional check function for performing conditional checks. During the simulation of the business contract, the conditional check function in the business contract can be obtained because the operation is completely consistent with the actual state.

[0095] It should be noted that the conditional check function in the embodiment of the present application has its own conditional check logic, which is generated when developing a business contract. For example, the conditional check logic is to check whether the account address of the calling contract is a specific account address.

[0096] S620: Acquire an external data source, and check the condition check function according to the external data source to obtain a check result.

[0097] In an embodiment of the present application, the server can obtain an external data source, which can be flexibly adjusted according to different conditional check logics. For example, the external data source is the account address of the calling contract, and the account address is a specific account address. If the conditional check function is checked according to the external data source, and it is found that the external data source is a specific account address, it means that the conditional check function is correct. If the conditional check function finds that the external data source is not a specific account address, it means that there is a problem with the conditional check function.

[0098] In one example, when checking a conditional check function based on an external data source, it is necessary to check the checking process of the conditional check function. For example, for an external data source, the preset checking process is: the conditional check function will first check whether the external data source matches the business contract. If it matches, it will further check the relationship between the external data source and the specific account address; if the conditional check function does not check according to the normal checking process, it means that there is a problem with the conditional check function.

[0099] In some examples, multiple different types of external data sources may be obtained, and multiple checks may be performed on the condition check function through the different types of external data sources to improve the accuracy of the check.

[0100] S630. If the check result indicates that the conditional check function complies with the preset check logic, it is determined that the conditional check on the business contract passes.

[0101] In an embodiment of the present application, the conditional check function is checked to obtain a check result, and the check result includes whether the conditional check function is correct or the conditional check function is wrong. If the test result indicates that the conditional check function complies with the preset check logic, it is determined that the conditional check of the business contract has passed, wherein the preset check logic, i.e., the conditional check function, is executed normally, and the conditional check logic is correct and complete.

[0102] It should be noted that Figure 6 For a detailed description of steps S410, S510, and S430, see Figure 5 Steps S410, S510, and S430 shown are not repeated here.

[0103] In an embodiment of the present application, a conditional check function used for conditional checking in a business contract is checked through an external data source to determine whether the conditional check function is executed normally and the correctness and completeness of the conditional check logic, thereby providing accuracy of the conditional check on the business contract.

[0104] The present application also provides another smart contract processing method, which can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the server Figure 7 As shown, the smart contract processing method will Figure 4 The S430 shown in FIG. 1 is expanded into steps S710 to S720. Steps S710 to S720 are described in detail as follows:

[0105] S710: If the condition check of the business contract passes, the business function of the business contract is executed based on the acquired external data source.

[0106] In an embodiment of the present application, if the condition check of the business contract is passed, the business contract can be triggered and executed normally. It is also necessary to check whether the execution process of the business contract is normal. At this time, it is necessary to obtain an external data source, which corresponds to the business function corresponding to the business contract. For example, if the business contract is a resource transaction, the external data source is the account address corresponding to the resource.

[0107] The server executes the business function of the business contract based on the external data source. The business function is used to complete certain business logic, such as transferring resources into or out of the account address corresponding to the resource.

[0108] S720. If the execution result of the business function matches the expected execution result, the transaction information is sent to the blockchain network.

[0109] In an embodiment of the present application, if the execution result of the business function matches the expected execution result, such as a resource is transferred in or out of the account address corresponding to the resource, it means that the execution process of the business contract is normal, the business logic is correct, and the server sends transaction information to the blockchain network.

[0110] If the execution result of the business function does not match the expected execution result, it means that the business logic is incorrect. At this time, a new external data source can be obtained again, and the business function of the business contract can be re-executed based on the new external data source. If the re-execution result still does not match the corresponding expected execution result, the server can send operation identification information to the client and server, and then the client and server will perform corresponding processing on the business contract.

[0111] It should be noted that Figure 7 For more detailed description of steps S410 to S420 shown in Figure 4 Steps S410 to S420 shown in FIG. 1 are not described in detail here.

[0112] In an embodiment of the present application, after the condition check of the business contract is passed, the business function of the business contract is further tested to determine whether the execution process and business logic of the business contract are normal, thereby further ensuring the correctness and reliability of the business contract.

[0113] In one embodiment of the present application, another smart contract processing method is also provided, which can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the server Figure 8 As shown in Figure 4 Based on the above, S810 to S830 are added. Steps S810 to S830 are described in detail as follows:

[0114] S810: Obtain pending business corresponding to the business contract.

[0115] In an embodiment of the present application, the business contract can be simulated and run in the server, and the business contract runs normally and correctly. The server can also process the corresponding business based on the business contract off-chain. First, the pending business corresponding to the business contract is obtained, wherein the business logic of the business contract can process the pending business.

[0116] In one example, the pending business may be sent by a client or by a blockchain network, which is not limited here.

[0117] S820: If the business to be processed is a business that requires a resource amount greater than a preset resource amount, the business to be processed is executed according to the business function corresponding to the business contract to obtain a processing result.

[0118] In an embodiment of the present application, it is necessary to determine whether the amount of resources required for the business to be processed is greater than the preset amount of resources, where the required amount of resources refers to the amount of computing resources, that is, whether the business to be processed will consume more computing resources (such as CPU, memory). If the business to be processed requires more resources than the preset amount of resources, it means that more computing resources are required to process the business to be processed. The server can execute the business to be processed off-chain based on the business function corresponding to the business contract to obtain the processing result.

[0119] It should be noted that the server executes and processes business based on the business function corresponding to the business contract off-chain, which means that the server simulates the operation of the business contract locally and executes and processes the business through the simulated business function. Although it is simulated, since the simulated business contract is executed normally and correctly, the processing result obtained by the server through the simulated business contract to execute the business to be processed is also correct.

[0120] S830. Send the processing result to the business contract deployed in the blockchain network for storage.

[0121] In an embodiment of the present application, the server sends the processing results to the business contract deployed in the blockchain network for storage, that is, the server processes the pending business off-chain, reduces the on-chain overhead, and the processing results are stored on the chain.

[0122] In one example, after obtaining the processing result, the server can encrypt the processing result and then store the encrypted processing result on the chain to improve security.

[0123] It should be noted that Figure 8 For more detailed description of steps S410 to S430 shown in Figure 4 The steps S410 to S430 shown are not described in detail here.

[0124] In an embodiment of the present application, for pending businesses that require more computing resources, the server can execute the pending businesses based on the business functions corresponding to the business contracts off-chain to obtain processing results, and store the processing results on-chain to reduce on-chain overhead.

[0125] Figures 4 to 8 The embodiment shown is explained from the perspective of the server. Figures 9 to 14 The implementation details of the technical solution of the embodiment of the present application are elaborated in detail from the perspective of the client:

[0126] The present application embodiment provides another smart contract processing method, which includes a method that can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the client Fig. 9 As shown, the smart contract processing method includes S910 to S920. Steps S910 to S920 are described in detail as follows:

[0127] S910. Obtain the business contract address deployed in the blockchain network.

[0128] In an embodiment of the present application, the client deploys the business contract in the blockchain network, and then receives the business contract address sent by the blockchain network.

[0129] S920. Send a registration request to the server based on the business contract address, so that the server simulates the operation of the business contract through the business contract address to perform a condition check on the business contract, and after the condition check on the business contract passes, send transaction information to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

[0130] In the embodiment of the present application, the client can generate a registration request based on the business contract address, that is, the registration request includes the business contract address, and then the server performs corresponding processing based on the business contract address. For the specific process, please refer to Figure 4 As shown, no further description is given here.

[0131] In the embodiment of the present application, no processing is required for the object. The client deploys the blockchain, and the server performs conditional checks through simulation operations to ensure the correctness of the business contract. After that, the blockchain network automatically executes the business contract through transaction triggers, without the need to manually call the contract function, thereby avoiding errors caused by human factors.

[0132] The present application embodiment provides another smart contract processing method, which includes a method that can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the client Fig.10 As shown in Fig. 9 Steps S1010 to S1020 are added before S910 shown in FIG. Steps S1010 to S1020 are described in detail as follows:

[0133] S1010. Deploy a management contract in the blockchain network, where the management contract is used to record the contract information of each business contract.

[0134] In an embodiment of the present application, the client deploys a management contract in the blockchain, which can be a management contract deployed after the blockchain network is built and before it is officially put into operation. The management contract is used to associate business contracts and record the contract information of each business contract.

[0135] In one example, a client sends a contract deployment request to a blockchain network, and the blockchain network extracts a management contract from the contract deployment request and deploys it.

[0136] S1020. Send a deployment transaction for the business contract to the blockchain network, so that the blockchain network writes the contract information of the business contract into the management contract based on the deployment transaction.

[0137] In an embodiment of the present application, after deploying the management contract, the client sends a deployment transaction for the business contract to the blockchain network. The deployment transaction is used to instruct the blockchain network to deploy the business contract, that is, by writing the contract information of the business contract into the management contract.

[0138] Among them, the business contract is developed and compiled by the client. The deployment transaction includes the contract ABI and the description information of the business contract, such as the functional information implemented by the contract, the interface information of the contract, and the specific bytecode corresponding to the contract; then the blockchain network generates contract information for the business contract based on the contract ABI and description information, such as the contract address and deployment hash value, and then writes the contract information into the management contract.

[0139] It should be noted that Fig.10 For a detailed description of steps S910 to S920, see Fig. 9 Steps S910 to S920 shown in FIG. 1 are not described in detail here.

[0140] In the embodiment of the present application, a management contract is first deployed in the blockchain network, and the contract information of the business contract is written into the management contract through a deployment transaction to realize the deployment of the business contract, thereby ensuring the effective management of the contract information of the business contract.

[0141] The present application embodiment provides another smart contract processing method, which includes a method that can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the client Fig.11 As shown in Fig.10 Based on the above, steps S1110 to S1120 are added after S1020. Steps S1110 to S1120 are described in detail as follows:

[0142] S1110. If the local cache includes the contract information of the business contract, check whether the current version of the business contract is deployed in the blockchain network.

[0143] In an embodiment of the present application, the client has a local cache for storing description information of the business contract, wherein the description information stored therein is a subset of the business contract information in the management contract; in some examples, after the client deploys the business contract on the blockchain network, the local cache is also used to store the contract information of the business contract written into the management contract for quick retrieval.

[0144] If the local cache includes the contract information of the business contract, it means that the business contract has been deployed in the blockchain network. It is necessary to further check whether the current version of the business contract has been deployed in the blockchain network. The current version refers to the latest version, that is, to determine whether the version number of the business contract deployed in the blockchain network is the same as the version number of the latest version.

[0145] In other embodiments of the present application, if the local cache does not contain the contract information of the business contract, at this time, the client can request the management contract to obtain the contract information of the business contract from the management contract and update it to the local cache.

[0146] S1120. If it is detected that the current version of the business contract is not deployed in the blockchain network, a version update transaction is sent to the blockchain network to write the contract information of the current version of the business contract into the management contract.

[0147] In an embodiment of the present application, if it is detected that the current version of the business contract is not deployed in the blockchain network, it is necessary to update the version of the business contract of the blockchain network, and the server sends a version update transaction to the blockchain network. The version update transaction carries the description information of the current version of the business contract, and then the blockchain network writes the contract information of the current version of the business contract in the management contract based on the version update transaction. For example, the blockchain network can modify part of the business contract in the management contract based on the description information of the current version of the business contract, such as modifying the contract ABI, deployment transaction hash and contract version number, without modifying the contract address and contract name.

[0148] It should be noted that Fig.11 For detailed description of steps S1010-S1020 and S910-S920, please refer to Fig.10 Steps S1010 to S1020 and S910 to S920 shown in the figure are not repeated here.

[0149] In the embodiment of the present application, for the version update of the business contract, there is no need for the object to manually manage different versions of the contract. Only the client needs to interact with the blockchain network to facilitate the upgrade of the business contract.

[0150] It is worth noting that the present application embodiment provides another smart contract processing method, which can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the client Fig.12 As shown in Fig. 9 Steps S1210 to S1220 are added after S920 shown in FIG. Among them, steps S1210 to S1220 are the process of calling the business contract of the client, which are described in detail as follows:

[0151] S1210. During the process of automatically executing a business contract on the blockchain network, if it is determined that the local cache does not contain the application binary interface information of the business contract, the application binary interface information of the business contract is obtained from the management contract and written into the local cache.

[0152] In the embodiment of the present application, the blockchain network will automatically execute the business contract based on the transaction information sent by the server. During this process, the client can call the business contract, and calling the business contract requires the target contract information of the business contract. The ABI information defines the method and structure for interacting with the binary contract. The ABI information includes the interface list, interface name, parameter name, parameter type, return type, etc. of the contract. As described above, what is stored in the client local cache is a subset of the business contract information in the management contract. Therefore, it is necessary to first determine whether the local cache contains the ABI information of the business contract. If it is determined that the local cache does not contain the ABI information of the business contract, the server obtains the ABI information of the business contract from the management contract and writes it to the local cache.

[0153] In other embodiments of the present application, if the server fails to obtain the ABI information of the business contract from the management contract, it means that the blockchain network has not deployed the business contract and the call fails.

[0154] S1220: If it is determined that the local cache contains the application binary interface information of the business contract, the business contract is called based on the application binary interface information of the business contract, and the calling result is obtained.

[0155] In an embodiment of the present application, if it is determined that the local cache contains ABI information of the business contract, the server will define the method and structure for interacting with the binary contract based on the ABI information of the business contract to call the business contract and obtain the call result.

[0156] It should be noted that Fig.12 For a detailed description of steps S910 to S920, see Fig. 9 Steps S910 to S920 shown in FIG. 1 are not described in detail here.

[0157] In an embodiment of the present application, during the process of automatic execution of a business contract on the blockchain network, the client can also call the business contract, obtain ABI information from the management contract, and write it into the local cache for subsequent calls, and then call the business contract based on the ABI information to ensure that the business contract can be called correctly without the need for manual object calling.

[0158] The present application embodiment provides another smart contract processing method, which includes a method that can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the client Fig.13 As shown in Fig.12 The S1220 shown in FIG. 1 is expanded into steps S1310 to S1320. S1310 to S1320 are described in detail as follows:

[0159] S1310: If it is determined that the local cache contains the application binary interface information of the business contract, the interface to be called and the parameters of the interface in the business contract are obtained according to the application binary interface information.

[0160] In the embodiments of the present application, it can be understood that the business contract implements multiple functions, such as resource conversion and trading of converted resources, and the ABI information of the business contract includes multiple interfaces corresponding to the multiple functions and parameters of each interface. Therefore, the server obtains the interface to be called in the business contract and the parameters of the interface according to the ABI information.

[0161] When obtaining the interface to be called, the client can also select an interface corresponding to the function from multiple interfaces as the interface to be called based on the function to be implemented, and then obtain the parameter name, parameter type and return type of the interface to be called.

[0162] S1320. Generate a call transaction according to the interface to be called and the parameters of the interface, and send the call transaction to the blockchain network to call the business contract.

[0163] In an embodiment of the present application, after obtaining the interface to be called and the parameters of the interface, the interface to be called and the parameters are encoded in a specific format according to the interface type list and converted into binary data to generate a call transaction, which is then sent to the blockchain network; in one example, similarly, when obtaining the call result of the business contract, the call interface needs to be decoded in a characteristic format.

[0164] It should be noted that Fig.13 For a detailed description of steps S910 to S920 and S1210 shown in Fig.12 Steps S910 to S920 and S1210 shown in FIG. 1 are not described in detail here.

[0165] The present application embodiment provides another smart contract processing method, which includes a method that can be applied to Figure 3 In the implementation environment shown, the method can be implemented by Figure 3 , as shown in the client Fig.14 As shown in Fig.12 The S1210 shown in FIG. 1 is expanded into steps S1410 to S1420. S1410 to S1420 are described in detail as follows:

[0166] S1410. During the process of automatic execution of a business contract by the blockchain network, if it is determined that the local cache does not contain the application binary interface information of the business contract, a query request is sent to the management contract of the blockchain network based on the contract name and contract version of the business contract, so that the management contract determines the corresponding business contract based on the contract name and contract version of the business contract.

[0167] In an embodiment of the present application, the management contract stores the contract name of the business contract and the correspondence between the contract version and the contract address, that is, the contract name and contract version number are used as key values ​​to uniquely determine the address of the business contract. Since the management contract stores the contract information of multiple business contracts, when the client needs to obtain the ABI information of the business contract from the management contract, it needs to send a query request to the management contract of the blockchain. The query request includes the contract name and contract version of the business contract. The management contract uniquely determines the business contract through the key value, and then the management contract can find the contract information of the business contract.

[0168] S1420. Receive application binary interface information of the business contract sent by the management contract of the blockchain network.

[0169] In some examples, the query request also carries information required by the client. Therefore, after searching for the contract information of the business contract, the management contract filters out the ABI information and sends the ABI information of the business contract to the client.

[0170] In the embodiment of the present application, the business contract can be uniquely located by the contract name and contract version, without the need for a contract ABI, which facilitates the management of the business contract by the contract manager and is not convenient for server positioning.

[0171] For ease of understanding, the following is based on Figure 3 The implementation environment shown provides a detailed description of the smart contract processing method provided in the embodiment of the present application: wherein the smart contract processing includes the process of automatically deploying and calling the smart contract and the process of automatically executing the smart contract.

[0172] like Fig.15 As shown, the overall framework for the deployment and invocation of smart contracts includes: objects, clients, and blockchain networks, where objects interact with the blockchain through clients, such as deploying and invoking business contracts.

[0173] The client includes:

[0174] Client main program APP: controls the local cache and interacts with the blockchain through RPC.

[0175] Local Cache: stores business contract information, which is a subset of the business contract information in the management contract for quick and easy access.

[0176] Remote procedure call module RPC: Communicate and interact with the blockchain network through this module, such as jsonrpc (a stateless and lightweight remote procedure call (RPC) transmission protocol), grpc (a high-performance, open source and general RPC framework), etc.

[0177] Blockchain Network:

[0178] Management Contract (MC): Manages business contracts and stores relevant information of business contracts.

[0179] Business Contract (BC): A contract that implements business functions and is the contract that users actually interact with when performing business operations.

[0180] Storage: The actual storage of the blockchain system, such as the Key-Value database of each blockchain node program.

[0181] like Fig.16 As shown, the process of automatically deploying and calling smart contracts executed by the client includes: S1601, deploying management contracts. S1602, deploying business contracts. S1603, maintaining business contract information through management contracts. S1604, calling business contracts. S1605, obtaining calling results.

[0182] Among them, there is only one management contract, but there can be multiple business contracts. If multiple business contracts are deployed, S1602 and S1603 can be performed multiple times; in the embodiment of the present application, the client can call the business contract multiple times.

[0183] In the embodiment of the present application, both the deployment of business contracts and the calling of business contracts depend on the management contract. Generally, after the blockchain system is built, it is necessary to deploy the management contract before the formal operation to start recording the relevant information of the relevant business contracts. After the management contract is deployed, when the object wants to deploy the business contract, it does not directly send a transaction to the blockchain for deployment, but deploys it through the client; when deploying the business contract, the client will interact with the management contract to maintain the relevant information of the business contract. The management contract is transparent to the object, and the client automatically completes the relevant interaction; after completing the "deployment of the business contract", when the object wants to call the business contract, it does not directly send a transaction to the blockchain for calling, but calls it through the client. The object calls the business contract through the client, and the client will automatically parse the call results such as the output and logs of the business contract, and the call results presented to the object are human-readable.

[0184] Among them, the management contract maintains the relevant information of the business contract. In an example, the contract information of the business contract stored in the management contract is shown in Table 1 below.

[0185]

[0186]

[0187] Table 1

[0188] The management contract stores the correspondence between the business contract name and the contract address. The user only needs to remember the business contract name and enter the contract name into the client. The client can locate the business contract through the management contract of the blockchain network. Since the management contract stores the contract information of the business contract, the client can obtain the contract information of the business contract after locating the business contract through the management contract. The contract information of the business contract includes ABI information. The client can obtain the callable interface and its formal parameters in the contract through the ABI information, and call the corresponding contract interface by inputting the parameters. The storage of the contract ABI can be not a string, but other encodings.

[0189] In an embodiment of the present application, the contract information of the business contract also includes contract description information, and the object can also learn more information from it, such as the contract description information is used to describe the function of the contract and the corresponding role of the interface in the contract.

[0190] The contract information of a business contract also includes the contract version number. If the object wants to upgrade the business contract, that is, deploy business contracts with the same contract name but different version numbers, there is no need to manually manage different versions of the contract. The client and the management contract complete the corresponding logic. It should be noted that whether deploying or calling a business contract, the address information of the business contract is transparent to the user.

[0191] In one example, the contract version information of the business contract stored in the management contract is shown in Table 2 below.

[0192] Fields illustrate Example Value contract_name Contract Name HelloWorld contract_versions Historical contract version number ["1.0","1.1","2.0"]

[0193] Table 2

[0194] The contents of the contract version record table include: contract name, historical contract version number. The historical contract version number is a record of all historical version numbers of the contract name, which can be stored as an array.

[0195] In the embodiment of the present application, the storage implementation description of the management contract is as follows Fig.17As shown, contract_entry = contract_name + contract_version. contract_entry, i.e., the contract name (contract_name) and the contract version number (contract_version) are used as key values ​​to uniquely determine the address of the business contract actually called.

[0196] like Fig.18 As shown in the figure, the process of deploying a business contract BC with version number V includes:

[0197] S1801. Check whether the BC information is in the local cache of the client. If yes, jump to S1803; otherwise, jump to S1802.

[0198] S1802. If BC is not in the cache, obtain the contract information of BC from the management contract MC and update it to the local cache of the client.

[0199] S1803. Check whether the contract BC to be deployed already exists in the blockchain for version number V. If yes, jump to S1805; otherwise, jump to S1804.

[0200] S1804. Send transaction deployment BC, write BC information to MC, and update local cache accordingly.

[0201] S1805, end.

[0202] like Fig.19 As shown, the process of calling the business contract BC includes:

[0203] S1901, check whether the BC information is in the local cache of the client. If yes, it means that the contract BC exists, jump to step S1904; otherwise, jump to step S1902.

[0204] S1902, check whether BC is in MC. If yes, it means that the contract BC exists, jump to S1903; otherwise, it means that the contract BC does not exist, the call fails, jump to S1905.

[0205] S1903. After obtaining the BC information from the MC, the BC information is written into the client local cache for the convenience of the next call.

[0206] S1904. The client constructs a transaction with the BC information in the local cache and sends it to the blockchain to complete the actual interaction logic with the business contract; the ABI information therein can be used to construct a transaction in combination with the interface name and parameters entered by the user.

[0207] S1905, end.

[0208] like Fig. 20 As shown, the framework for automatically executing smart contracts includes:

[0209] Client: Same as the client mentioned above, users interact with the blockchain and server through the client.

[0210] Blockchain: Blockchain network, business contracts BC are deployed on the blockchain network.

[0211] Server: It is composed of multiple nodes, which complete the automatic execution (call) of the function of the business contract BC. Each time a node is triggered, it will simulate the business contract BC locally to perform a condition check. Only after the condition check passes will the node continue to send transactions to the BC on the blockchain to complete the automatic execution logic of the function.

[0212] In one example, some nodes in the server are selected to simulate and run the business contract respectively, and whether the condition check of the business contract passes is determined based on the condition check result of each node. For example, if the condition check results of more than half of the nodes pass, it is determined that the condition check of the business contract passes.

[0213] like Fig.21 As shown, the process of automatically executing the smart contract includes: S2101, the client deploys the business contract, S2102, the client registers the business contract on the server, S2103, the server detects whether the trigger condition is met, S2104, the server simulates the operation of the smart contract to perform condition checks, and S2105, the server sends a transaction to automatically execute the smart contract.

[0214] In an embodiment of the present application, the business contract is deployed in the same business contract deployment process. When a user wants to deploy a business contract, instead of sending a transaction directly to the blockchain for deployment, it is deployed through the client. Get the contract address address. After completing the "deployment of the business contract", if you want the business contract to be automatically executed, the client can register the business contract address on the server through the client and set the trigger conditions and other parameters. After registration, the node in the server will automatically check whether the trigger conditions are met, and the cycle will continue. If the conditions are met, it will be "triggered" and continue to the next step. The node in the server will simulate the operation of the business contract locally, call the condition check function of the business contract, and check whether specific conditions are met. When the condition check in the contract is passed, the node in the server will send a transaction to the blockchain network to formally call the business function of the business contract to achieve the effect of automatic execution of the smart contract.

[0215] In an embodiment of the present application, when a given condition (trigger condition) is met, the smart contract function is automatically executed, wherein the trigger condition may be triggered once every certain period of time (such as 1 minute, 1 hour...), or other custom conditions (such as when the A / B exchange rate reaches 7 or above, A and B are the products of commodity exchange between two countries), and the triggering is completed by the node in the server.

[0216] When checking conditions, the interface written in solidity in the BC contract is used to check conditions, such as checking whether msg.sender is a specific account address. When the condition check meets the conditions, the function needs to be automatically executed to complete certain business logic, such as transferring money to a specific account.

[0217] like Fig. 22 As shown, it shows the interface description of the node in the server. When the node in the server calls check and doBusiness (executes business functions), the parameter indata can be provided by the node of the server, that is, an external data source is provided for flexible execution of business logic, such as passing a specific account address through indata to perform an equality check with msg.sender.

[0218] The pass variable in check indicates the result of the conditional check, and true means passing. In the embodiment of the present application, (block.timestamp-lastTimeStamp)>interval ensures that the execution of the business logic in two doBusinesses is separated by a certain time, that is, the business logic in doBusiness is not allowed to be executed twice in a short period of time.

[0219] The external data source and parameter transfer are completed through abi.encode and abi.decode.

[0220] In the embodiment of the present application, in addition to the automatic node running check locally to pass the check, for the on-chain contract, when the blockchain node executes the business contract, doBusiness generally needs to call check to perform conditional checks to ensure that the business logic is executed when the conditions are met, and to ensure the correctness of the business logic. If the business logic in doBusiness is not so important, or does not require such strict conditions, it is also possible not to call check for inspection.

[0221] In the embodiment of the present application, more complex services that consume more resources (CPU, memory) can be moved to the off-chain for execution to reduce on-chain overhead, that is, the automatic node calls the service contract to execute services that consume more resources, and the service function only stores the calculation results. The off-chain calculation results are passed by the parameter indata, decoded by abi.decode and stored in the on-chain contract.

[0222] The smart contract processing method provided in the embodiment of the present application can be combined with the deployment and calling process of the business contract and the automated execution process, such as the client deploying the management contract and then deploying the business contract, the client registering the business contract in the server, simulating the operation and condition checking of the business contract through the nodes in the server, and sending the transaction to the blockchain network. The blockchain network automatically executes the business contract; in the process of the blockchain network automatically executing the business contract, the object calls the business contract through the client to obtain the calling result.

[0223] The method provided in the embodiment of the present application allows the entire framework to be deployed in a decentralized manner without relying on a single center, maintaining the advantages of decentralization; users do not need to maintain the contract address and contract ABI, which are maintained by the client and the management contract. Smart contracts can be executed automatically without the need to manually send transactions; users can remember the business contract name and enter it into the client to view the interface information of the contract, and can call it by entering the interface name and corresponding parameters without entering the contract ABI and contract address. The business contract version is managed by the management contract, and users do not need to manage it manually, which facilitates contract deployment (upgrade). After the initial steps of calling and deploying the business contract and automatically executing the contract are completed manually, the subsequent steps are automatically completed by the program, avoiding errors caused by human factors.

[0224] The device embodiment of the present application is introduced, which can be used to execute the smart contract processing method in the above embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the embodiment of the smart contract processing method in the above embodiment of the present application.

[0225] The present application embodiment provides a smart contract processing device, such as Fig.23 As shown, the smart contract processing device can be configured in a server, and the device includes:

[0226] The receiving module 2310 is used to receive a registration request including a business contract address sent by a client, where the registration request is initiated by the client after deploying the business contract on the blockchain network;

[0227] An operation module 2320 is used to simulate and operate a business contract according to the business contract address to perform a condition check on the business contract;

[0228] The sending module 2330 is used to send transaction information to the blockchain network if the condition check of the business contract is passed, so that the blockchain network automatically executes the business contract based on the transaction information.

[0229] In one embodiment of the present application, based on the aforementioned scheme, the registration request also includes the triggering conditions of the business contract; the operation module 2320 is further used to obtain the contract information of the business contract according to the business contract address, and build an execution environment for the business contract locally based on the contract information to register the business contract locally; if it is detected that the current execution environment parameters meet the triggering conditions of the business contract, the business contract is simulated to perform a conditional check on the business contract.

[0230] In one embodiment of the present application, based on the aforementioned scheme, the operation module 2320 is further used to simulate the operation of the business contract to obtain a conditional check function used for conditional checking in the business contract; obtain an external data source, and check the conditional check function according to the external data source to obtain a check result; if the check result indicates that the conditional check function complies with the preset check logic, it is determined that the conditional check of the business contract has passed.

[0231] In one embodiment of the present application, based on the aforementioned scheme, the sending module 2330 is further used to execute the business function of the business contract based on the acquired external data source if the condition check of the business contract is passed; if the execution result of the business function matches the expected execution result, the transaction information is sent to the blockchain network.

[0232] In one embodiment of the present application, based on the aforementioned scheme, the device also includes a processing module for obtaining a pending business corresponding to the business contract; if the pending business is a business that requires a resource amount greater than a preset resource amount, the pending business is executed according to the business function corresponding to the business contract to obtain a processing result; and the processing result is sent to the business contract deployed in the blockchain network for storage.

[0233] The present application embodiment provides a smart contract processing device, such as Fig.24 As shown, the smart contract processing device can be configured in the client, and the device includes:

[0234] An acquisition module 2410 is used to acquire a business contract address deployed in a blockchain network;

[0235] Request module 2420 is used to send a registration request to the server based on the business contract address, so that the server simulates the operation of the business contract through the business contract address to perform a condition check on the business contract, and after the condition check on the business contract is passed, send transaction information to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

[0236] In one embodiment of the present application, based on the aforementioned scheme, the device also includes a deployment module, which is used to deploy a management contract in the blockchain network, and the management contract is used to record the contract information of each business contract; a deployment transaction for the business contract is sent to the blockchain network, so that the blockchain network writes the contract information of the business contract into the management contract based on the deployment transaction.

[0237] In one embodiment of the present application, based on the aforementioned scheme, the device also includes an update module, which is used to detect whether the current version of the business contract is deployed in the blockchain network if the local cache includes contract information of the business contract; if it is detected that the current version of the business contract is not deployed in the blockchain network, a version update transaction is sent to the blockchain network to write the contract information of the current version of the business contract into the management contract.

[0238] In one embodiment of the present application, based on the aforementioned scheme, the device also includes a calling module, which is used to obtain the application binary interface information of the business contract from the management contract and write it into the local cache if it is determined that the local cache does not contain the application binary interface information of the business contract during the process of automatically executing the business contract on the blockchain network; if it is determined that the local cache contains the application binary interface information of the business contract, the business contract is called based on the application binary interface information of the business contract, and the calling result is obtained.

[0239] In one embodiment of the present application, based on the aforementioned scheme, the calling module is further used to obtain the interface to be called and the parameters of the interface in the business contract according to the application binary interface information; generate a calling transaction according to the interface to be called and the parameters of the interface, and send the calling transaction to the blockchain network to call the business contract.

[0240] In one embodiment of the present application, based on the aforementioned scheme, the calling module is further used to send a query request to the management contract of the blockchain network based on the contract name and contract version of the business contract, so that the management contract determines the corresponding business contract based on the contract name and contract version of the business contract; and receives the application binary interface information of the business contract sent by the management contract of the blockchain network.

[0241] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here.

[0242] An embodiment of the present application also provides an electronic device, comprising one or more processors and a storage device, wherein the storage device is used to store one or more computer programs. When the one or more computer programs are executed by one or more processors, the electronic device implements the above-mentioned smart contract processing method.

[0243] Fig.25 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0244] It should be noted that Fig.25 The computer system 2500 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application. The electronic device may be a terminal or a server.

[0245] like Fig.25 As shown, the computer system 2500 includes a processor (Central Processing Unit, CPU) 2501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (Read-Only Memory, ROM) 2502 or the program loaded from the storage part 2508 to the random access memory (Random Access Memory, RAM) 2503, such as executing the method in the above embodiment. In RAM 2503, various programs and data required for system operation are also stored. CPU 2501, ROM 2502 and RAM 2503 are connected to each other through bus 2504. Input / output (Input / Output, I / O) interface 2505 is also connected to bus 2504.

[0246] In some embodiments, the following components are connected to the I / O interface 2505: an input section 2506 including a keyboard, a mouse, etc.; an output section 2507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 2508 including a hard disk, etc.; and a communication section 2509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 2509 performs communication processing via a network such as the Internet. A drive 2510 is also connected to the I / O interface 2505 as needed. A removable medium 2511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 2510 as needed, so that a computer program read therefrom is installed into the storage section 2508 as needed.

[0247] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 2509, and / or installed from the removable medium 2511. When the computer program is executed by the processor (CPU) 2501, various functions defined in the system of the present application are executed.

[0248] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0249] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and a computer program.

[0250] The units or modules involved in the embodiments described in this application may be implemented by software or hardware, and the units or modules described may also be set in a processor. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.

[0251] Another aspect of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method described above is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0252] Another aspect of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the electronic device executes the method provided in the above-mentioned embodiments.

[0253] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0254] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0255] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person of ordinary skill in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

Claims

1. A smart contract processing method, characterized in that: include: Receive a registration request including a business contract address sent by a client, where the registration request is initiated by the client after deploying the business contract on a blockchain network; Simulate and run the business contract according to the business contract address to perform conditional checks on the business contract; If the condition check of the business contract passes, the transaction information is sent to the blockchain network so that the blockchain network automatically executes the business contract based on the transaction information.

2. The method according to claim 1, characterized in that The registration request also includes a trigger condition of the business contract; and the simulating and running the business contract according to the business contract address to perform a condition check on the business contract includes: Acquire the contract information of the business contract according to the business contract address, and construct the execution environment of the business contract locally based on the contract information to register the business contract locally; If it is detected that the current execution environment parameters meet the triggering conditions of the business contract, the business contract is simulated and run to perform a condition check on the business contract.

3. The method according to claim 2, characterized in that The simulating operation of the business contract to perform a condition check on the business contract includes: Simulate and run the business contract to obtain a condition check function used for condition check in the business contract; Acquire an external data source, and check the condition check function according to the external data source to obtain a check result; If the check result indicates that the conditional check function complies with the preset check logic, it is determined that the conditional check on the business contract passes.

4. The method according to claim 1, characterized in that If the condition check of the business contract passes, the transaction information is sent to the blockchain network, including: If the condition check of the business contract passes, the business function of the business contract is executed based on the acquired external data source; If the execution result of the business function matches the expected execution result, the transaction information is sent to the blockchain network.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Obtaining pending business corresponding to the business contract; If the to-be-processed business is a business that requires a resource amount greater than a preset resource amount, executing the to-be-processed business according to the business function corresponding to the business contract to obtain a processing result; The processing result is sent to the business contract deployed in the blockchain network for storage.

6. A smart contract processing method, characterized in that: include: Get the business contract address deployed in the blockchain network; A registration request is sent to the server based on the business contract address, so that the server simulates the operation of the business contract through the business contract address to perform a condition check on the business contract, and after the condition check on the business contract passes, transaction information is sent to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

7. The method according to claim 6, characterized in that Before obtaining the business contract address deployed in the blockchain network, the method further includes: Deploy a management contract in the blockchain network, wherein the management contract is used to record contract information of each business contract; A deployment transaction for the business contract is sent to the blockchain network, so that the blockchain network writes the contract information of the business contract into the management contract based on the deployment transaction.

8. The method according to claim 7, characterized in that After sending a deployment transaction for the business contract to the blockchain network to write the contract information of the business contract into the management contract, the method further includes: If the local cache includes the contract information of the business contract, then detecting whether the current version of the business contract is deployed in the blockchain network; If it is detected that the current version of the business contract is not deployed in the blockchain network, a version update transaction is sent to the blockchain network to write the contract information of the current version of the business contract into the management contract.

9. The method according to claim 7, characterized in that: After sending the registration request to the server based on the business contract address, the method further includes: During the process of automatically executing the business contract on the blockchain network, if it is determined that the local cache does not contain the application binary interface information of the business contract, the application binary interface information of the business contract is obtained from the management contract and written into the local cache; If it is determined that the local cache contains the application binary interface information of the business contract, the business contract is called based on the application binary interface information of the business contract, and the calling result is obtained.

10. The method according to claim 9, characterized in that The calling of the business contract based on the application binary interface information of the business contract comprises: Acquire the interface to be called and parameters of the interface in the business contract according to the application binary interface information; A call transaction is generated according to the interface to be called and the parameters of the interface, and the call transaction is sent to the blockchain network to call the business contract.

11. The method according to claim 9, characterized in that The acquiring the application binary interface information of the business contract from the management contract includes: Based on the contract name and contract version of the business contract, a query request is sent to the management contract of the blockchain network, so that the management contract determines the corresponding business contract based on the contract name and contract version of the business contract; Receive application binary interface information of the business contract sent by the management contract of the blockchain network.

12. A smart contract processing device, characterized in that: include: A receiving module, used to receive a registration request including a business contract address sent by a client, wherein the registration request is initiated by the client after deploying the business contract on a blockchain network; An operation module, used for simulating the operation of the business contract according to the business contract address to perform a condition check on the business contract; A sending module is used to send transaction information to the blockchain network if the condition check of the business contract is passed, so that the blockchain network automatically executes the business contract based on the transaction information.

13. A smart contract processing device, characterized in that: include: The acquisition module is used to obtain the business contract address deployed in the blockchain network; A request module is used to send a registration request to the server based on the business contract address, so that the server simulates the operation of the business contract through the business contract address to perform a condition check on the business contract, and after the condition check on the business contract is passed, send transaction information to the blockchain network, so that the blockchain network automatically executes the business contract based on the transaction information.

14. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to execute the method described in any one of claims 1 to 5, or execute the method described in any one of claims 6 to 11.

15. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of an electronic device, the electronic device executes the method of any one of claims 1 to 6, or executes the method of any one of claims 6 to 11.

16. A computer program product, characterized in that The computer program product includes a computer program, which is stored in a computer-readable storage medium. The processor of the electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the method of any one of claims 1 to 5, or executes the method of any one of claims 6 to 11.