Registration, execution method, device and system of timed smart contracts in blockchain

By deploying the interfaces of oracle contracts and timed smart contracts on the blockchain, combining polling or voting to select trusted oracle and resource management, the problem of timed execution of smart contracts in the blockchain is solved, and timed execution and resources are realized Control enhances the trust and security of blockchain.

CN112837157BActive Publication Date: 2024-11-29THE PEOPLES BANK OF CHINA DIGITAL CURRENCY INST
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110185555.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-10
Publication Date
2024-11-29
Estimated Expiration
2041-02-10

AI Technical Summary

Technical Problem

Existing blockchain smart contracts are difficult to achieve regular trigger execution, especially in scenarios such as fixed-time reconciliation between financial institutions, which lack effective management and execution methods.

Method used

By deploying oracle contracts on the blockchain, receiving time information sent by trusted oracles, and providing a given time smart contract through the interface, making it execute regularly based on the time information, selecting trusted oracles by polling or voting. Generate logs to verify the accuracy of time information and configure consuming resources in built-in blocks or transaction blocks to control execution.

Benefits of technology

It realizes the management and execution of timed smart contracts in the blockchain, ensures the accurate execution of timed trigger functions, avoids the problems of infinite loops and excessive resource use, and improves the trust basis and information security of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112837157B_ABST
    Figure CN112837157B_ABST
Patent Text Reader

Abstract

The present invention discloses a registration and execution method, device and system for a timed smart contract in a blockchain, and relates to the field of computer technology. A specific implementation of the method includes: receiving a registration request for a timed smart contract; generating an interface connected to a prophecy contract for the timed smart contract according to the registration request, wherein the prophecy contract is deployed on the blockchain and is used to receive time information sent by a trusted prophecy machine, so as to provide the time information to the timed smart contract through the interface. This implementation realizes the management and execution of timed smart contracts through blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain, and in particular to a registration and execution method, device and system for a timed smart contract in a blockchain. Background Art

[0002] Blockchain can be considered as a decentralized and trusted distributed ledger. Since blockchain consists of many nodes forming an end-to-end network, there is no centralized equipment and management agency, and the distributed storage and distributed recording of data in the blockchain make the blockchain immutable. Therefore, writing smart contracts into the blockchain in a digital way and completing corresponding transactions by executing smart contracts in the blockchain have become increasingly popular among various institutions.

[0003] At present, smart contracts in blockchain generally require external transactions to trigger execution. For some transactions that need to be triggered to complete at a fixed time, such as reconciliation between financial institutions, there are still problems that need to be solved in the existing smart contract management and execution methods. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a registration and execution method, device and system for a timed smart contract in a blockchain, which realizes the management and execution of a timed smart contract through a blockchain.

[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a registration method for a timed smart contract in a blockchain is provided, comprising:

[0006] Receive registration request for timed smart contract;

[0007] According to the registration request, an interface connected to the oracle contract is generated for the timing smart contract, wherein the oracle contract is deployed on the blockchain and is used to receive time information sent by a trusted oracle, so as to provide the time information to the timing smart contract through the interface.

[0008] Optionally, the registration method of a timed smart contract in the above blockchain further comprises:

[0009] Generate a corresponding transaction block for other smart contracts, and record the transaction corresponding to the other smart contracts in the transaction block, wherein the other smart contracts are smart contracts without event triggering functions, so that the other smart contracts are executed based on the transaction block.

[0010] Optionally, the registration method of a timed smart contract in the above blockchain further comprises:

[0011] Generating a corresponding built-in block or a built-in area in the transaction block for the timed smart contract;

[0012] A corresponding amount of consumable resources is configured for the built-in block or the built-in area in the transaction block, and a transaction corresponding to the timed smart contract is recorded in the transaction block, so that the timed smart contract is executed based on the built-in block or the built-in area in the transaction block.

[0013] In a second aspect, an embodiment of the present invention provides a method for executing a timed smart contract in a blockchain, comprising:

[0014] Providing the oracle contract with time information sent by a trusted oracle, where the trusted oracle is selected from multiple oracles;

[0015] Providing the time information to the timing smart contract through an interface, wherein the timing smart contract includes a timing trigger function, and the timing smart contract is connected to the oracle contract through the interface;

[0016] When the time information satisfies the timing trigger function, the timing smart contract is executed.

[0017] Optionally, the execution method of the timed smart contract in the above blockchain further includes:

[0018] Use polling to determine the trusted oracle from multiple oracles;

[0019] or,

[0020] A voting method is used to select a trusted oracle from multiple oracles.

[0021] Optionally, the execution method of the timed smart contract in the above blockchain further includes:

[0022] Generate a record log, and record the time information in the record log;

[0023] When receiving a request for access from a trusted node or other trusted oracle in the blockchain, providing the record log to the trusted node or other trusted oracle;

[0024] According to the results of the review, verify whether the time information recorded in the log is accurate.

[0025] If not, the trusted oracle is marked as untrustworthy, and the step of selecting a trusted oracle from multiple oracles is re-executed.

[0026] Optionally, the execution method of the timed smart contract in the above blockchain further includes:

[0027] A transaction block is provided for the non-scheduled smart contract, wherein the transaction block records the transactions corresponding to the other smart contracts;

[0028] When the execution trigger of the other smart contract is received, the transaction block corresponding to the other smart contract is executed.

[0029] Optionally, the execution method of the timed smart contract in the above blockchain further comprises: a built-in block or a built-in area in the transaction block is set for the timed smart contract, and the built-in block or the built-in area is configured with a corresponding consumable resource amount, wherein the built-in block or the built-in area records the transaction of the timed smart contract;

[0030] The steps of executing the timing smart contract include:

[0031] When the execution trigger of the timed smart contract is received, it is determined whether the currently required amount of resources is not greater than the consumable amount of resources corresponding to the built-in block or the built-in area. If so, the built-in block or the built-in area corresponding to the timed smart contract is executed; otherwise, execution is prohibited.

[0032] Optionally, when the timed smart contract includes at least two timed trigger functions, and each of the timed trigger functions corresponds to a processing logic in the timed smart contract;

[0033] The step of executing the timed smart contract includes: executing the processing logic corresponding to the timed trigger function.

[0034] In a third aspect, an embodiment of the present invention provides a registration device for a timed smart contract in a blockchain, comprising: a receiving unit and a registration unit, wherein:

[0035] The receiving unit is used to receive a registration request for a timed smart contract;

[0036] The registration unit is used to generate an interface connected to the oracle contract for the timing smart contract according to the registration request, wherein the oracle contract is deployed on the blockchain and is used to receive time information sent by a trusted oracle to provide the time information to the timing smart contract through the interface.

[0037] In a fourth aspect, an embodiment of the present invention provides an execution device for a timed smart contract in a blockchain, comprising: an interaction unit, an interface corresponding to each timed smart contract, and an execution unit, wherein:

[0038] The interaction unit is used to provide the oracle contract with time information sent by a trusted oracle, wherein the trusted oracle is selected from a plurality of oracles;

[0039] The interface corresponding to each of the timing smart contracts is used to connect the corresponding timing smart contract to the oracle contract, and provide the time information received by the oracle contract to the timing smart contract, wherein the timing smart contract includes a timing trigger function;

[0040] The execution unit is used to execute the timing smart contract when the time information received by the timing smart contract satisfies the timing trigger function.

[0041] In a fifth aspect, an embodiment of the present invention provides an execution system of a timed smart contract in a blockchain, comprising: a plurality of oracles and an execution device of a timed smart contract in the above blockchain, wherein:

[0042] An execution device of a timed smart contract in the blockchain, configured to select a trusted oracle from the plurality of oracle machines;

[0043] Each of the oracle machines, after being elected as the trusted oracle machine, provides time information to the oracle machine contract through the execution device of the timing smart contract in the blockchain.

[0044] An embodiment of the above invention has the following advantages or beneficial effects: by registering a timed smart contract deployed on a blockchain, an interface connected to an oracle contract can be generated for the timed smart contract; after the oracle contract receives the time information sent by a trusted oracle, the time information is sent to the timed smart contract through the interface, so that the timed smart contract can be executed on a scheduled basis according to the time information, thereby realizing the management and execution of the timed smart contract through the blockchain.

[0045] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0047] Figure 1 It is a schematic diagram of the main process of the registration method of the timed smart contract in the blockchain according to an embodiment of the present invention;

[0048] Figure 2 is a schematic diagram of the main process of a registration method for a timed smart contract in a blockchain according to another embodiment of the present invention;

[0049] Figure 3 is a schematic diagram of the main process of executing a timed smart contract in a blockchain according to an embodiment of the present invention;

[0050] Figure 4is a schematic diagram of the main process of executing a timed smart contract in a blockchain according to another embodiment of the present invention;

[0051] Figure 5 It is a schematic diagram of the main process of executing a non-scheduled smart contract in a blockchain according to an embodiment of the present invention;

[0052] Figure 6 is a schematic diagram of the main process of executing a timed smart contract in a blockchain according to another embodiment of the present invention;

[0053] Figure 7 is a schematic diagram of the main process of executing a timed smart contract in a blockchain according to another embodiment of the present invention;

[0054] Figure 8 is a schematic diagram of the main flow of the processing logic execution in the timing smart contract according to an embodiment of the present invention;

[0055] Fig. 9 is a schematic diagram of main units of a registration device for a timed smart contract in a blockchain according to an embodiment of the present invention;

[0056] Fig.10 is a schematic diagram of the main units of the execution device of the timed smart contract in the blockchain according to an embodiment of the present invention;

[0057] Fig.11 is a schematic diagram of an execution system of a timed smart contract in a blockchain according to an embodiment of the present invention;

[0058] Fig.12 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0059] Fig.13 It is a schematic diagram of the structure of a computer system suitable for implementing a node in a blockchain according to an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0061] A smart contract is a set of commitments or obligations defined in a programming language, on which the parties to the contract can execute these commitments or obligations. The protocol consists of processing logic with a logical sequence.

[0062] Figure 1A registration method for a timed smart contract in a blockchain according to an embodiment of the present invention. Figure 1 As shown, the registration method of the timed smart contract in the blockchain may include the following steps:

[0063] S101: Receive a registration request for a timed smart contract;

[0064] S102: Generate an interface connected to the oracle contract for the timing smart contract according to the registration request, wherein the oracle contract is deployed on the blockchain and is used to receive time information sent by the trusted oracle to provide time information to the timing smart contract through the interface.

[0065] Among them, a timed smart contract refers to a smart contract with a time trigger function that can be triggered by combining time and the time trigger function. Among them, the time trigger function is a time judgment function or a conditional function. By inputting time information (such as the current time, etc.) into the time trigger function, it is determined whether the time information satisfies the time trigger function. If it does, the smart contract corresponding to the time trigger function or the logic execution in the smart contract corresponding to the time trigger function is triggered.

[0066] An oracle contract is a protocol defined in a programming language that can communicate with an external oracle, provide time information for connected timed smart contracts, is independent of the oracle, and can be deployed on the blockchain.

[0067] A trusted oracle is a device that is independent of the blockchain and can communicate trustlessly with the oracle contract.

[0068] It is worth noting that the registration request may carry the characteristic identification information of the timed smart contract. Accordingly, there are two ways to generate an interface connected to the oracle contract for the timed smart contract: Implementation method 1, generate a corresponding interface for each of the multiple timed smart contracts, and set the characteristic identification information of the timed smart contract in the interface to provide time information for the timed smart contract; Implementation method 2, generate a corresponding interface for multiple timed smart contracts, and after receiving the registration request of the timed smart contract, write the characteristic identification information of the timed smart contract into the interface, so that the interface provides time information for the timed smart contract corresponding to the characteristic identification information included therein.

[0069] exist Figure 1In the illustrated embodiment, by registering a timed smart contract deployed on the blockchain, an interface connected to the oracle contract can be generated for the timed smart contract. After the oracle contract receives the time information sent by the trusted oracle, the time information is sent to the timed smart contract through the interface, so that the timed smart contract can be executed on time according to the time information, thereby realizing the management and execution of the timed smart contract through the blockchain.

[0070] In addition, the execution of the scheduled smart contract needs to rely on the trust foundation of the entire chain. Based on this, in the solution provided by the embodiment of the present invention, the blockchain is preferably a consortium chain.

[0071] In an embodiment of the present invention, in order to achieve differentiated management of scheduled smart contracts and other smart contracts other than scheduled smart contracts.

[0072] For other smart contracts besides the scheduled smart contract, the registration method of the scheduled smart contract in the blockchain may further include: generating corresponding transaction blocks for other smart contracts, and recording transactions corresponding to other smart contracts in the transaction blocks, wherein the other smart contracts are smart contracts that do not have event trigger functions, so that the other smart contracts are executed based on the transaction blocks.

[0073] Among them, other smart contracts refer to smart contracts that require external business or business data to trigger execution.

[0074] For timed smart contracts, such as Figure 2 As shown, the registration method of the timed smart contract in the blockchain may further include the following steps:

[0075] S201: Generate a corresponding built-in block or a built-in area in a transaction block for a timed smart contract;

[0076] S202: Configuring corresponding consumable resources for the built-in block or the built-in area in the transaction block, and recording the transaction corresponding to the timed smart contract in the transaction block, so that the timed smart contract is executed based on the built-in block or the built-in area in the transaction block.

[0077] Among them, the amount of consumable resources refers to the amount of resources currently available to the parties to the scheduled smart contract.

[0078] The amount of resources currently required refers to the amount of resources that the contracting parties of the timed smart contract need to pay to execute the timed smart contract.

[0079] By configuring the corresponding consumable resource amount for the built-in block or built-in area as described above, when the resource amount is lower than the consumable resource amount, the execution of the first smart contract will be forcibly stopped, thereby avoiding downtime problems caused by infinite loops, for example.

[0080] It can be understood that when generating a built-in area in a transaction block for a timed smart contract, at least one transaction block must exist first. The transaction block can be a transaction block corresponding to other smart contracts, or a transaction block generated for a timed smart contract, and a built-in area is divided in the transaction block, and the corresponding consumable resource amount is configured for the built-in area.

[0081] Among them, for the transaction block generated for the timed smart contract, a built-in area is divided in the transaction block. The transaction block corresponding to the timed smart contract is used to record the transaction record of the timed smart contract. Before executing the timed smart contract, it can be determined whether the current resource amount is not less than the consumable resource amount corresponding to the built-in area. If so, the timed smart contract is executed, and the transaction record of the timed smart contract is recorded in the transaction block outside the built-in area, so that the recording area of ​​the transaction record is separated from the built-in area, which is convenient for the management of the transaction record.

[0082] Figure 3 The present invention provides a method for executing a timed smart contract in a blockchain according to an embodiment of the present invention. Figure 3 As shown, the execution method of the timed smart contract in the blockchain may include the following steps:

[0083] S301: Provide the oracle contract with time information sent by a trusted oracle, where the trusted oracle is selected from multiple oracles;

[0084] S302: providing time information to a timing smart contract through an interface, wherein the timing smart contract includes a timing trigger function, and the timing smart contract is connected to the oracle contract through the interface;

[0085] S303: When the time information satisfies the timing trigger function, the timing smart contract is executed.

[0086] Among them, the oracle contract, trusted oracle, timed smart contract and timed trigger function mentioned and used in this embodiment are consistent with the definitions of the previous embodiments or are derived from the previous embodiments.

[0087] For example, the time information includes the current time. Accordingly, the time information satisfies the time trigger function, which means that after adding the current time to the time trigger function, the condition corresponding to the time trigger function can be satisfied. The time trigger function is: 0.9h≤T n -T n-1 ≤1.15h, where T n Represents the current time, T n-1Represents the execution time of the last execution of the first smart contract; 0.9h represents 0.9 hours, 1h represents 1 hour, and greater than or equal to 0.9h and less than or equal to 1.15h is the conditional limitation corresponding to the time trigger function; assuming that the execution time of the last execution of the scheduled smart contract is 2020.5.20 / 10:00, and the current time is 2020.5.20 / 10:30, then the current time does not satisfy the time trigger function 0.9h≤T n -T n-1 ≤1.15h; Assuming that the last execution time of the scheduled smart contract was 2020.5.20 / 10:00, and the current time is 2020.5.20 / 11:00, then the current time satisfies the time trigger function 0.9h≤T n -T n-1 ≤1.15h. The current time can also be obtained by multiplying the block height of the recorded block by the average time interval for generating each block.

[0088] For example, the time trigger function is: Among them, T n represents the current time, T represents the execution time of the first execution of the timed smart contract; f1 represents the time difference between each two adjacent executions, θ represents the allowable error of the defined time difference, and K represents the number of executions of the timed smart contract corresponding to the time trigger function. Accordingly, the condition corresponding to the time trigger function is limited to: greater than or equal to f1-θ and less than or equal to f1+θ. The time trigger function can also realize the timed triggering of the smart contract.

[0089] Therefore, the time-triggered function in the solution provided in the embodiment of the present invention can be any function that can achieve timing, and trigger the execution of its corresponding timed smart contract or the processing logic within the timed smart contract through the timing.

[0090] In addition, since the scheduled smart contract obtains time information through the oracle contract deployed on the blockchain, that is, the scheduled smart contract does not directly interact with the outside world, by limiting the information that can be transmitted by the interface (connecting the oracle contract and the scheduled smart contract), it is possible to effectively avoid aggressive information attacks on the scheduled smart contract. In addition, since one oracle contract can connect to multiple scheduled smart contracts and the oracle contract has a relatively simple function, it is convenient for users to maintain the oracle contract.

[0091] In addition, when the time trigger function is the conditional function shown in the above embodiment, and the multiple current times continuously received by the oracle contract may all satisfy the above time trigger function, in order to avoid the repetitive execution of the scheduled smart contract to be executed within the conditional range defined by the time trigger function, for each execution of the scheduled smart contract or the completed execution, the scheduled oracle contract will feedback the corresponding identifier of each execution or the corresponding identifier of each execution. Accordingly, the scheduled oracle contract can further determine whether to trigger the scheduled smart contract to be executed based on the corresponding identifier of the execution or the corresponding identifier of the execution completion.

[0092] In the above embodiment, time information is acquired through a monitoring interface, and whether the time information satisfies a time trigger function is determined to determine whether to execute a timed smart contract having the time trigger function. This realizes triggering a timed smart contract by combining time information and a time trigger function within the blockchain, and can effectively ensure that a timed smart contract having a time trigger function in the blockchain can be executed according to the time information.

[0093] It is worth noting that the execution of the scheduled smart contract needs to rely on the trust foundation of the entire chain. Based on this, in the solution provided by the embodiment of the present invention, the blockchain is preferably a consortium chain.

[0094] In the embodiment of the present invention, there are two ways to determine a trusted oracle:

[0095] The first way to determine a trusted oracle:

[0096] A polling method is used to determine a trusted oracle from multiple oracles. The polling method can be polling in a certain order or in a random manner.

[0097] For example, multiple oracles are Oracle A, Oracle B, Oracle C and Oracle D. Polling in a certain order can be polling in the order of Oracle A, Oracle B, Oracle C and Oracle D. The current trusted oracle is Oracle B. After Oracle B has been a trusted oracle for a certain period of time, Oracle C will be used as a trusted oracle.

[0098] For example, multiple oracles are Oracle A, Oracle B, Oracle C and Oracle D. According to random polling, the current trusted oracle is Oracle B. After Oracle B has been a trusted oracle for a certain period of time, Oracle D is randomly selected as the trusted oracle.

[0099] The second way to determine a trusted oracle:

[0100] A voting method is used to select a trusted oracle from multiple oracles. The voting method can be performed periodically, for example, every month, every week, every 5 days, etc.

[0101] There are two specific voting methods:

[0102] The first voting method: Preliminarily screen out an oracle from multiple oracles. For a consortium chain or a private chain, each node included in the consortium chain or the private chain votes for the preliminarily screened oracle. When the voting ratio (voting ratio: the number of nodes that vote in favor or agree divided by the total number of nodes included in the consortium chain or the private chain) is not less than the preset ratio threshold, the preliminarily screened oracle is determined to be a credible oracle; for a public chain, multiple credible nodes included in the public chain vote for the preliminarily screened oracle. When the voting ratio (voting ratio: the number of nodes that vote in favor or agree divided by the total number of credible nodes included in the public chain) is not less than the preset ratio threshold, the preliminarily screened oracle is determined to be a credible oracle; wherein, the voting ratio can be adjusted accordingly according to the actual situation, and the voting ratio can more truly reflect the actual situation of the vote. Through the first voting method, a credible oracle can be selected relatively quickly and accurately, and the credibility of the credible oracle can be guaranteed to a certain extent. Then, by communicating with the blockchain through the credible oracle, the information security of the blockchain can be effectively improved.

[0103] The second voting method:

[0104] For each node included in the consortium chain or private chain or each trusted node in the public chain, respectively perform: select at least one preliminary screening oracle from multiple oracles, and then count the number of votes in favor (consent) of each preliminary screening oracle; based on the results of the preliminary vote, further screening of trusted oracles may include:

[0105] 1. Directly select the initial screening oracle with the most votes in favor as the trusted oracle; if there are at least two initial screening oracles with the most votes in favor, randomly select one from the at least two or select the one with the least number of votes against as the trusted oracle;

[0106] For example, the nodes participating in the voting are node 1, node 2, node 6, node 8, and node 9, and the multiple oracles are oracle a, oracle b, oracle c, and oracle d. Among them, node 1 votes in favor of oracle a and oracle b, node 2 votes in favor of oracle a and oracle c, node 6 votes in favor of oracle a and oracle d; node 8 votes in favor of oracle a and oracle d, and node 9 votes in favor of oracle a and oracle c; then oracle a has the most votes in favor and serves as the trusted oracle.

[0107] 2. Determine the initial screening oracles that do not have any negative votes, and select the initial screening oracles with the most votes as the trusted oracle from among the initial screening oracles that do not have any negative votes;

[0108] For example, multiple oracles are Oracle A, Oracle B, Oracle C, and Oracle D. Among them, the initial screening oracles without any negative votes are Oracle A, Oracle B, and Oracle C. Oracle A has the most positive votes, so Oracle A is selected as the trusted oracle.

[0109] 3. Re-vote the initial screening oracles that do not have any negative votes, or the initial screening oracles with the number of affirmative votes not less than the preset threshold, or the initial screening oracles with the largest number of affirmative votes, and determine the trusted oracle based on the results of the re-voting.

[0110] There are three screening forms for the second voting method, and users can make corresponding choices according to their needs, realizing flexible selection of trusted oracles and preventing the outside world from locating trusted oracles through voting. To a certain extent, it can ensure the security of trusted oracles.

[0111] In the embodiment of the present invention, Figure 4 As shown, the execution method of the timed smart contract in the blockchain may further include the following steps:

[0112] S401: Generate a record log and record time information in the record log;

[0113] S402: When receiving a query request from a trusted node or other trusted oracle in the blockchain, providing a record log to the trusted node or other trusted oracle;

[0114] S403: Verify whether the time information recorded in the log is accurate according to the result of the query. If it is, execute step S404; otherwise, execute step S405;

[0115] The trusted node or other trusted oracle mainly compares the last time information recorded in the log with the current time of its own device. When the comparison result is that the difference between the last time information recorded in the log and the current time of its own device is not greater than the preset time difference threshold, it is determined that the last time information matches the time of the trusted node or other trusted oracle. Accordingly, the result of the query may include: the total number of trusted nodes or other trusted oracles participating in the query of the log, the number of trusted nodes or other trusted oracles that match the last time information recorded in the log, etc.

[0116] Verification of whether the time information recorded in the log is accurate can be as follows: whether the number of trusted nodes or other trusted oracles that match the last time information recorded in the log is the same as the total number of trusted nodes or other trusted oracles that participated in consulting the log; if so, the time information is determined to be accurate.

[0117] Verification of whether the time information recorded in the log is accurate can also be performed by: whether the number of trusted nodes or other trusted oracles that match the last time information recorded in the log is not less than a preset number threshold; if so, the time information is determined to be accurate.

[0118] S404: End the current process;

[0119] S405: Mark the trusted oracle as untrustworthy, and re-execute the step of selecting a trusted oracle from multiple oracles.

[0120] Through the above process, the time information provided by the trusted oracle can be verified to ensure the reliability of the trusted oracle and the time information, thereby ensuring the reliability of the execution of the scheduled smart contract.

[0121] In the embodiment of the present invention, different types of smart contracts (scheduled smart contracts and non-scheduled smart contracts) have corresponding different execution methods, which can enable non-scheduled smart contracts to be executed according to the original execution method, and set a corresponding execution method separately for the scheduled smart contract. This can be achieved by adding the execution method corresponding to the scheduled smart contract on the basis of the existing blockchain, which can effectively simplify the construction process of the smart contract execution method in the blockchain, thereby saving the construction cost of the smart contract execution method in the blockchain.

[0122] For the execution of non-scheduled smart contracts:

[0123] like Figure 5 As shown, the following steps may be included:

[0124] S501: A transaction block is set for the non-scheduled smart contract, wherein the transaction block records the transactions corresponding to the other smart contracts;

[0125] S502: When receiving the execution trigger of other smart contracts, execute the transaction block corresponding to the other smart contracts.

[0126] For the execution of timed smart contracts:

[0127] like Figure 6 As shown, the following steps may be included:

[0128] S601: A built-in block or a built-in area in a transaction block is set for a timed smart contract, and the built-in block or the built-in area is configured with a corresponding consumable resource amount, wherein the built-in block or the built-in area records a transaction of the timed smart contract;

[0129] S602: When receiving the execution trigger of the timed smart contract, determine whether the current required resource amount is not greater than the consumable resource amount corresponding to the built-in block or built-in area. If so, execute step S603; otherwise, execute step S604;

[0130] S603: Execute the built-in block or built-in area corresponding to the timed smart contract and end the current process;

[0131] S604: Execution prohibited.

[0132] Among them, the amount of consumable resources refers to the amount of resources currently available to the parties to the scheduled smart contract.

[0133] The amount of resources currently required refers to the amount of resources that the contracting parties of the timed smart contract need to pay to execute the timed smart contract.

[0134] For example, if the current smart contract is a non-scheduled smart contract (a smart contract executed by external triggers outside the blockchain), then according to Figure 5 The given embodiment executes the current smart contract. The current smart contract is a timed smart contract. Figure 6 The given embodiment executes the current smart contract.

[0135] Through the above Figure 5 and Figure 6 The embodiment of the present invention realizes the differentiated execution of non-scheduled smart contracts and scheduled smart contracts. Figure 6 The embodiment executes a timed smart contract by configuring the corresponding consumable resource amount for the built-in block or built-in area. When the resource amount is lower than the consumable resource amount, the execution of the timed smart contract will be forcibly stopped, avoiding downtime problems caused by infinite loops, for example.

[0136] In an embodiment of the present invention, when a timed smart contract includes at least two timed trigger functions, and each timed trigger function corresponds to a processing logic in the timed smart contract; accordingly, the step of executing the timed smart contract may include: executing the processing logic corresponding to the timed trigger function. For example, if the first time currently obtained satisfies the time trigger function 1 corresponding to the processing logic 1 in the timed smart contract, the processing logic 1 in the timed smart contract is executed, and then, it can be understood that based on the processing logic 1, according to the processing logic agreed in the timed smart contract, the processing logic related to the processing logic 1 is executed; if the second time currently obtained satisfies the time trigger function 3 corresponding to the processing logic 3 in the timed smart contract, the processing logic 3 in the timed smart contract is executed, etc. The above process realizes the segmented execution of the logic in the smart contract to meet the more complex and diverse needs of the smart contract.

[0137] The following two cases further explain in detail the execution method of the timed smart contract in the blockchain.

[0138] Case 1: A timed smart contract has a timed trigger function that can trigger the execution of the timed smart contract.

[0139] like Figure 7 As shown, each scheduled smart contract execution in the blockchain can cyclically execute the following steps:

[0140] S700: A built-in block or a built-in area in a transaction block is set for a timed smart contract, and the built-in block or the built-in area is configured with a corresponding consumable resource amount, wherein the built-in block or the built-in area records a transaction of the timed smart contract;

[0141] S701: Provide the oracle contract with the current time sent by the trusted oracle;

[0142] S702: The oracle contract sends the current time to the timing trigger function;

[0143] S703: Determine whether the current time satisfies the timing trigger function, if yes, execute step S704; otherwise, execute step S707;

[0144] S704: Determine the built-in block or built-in area corresponding to the timed smart contract;

[0145] S705: Determine whether the currently required resource amount is not greater than the consumable resource amount corresponding to the built-in block or built-in area. If so, execute step S706; otherwise, execute step S707;

[0146] S706: Execute the built-in block or built-in area corresponding to the timed smart contract and end the current process;

[0147] S707: Execution prohibited.

[0148] Case 2: Multiple processing logics in a timed smart contract correspond to a timed trigger function that can trigger the execution of the processing logic.

[0149] like Figure 8 As shown, each scheduled smart contract execution in the blockchain can cyclically execute the following steps:

[0150] S800: A corresponding built-in block or a built-in area in a transaction block is set for the timed smart contract, and the built-in block or the built-in area is configured with a corresponding consumable resource amount, wherein the built-in block or the built-in area records a transaction corresponding to the processing logic in the timed smart contract;

[0151] This step can be implemented in two ways:

[0152] Implementation method 1: Each processing logic in the timed smart contract is located in the same built-in block or built-in area in the transaction block, and one timed smart contract corresponds to one built-in block or one built-in area.

[0153] Implementation method 2: Each processing logic in the timing smart contract corresponds to a built-in block or a built-in area in the transaction block. According to the logical relationship between the various processing logics in the timing smart contract, the built-in blocks or built-in areas corresponding to each processing logic are determined or connected in series.

[0154] S801: Provide the oracle contract with the current time sent by the trusted oracle;

[0155] S802: The oracle contract sends the current time to multiple timing trigger functions included in the smart contract;

[0156] S803: for each timed trigger function, execute: determine whether the current time satisfies the timed trigger function, if yes, execute step S804; otherwise, execute step S807;

[0157] S804: Determine a built-in block or built-in area corresponding to the processing logic;

[0158] S805: Determine whether the currently required resource amount is not greater than the consumable resource amount corresponding to the built-in block or built-in area. If so, execute step S806; otherwise, execute step S807;

[0159] S806: Execute the built-in block or built-in area and end the current process;

[0160] For the first implementation of step S800, step S806 specifically includes executing the transaction corresponding to the processing logic;

[0161] Regarding the first implementation method in step S800, step S806 specifically includes executing the built-in block or built-in area corresponding to the processing logic.

[0162] S807: Execution prohibited.

[0163] It is worth noting that in the above Figure 7 and Figure 8 In the given embodiment, the current time received by the oracle contract can also be recorded in the corresponding log file to facilitate the verification of the current time and ensure the accuracy of the scheduled execution of the scheduled smart contract.

[0164] like Fig. 9 As shown, an embodiment of the present invention provides a registration device 900 for a timed smart contract in a blockchain. The registration device 900 for a timed smart contract in a blockchain may include: a receiving unit 901 and a registration unit 902, wherein:

[0165] A receiving unit 901, configured to receive a registration request for a timed smart contract;

[0166] The registration unit 902 is used to generate an interface connected to the oracle contract for the timing smart contract according to the registration request received by the receiving unit 901, wherein the oracle contract is deployed on the blockchain and is used to receive the time information sent by the trusted oracle to provide the time information to the timing smart contract through the interface.

[0167] In the embodiment of the present invention, Fig. 9 As shown, the registration device 900 for the timed smart contract in the blockchain may further include:

[0168] The processing unit 903 is used to generate corresponding transaction blocks for other smart contracts and record transactions corresponding to other smart contracts in the transaction blocks, wherein the other smart contracts are smart contracts without event triggering functions, so that the other smart contracts are executed based on the transaction blocks.

[0169] In an embodiment of the present invention, the processing unit 903 is further used to generate a corresponding built-in block or a built-in area in the transaction block for the timed smart contract; configure the corresponding consumable resource amount for the built-in block or the built-in area in the transaction block, and record the transaction corresponding to the timed smart contract in the transaction block, so that the timed smart contract is executed based on the built-in block or the built-in area in the transaction block.

[0170] like Fig.10 As shown, an embodiment of the present invention provides an execution device 1000 for a timed smart contract in a blockchain. The execution device 1000 for a timed smart contract in a blockchain may include: an interaction unit 1001, an interface 1002 corresponding to each timed smart contract, and an execution unit 1003, wherein:

[0171] An interaction unit 1001 is used to provide the oracle contract with time information sent by a trusted oracle, wherein the trusted oracle is selected from a plurality of oracles;

[0172] The interface 1002 corresponding to each timed smart contract is used to connect the corresponding timed smart contract to the oracle contract, and provide the time information received by the oracle contract to the timed smart contract, wherein the timed smart contract includes a timed trigger function;

[0173] The execution unit 1003 is used to execute the timed smart contract when the time information received by the timed smart contract satisfies the timed trigger function.

[0174] In the embodiment of the present invention, Fig.10 As shown, the execution device 1000 of the timed smart contract in the blockchain may further include:

[0175] The deployment unit 1004 is used to determine a trusted oracle from multiple oracles by using a polling method.

[0176] In an embodiment of the present invention, the deployment unit 1004 is further used to select, by voting, from a plurality of oracles, an oracle whose voting ratio is not less than a preset ratio threshold as a trusted oracle.

[0177] In the embodiment of the present invention, Fig.10 As shown, the execution device 1000 of the timed smart contract in the blockchain may further include:

[0178] The verification unit 1005 is used to generate a record log and record the time information provided by the interaction unit 1001 in the record log; when receiving a query request from a trusted node or other trusted oracle in the blockchain, the record log is provided to the trusted node or other trusted oracle; based on the query result, it is verified whether the time information recorded in the record log is accurate. If not, the trusted oracle is marked as untrustworthy, and the step of selecting a trusted oracle from multiple oracles is re-executed.

[0179] In an embodiment of the present invention, the execution unit 1003 is further used to set a transaction block for the non-scheduled smart contract, wherein the transaction block records transactions corresponding to other smart contracts; when an execution trigger of other smart contracts is received, the transaction block corresponding to the other smart contracts is executed.

[0180] In an embodiment of the present invention, the execution unit 1003 is further used to set a built-in block or a built-in area located in a transaction block for a timed smart contract, and the built-in block or the built-in area is configured with a corresponding consumable resource amount, wherein the built-in block or the built-in area records the transaction of the timed smart contract; when receiving an execution trigger of the timed smart contract, it is determined whether the currently required resource amount is not greater than the consumable resource amount corresponding to the built-in block or the built-in area, and if so, the built-in block or the built-in area corresponding to the timed smart contract is executed, otherwise, execution is prohibited.

[0181] In an embodiment of the present invention, when the timed smart contract includes at least two timed trigger functions, and each timed trigger function corresponds to a processing logic in the timed smart contract;

[0182] The execution unit 1003 is further used to execute the processing logic corresponding to the timing trigger function.

[0183] like Fig.11 As shown, an embodiment of the present invention provides an execution system 1100 for a timed smart contract in a blockchain. The execution system 1100 for a timed smart contract in a blockchain may include: a plurality of oracles 1101 and an execution device 1000 for a timed smart contract in a blockchain provided in the above embodiment, wherein:

[0184] An execution device 1000 of a timed smart contract in a blockchain, used to select a trusted oracle from a plurality of oracles;

[0185] Each oracle 1101, after being elected as a trusted oracle, provides time information to the oracle contract through the execution device of the timing smart contract in the blockchain.

[0186] In the embodiment of the present invention, Fig.11 As shown, the embodiment of the present invention provides an execution system 1100 of a timed smart contract in a blockchain, further comprising: a trusted node 1103 arranged on the blockchain, wherein:

[0187] The execution device 1000 of the timed smart contract in the blockchain is further used to generate a record log and record the time information in the record log; when receiving a query request from the trusted node 1103 or other trusted oracle in the blockchain, the record log is provided to the trusted node or other trusted oracle; the time information recorded in the record log is verified by the trusted node or other trusted oracle to be accurate. If not, the trusted oracle is marked as untrustworthy, and the step of selecting a trusted oracle from multiple oracles is re-executed.

[0188] Fig.12An exemplary system architecture 1200 is shown, to which a method for registering a timed smart contract in a blockchain or a device for registering a timed smart contract in a blockchain or a method for executing a smart contract in a blockchain or a device for executing a smart contract in a blockchain, to which an embodiment of the present invention may be applied.

[0189] like Fig.12 As shown, the system architecture 1200 may include a blockchain network 1201 and an external device 1202 of the blockchain network 1201, wherein the blockchain network 1201 refers to a network for sharing data between nodes, and the blockchain network 1201 may include multiple nodes 12011. Each node 12011 can receive input information from the external device 1202 or information broadcast by other nodes during normal operation, and maintain the shared data (i.e., blockchain) in the blockchain network based on the received input information. In order to ensure the information intercommunication within the blockchain network 1201, there can be an information connection between each node, and peer-to-peer (P2P) communication can be achieved between any two nodes, and P2P communication can be performed specifically through a wired communication link or a wireless communication link. For example, when any node in the blockchain network receives input information, other nodes obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes in the blockchain network are consistent. The external device 1202 may include: terminal devices 12021, 12022, 12023, a database 12024, a business server 12025 and a prophecy machine 12026. The external device 1202 may be connected to the blockchain network 1201 and may communicate with the node 12011 in the blockchain network 1201.

[0190] Node 12011 in blockchain network 1201 is deployed with a timed smart contract and a oracle contract. Users can use terminal devices 12021, 12022, 12023, database 12024, business server 12025 and oracle 12026 to interact with blockchain network 1201 to receive or send messages, etc. For example, oracle 12026 sends the current time to the oracle contract.

[0191] Terminal devices 12021, 12022, 12023 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0192] The node 12011 in the blockchain network 1201 may be a server that provides various services, such as a management server that provides support for transaction data submitted by users using terminal devices 12021, 12022, and 12023, or a background management server that provides support for reconciliation data submitted by the business server 12025 or the database 12024, or a management server that provides support for business data or reconciliation data or current time submitted by the oracle 12026 (for example only). The node 12011 in the blockchain network 801 may call the corresponding smart contract for the received business data or reconciliation data, etc., so as to analyze and process the business data or reconciliation data according to the smart contract.

[0193] It should be noted that the registration method of the smart contract in the blockchain or the execution method of the smart contract in the blockchain provided in the embodiment of the present invention is generally executed by the node 12011 in the blockchain network 1201. Accordingly, the registration device of the smart contract in the blockchain or the execution device of the smart contract in the blockchain is generally set in the node 12011 in the blockchain network 1201.

[0194] It should be understood that Fig.12 The number of nodes, terminal devices, databases, business servers, and oracle machines in the blockchain network is only illustrative. Depending on the implementation needs, there can be any number of nodes, terminal devices, databases, business servers, and oracle machines in the blockchain network.

[0195] like Fig.13 As shown, the computer system 1300 includes a central processing unit (CPU) 1301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1302 or the program loaded from the storage part Y08 to the random access memory (RAM) 1303. In the RAM 1303, various programs and data required for the operation of the system 1300 are also stored. The CPU 1301, ROM 1302 and RAM 1303 are connected to each other through the bus Y04. An input / output (I / O) interface 1305 is also connected to the bus 1304.

[0196] The following components are connected to the I / O interface 1305: an input section 1306 including a keyboard, a mouse, etc.; an output section 1307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1308 including a hard disk, etc.; and a communication section 1309 including a network interface card such as a LAN card, a modem, etc. The communication section 1309 performs communication processing via a network such as the Internet. A drive 1310 is also connected to the I / O interface 1305 as needed. A removable medium 1311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1310 as needed, so that a computer program read therefrom is installed into the storage section 1308 as needed.

[0197] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code 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 1309, and / or installed from the removable medium 1311. When the computer program is executed by the central processing unit (CPU) 1301, the above-mentioned functions defined in the system of the present invention are executed.

[0198] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, 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 may 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 (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0199] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a 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 flow chart, and the combination of the boxes in the block diagram or flow chart 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 computer instructions.

[0200] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a receiving unit and a registration unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the receiving unit may also be described as a "unit for receiving a registration request for a timed smart contract".

[0201] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a registration request for a timed smart contract; according to the registration request, generating an interface connected to an oracle contract for the timed smart contract, wherein the oracle contract is deployed on the blockchain and is used to receive time information sent by a trusted oracle to provide time information to the timed smart contract through the interface.

[0202] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: providing the oracle contract with time information sent by a trusted oracle, wherein the trusted oracle is selected from multiple oracles; providing time information to a timed smart contract through an interface, wherein the timed smart contract includes a timed trigger function, and the timed smart contract is connected to the oracle contract through an interface; when the time information satisfies the timed trigger function, the timed smart contract is executed.

[0203] According to the technical solution of the embodiment of the present invention, by registering a timed smart contract deployed on the blockchain, an interface connected to the oracle contract can be generated for the timed smart contract. After the oracle contract receives the time information sent by the trusted oracle, the time information is sent to the timed smart contract through the interface, so that the timed smart contract can be executed on time according to the time information, thereby realizing the management and execution of the timed smart contract through the blockchain.

[0204] In addition, the time-triggered function can be any function that can implement timing, and trigger the execution of its corresponding timed smart contract or the processing logic within the timed smart contract through the timing.

[0205] In addition, since the scheduled smart contract obtains time information through the oracle contract deployed on the blockchain, that is, the scheduled smart contract does not directly interact with the outside world, by limiting the information that can be transmitted by the interface (connecting the oracle contract and the scheduled smart contract), it is possible to effectively avoid aggressive information attacks on the scheduled smart contract. In addition, since one oracle contract can connect to multiple scheduled smart contracts and the oracle contract function is relatively simple, it is convenient for users to maintain the oracle contract.

[0206] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A registration method for a timed smart contract in a blockchain, characterized in that: include: Receive registration request for timed smart contract; According to the registration request, an interface connected to the oracle contract is generated for the timing smart contract, wherein the oracle contract is deployed on the blockchain and is used to receive time information sent by a trusted oracle, so as to provide the time information to the timing smart contract through the interface; The timed smart contract refers to a smart contract with a time trigger function, which is triggered by combining time with the time trigger function. The time information is input into the time trigger function to determine whether the time information satisfies the time trigger function. If it does, the timed smart contract corresponding to the time trigger function or the logic execution in the timed smart contract corresponding to the time trigger function is triggered; The timing smart contract includes one or more time-triggered functions; In the case where the timed smart contract includes a time-triggered function, after the time-triggered function is triggered, all processing logics included in the timed smart contract are executed; In the case where the timing smart contract includes multiple time trigger functions, each processing logic included in the timing smart contract corresponds to one time trigger function, and after any one or more time trigger functions are triggered, the processing logic corresponding to the triggered time trigger function included in the timing smart contract is executed; The registration method further includes: generating a corresponding built-in block or a built-in area in a transaction block for the timed smart contract, configuring a corresponding consumable resource amount for the built-in block or the built-in area in the transaction block, and recording a transaction corresponding to the timed smart contract in the transaction block, so that the timed smart contract is executed based on the built-in block or the built-in area in the transaction block, wherein the transaction block is a transaction block corresponding to other smart contracts or a transaction block generated for the timed smart contract, and the other smart contracts are smart contracts without a time trigger function.

2. The registration method of a timed smart contract in a blockchain according to claim 1, characterized in that: Further including: Generate corresponding transaction blocks for other smart contracts, and record transactions corresponding to the other smart contracts in the transaction blocks, so that the other smart contracts are executed based on the transaction blocks.

3. A method for executing a timed smart contract in a blockchain, characterized in that: include: Providing time information sent by a trusted oracle to an oracle contract, wherein the trusted oracle is selected from a plurality of oracles, and the oracle contract is deployed on the blockchain; The oracle contract provides the time information to the timing smart contract through an interface, wherein the timing smart contract includes a time trigger function, and the timing smart contract is connected to the oracle contract through the interface; when the time information satisfies the time trigger function, the timing smart contract is executed; The timing smart contract includes one or more time-triggered functions; In the case where the timed smart contract includes one of the time-triggered functions, after the time-triggered function is triggered, all processing logics included in the timed smart contract are executed; In the case where the timing smart contract includes multiple time trigger functions, each processing logic included in the timing smart contract corresponds to one time trigger function. After any one or more time trigger functions are triggered, the processing logic corresponding to the triggered time trigger function included in the timing smart contract is executed; The timed smart contract is provided with a built-in block or a built-in area in a transaction block, the built-in block or the built-in area is configured with a corresponding amount of consumable resources, and the built-in block or the built-in area records the transaction of the timed smart contract, so that the timed smart contract is executed based on the built-in block or the built-in area in the transaction block, wherein the transaction block is a transaction block corresponding to other smart contracts or a transaction block generated for the timed smart contract, and the other smart contracts are smart contracts without a time trigger function.

4. The method for executing a timed smart contract in a blockchain according to claim 3, characterized in that: Further including: Use polling to determine the trusted oracle from multiple oracles; or, A voting method is used to select a trusted oracle from multiple oracles.

5. The method for executing a timed smart contract in a blockchain according to claim 3, characterized in that: Further including: Generate a record log, and record the time information in the record log; When receiving a request for access from a trusted node or other trusted oracle in the blockchain, providing the record log to the trusted node or other trusted oracle; According to the results of the review, verify whether the time information recorded in the log is accurate. If not, the trusted oracle is marked as untrustworthy, and the step of selecting a trusted oracle from multiple oracles is re-executed.

6. The method for executing a timed smart contract in a blockchain according to claim 3, characterized in that: Further including: A transaction block is provided for the non-scheduled smart contract, wherein the transaction block records the transactions corresponding to the other smart contracts; When the execution trigger of the other smart contract is received, the transaction block corresponding to the other smart contract is executed.

7. The method for executing a timed smart contract in a blockchain according to claim 6, characterized in that: The steps of executing the timing smart contract include: When the execution trigger of the timed smart contract is received, it is determined whether the currently required amount of resources is not greater than the consumable amount of resources corresponding to the built-in block or the built-in area. If so, the built-in block or the built-in area corresponding to the timed smart contract is executed; otherwise, execution is prohibited.

8. A registration device for a timed smart contract in a blockchain, characterized in that: include: A receiving unit and a registering unit, wherein: The receiving unit is used to receive a registration request for a timed smart contract; The registration unit is used to generate an interface connected to the oracle contract for the timing smart contract according to the registration request, wherein the oracle contract is deployed on the blockchain and is used to receive time information sent by a trusted oracle to provide the time information to the timing smart contract through the interface; The timed smart contract refers to a smart contract with a time trigger function, which is triggered by combining time with the time trigger function. The time information is input into the time trigger function to determine whether the time information satisfies the time trigger function. If it does, the timed smart contract corresponding to the time trigger function or the logic execution in the timed smart contract corresponding to the time trigger function is triggered; The timing smart contract includes one or more time-triggered functions; In the case where the timed smart contract includes a time-triggered function, after the time-triggered function is triggered, all processing logics included in the timed smart contract are executed; In the case where the timing smart contract includes multiple time trigger functions, each processing logic included in the timing smart contract corresponds to one time trigger function, and after any one or more time trigger functions are triggered, the processing logic corresponding to the triggered time trigger function included in the timing smart contract is executed; The registration device further comprises a processing unit, wherein: The processing unit is further used to generate a corresponding built-in block or a built-in area in a transaction block for the timed smart contract, configure a corresponding consumable resource amount for the built-in block or the built-in area in the transaction block, and record the transaction corresponding to the timed smart contract in the transaction block, so that the timed smart contract is executed based on the built-in block or the built-in area in the transaction block, wherein the transaction block is a transaction block corresponding to other smart contracts or a transaction block generated for the timed smart contract, and the other smart contracts are smart contracts without a time trigger function.

9. A device for executing a timed smart contract in a blockchain, characterized in that: include: The interaction unit, the interface corresponding to each timed smart contract, and the execution unit, where: The interaction unit is used to provide the oracle contract with time information sent by a trusted oracle, wherein the trusted oracle is selected from a plurality of oracles, and the oracle contract is deployed on the blockchain; The interface corresponding to each of the timing smart contracts is used to connect the corresponding timing smart contract to the oracle contract, and provide the time information received by the oracle contract to the timing smart contract, wherein the timing smart contract includes a time trigger function; The execution unit is configured to execute the timing smart contract when the time information received by the timing smart contract satisfies the time trigger function; The timing smart contract includes one or more time-triggered functions; The execution unit is further configured to execute all processing logics contained in the timing smart contract after the time trigger function is triggered, in response to the situation where the timing smart contract includes the time trigger function; The execution unit is further used for the case where the timed smart contract contains multiple time-triggered functions, each processing logic contained in the timed smart contract corresponds to one time-triggered function, and after any one or more of the time-triggered functions are triggered, the processing logic corresponding to the triggered time-triggered function contained in the timed smart contract is executed; the timed smart contract is provided with a built-in block or a built-in area located in a transaction block, the built-in block or the built-in area is configured with a corresponding consumable resource amount, and the built-in block or the built-in area records the transaction corresponding to the timed smart contract; The execution unit is further used to execute the timed smart contract based on a built-in block or a built-in area located in a transaction block, wherein the transaction block is a transaction block corresponding to other smart contracts or a transaction block generated for the timed smart contract, and the other smart contracts are smart contracts without a time trigger function.

10. A system for executing a timed smart contract in a blockchain, characterized in that: include: Multiple oracles and a device for executing a timed smart contract in a blockchain as described in claim 9, wherein: An execution device of a timed smart contract in the blockchain, configured to select a trusted oracle from the plurality of oracle machines; Each of the oracle machines is used to provide time information to the oracle contract through the execution device of the timing smart contract in the blockchain after being elected as the trusted oracle machine.

11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Block chain-based time service oracle machine implementation method

    CN110633286A

  • Intelligent contract timing processing method, blockchain node and storage medium

    CN111367621A

  • Method and device for starting intelligent contract, electronic equipment and storage medium

    CN111818185A