Blockchain smart contract method, electronic device, computer readable storage medium, and blockchain system

CN112085600BActive Publication Date: 2026-08-21徐皓
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010920884.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-04
Publication Date
2026-08-21
Estimated Expiration
2040-09-04

AI Technical Summary

Technical Problem

发送交易的用户除了提供智能合约调用参数外,对于智能合约的执行结果没有任何控制

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112085600B_ABST
    Figure CN112085600B_ABST
Patent Text Reader

Abstract

This invention provides a smart contract method for blockchain, comprising: S1, a node receiving a smart transaction submitted by a user or a block transmitted by another node, the block containing the smart transaction; S2, the node executing all smart contract calls in the smart transaction, the smart contract adding input items to the transaction; S3, the node verifying the legality of the smart transaction, including verifying the integrity of the transaction after all smart contract calls have been executed; S4, if the verification result is that the transaction is legal, the smart transaction is accepted; otherwise, the smart transaction is rejected. A smart transaction is a transaction containing smart contract calls, and the smart transaction can define user expectations in the output items of the transaction; the smart contract provides appropriate input to satisfy the user's desired result. The blockchain node verifies whether the input provided by the smart contract satisfies the user's desired result. In the sense of contract law, this is equivalent to verifying whether the intentions of both parties are consistent. Only transactions that pass verification will be accepted by the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, specifically to a blockchain smart contract method, electronic device, computer-readable storage medium, and blockchain system. Background Technology

[0002] A smart contract is a computer protocol designed to transmit, verify, or execute contracts in an informational manner. Smart contracts allow for trusted transactions without a third party; these transactions are traceable and irreversible. Blockchain technology not only supports programmable contracts but also possesses advantages such as decentralization, immutability, and transparent traceability, making it naturally suited for smart contracts. Ethereum was the first blockchain to support Turing-complete smart contracts.

[0003] Blockchain smart contracts are programs and data deployed on a blockchain. Users trigger the execution of smart contract programs by sending transactions containing calls to smart contracts to blockchain nodes. Upon receiving the transaction, the blockchain node executes the called smart contract program. If the smart contract program returns a successful execution result, the blockchain node packages the transaction into a block and adds the block to the blockchain. Users sending transactions have no control over the execution result of the smart contract, except for providing the smart contract call parameters. Furthermore, the smart contracts deployed by the contract developers may contain errors or even malicious code. If the execution result does not meet the caller's expectations due to a misunderstanding of the smart contract by the caller, or if the smart contract itself contains errors or malicious intent, the caller can only accept it. This is because once the smart contract executes successfully, the caller cannot prevent the blockchain node from adding the transaction to the block, making it part of the blockchain record, and blockchain records are immutable and irreversible. Summary of the Invention

[0004] This invention proposes a blockchain smart contract method aimed at improving the aforementioned problems.

[0005] This invention is implemented as follows: a smart contract method for blockchain, the method specifically including the following steps:

[0006] S1. The node receives smart transactions or blocks, and the blocks contain smart transactions;

[0007] S2. The node executes all smart contract calls in the smart transaction. The smart contract adds input items to the transaction, or adds both input items and output items to the transaction.

[0008] S3. The node verifies the legality of the smart transaction. The legality verification of the transaction includes verifying the integrity of the transaction after all smart contract calls have been executed.

[0009] S4. If the verification result shows that the transaction is valid, accept the smart transaction; otherwise, reject the smart transaction.

[0010] A smart transaction is a transaction that includes smart contract calls. The smart transaction creator's expectations can be defined in the transaction's output.

[0011] If a node receives a smart transaction, accepting the smart transaction means packaging it into the current block; rejecting the smart transaction means abandoning it.

[0012] If a node receives a block, rejecting a smart transaction means abandoning that block.

[0013] Furthermore, the node uses a virtual machine to interpret and execute the program of the smart contract. The instruction set of the virtual machine includes spending instructions. The method of the virtual machine interpreting and executing the spending instructions includes the following steps: adding input items to the input list of the smart transaction.

[0014] Furthermore, the instruction set of the virtual machine includes at least one of the following instructions: payment instructions;

[0015] The method for the virtual machine to interpret and execute the payment instruction includes the following steps: adding an output item to the output list of the smart transaction;

[0016] Furthermore, the script in the output item is a call to another smart contract.

[0017] Furthermore, when the virtual machine executes a payment instruction, it adds the output items contained in the payment instruction data to the smart transaction's output list.

[0018] Furthermore, the method for the virtual machine to interpret and execute the cost instructions also includes the following steps:

[0019] The input item is the data in the spending instruction. The virtual machine verifies whether the input item is owned by the smart contract. Only if the verification result is yes will the input item be added to the input list of the smart transaction.

[0020] The present invention is implemented as follows: a blockchain system comprising several nodes and terminal devices, wherein the terminal devices can send smart transactions to nodes, and the nodes can send blocks to other nodes; after receiving a smart transaction or block, the node executes the blockchain smart contract method as described above.

[0021] The present invention is implemented as follows: an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the blockchain smart contract method as described above.

[0022] The present invention is implemented as follows: a computer-readable storage medium storing a program that implements the blockchain smart contract method as described above.

[0023] The smart transaction creator describes the desired outcome by defining the transaction outputs. The smart contract provides appropriate inputs to satisfy the smart transaction creator's desired outcome. Blockchain nodes verify the integrity of the smart contract, that is, whether the contract's outputs match, and thus verify whether the inputs provided by the smart contract meet the user's desired outcome. In the sense of contract law, the smart transaction creator's intent is embodied in the outputs, and the smart contract's intent (that is, the smart contract developer's intent) is embodied in the inputs. The blockchain node's verification of the smart contract's integrity is equivalent to verifying whether the intentions of both parties are consistent. Only transactions that pass verification are accepted by the blockchain, i.e., agreement in the sense of contract law. Therefore, smart contracts using the method of this invention are more in line with the legal definition of a contract. It can refuse to accept smart contract execution results that do not meet the user's expectations. Attached Figure Description

[0024] Figure 1 This is a schematic diagram of the structure of a blockchain system provided in an embodiment of the present invention;

[0025] Figure 2 A flowchart of a blockchain smart contract method provided in an embodiment of the present invention. Detailed Implementation

[0026] Various embodiments are possible based on the principles of this invention. The technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments or principles of this invention without creative effort are within the scope of protection of this invention.

[0027] Figure 1This is a blockchain system consisting of one or more network terminals (S102) connected to the internet (S101) and one or more blockchain nodes (S103) connected to the internet (S101). The network terminals (S102) construct transactions based on user input and send the transaction information to the blockchain nodes (S103) via the internet (S101). Each blockchain node (S103) can receive transaction information from the network terminals (S102) and blocks from other nodes (S103). A transaction includes an input list and an output list. Each output of a transaction includes a token. A token is a representation of value. In some blockchain implementations, a UTXO ledger is used, where each input of a transaction contains a reference to another transaction output; in other blockchain implementations, an account ledger is used, where each input of a transaction contains a token and an address. After receiving the transaction information, the node (S103) verifies the validity of the received transaction, including verifying that the input tokens of the transaction are unused tokens in the blockchain and that the transaction has appropriate authorization. For blockchains using Unspent Transaction Outputs (UTXOs) accounting, unused tokens refer to tokens in transaction outputs that have not been referenced as inputs by any transaction. For blockchains using account accounting, unused tokens refer to tokens within the account of the input address. Node (S103) packages the legitimate transactions received within a certain period into a block, adds this block as the latest block to its local blockchain, and broadcasts it to other nodes (S103) in the network (S101). After receiving new blocks from other nodes (S103), node (S103) verifies that all transactions in the received block are legitimate. If all transactions are verified as legitimate, the node adds this block as the latest block to the end of its local blockchain.

[0028] Verifying the legitimacy of a transaction includes verifying its integrity.

[0029] One embodiment of the present invention is a blockchain smart contract method. A smart contract on the blockchain includes a smart contract program (code) stored on the blockchain and data describing its state. Users can submit transactions containing smart contract calls to nodes; these are called smart transactions. A smart contract call generally includes a smart contract address and parameters; the smart contract address specifies the smart contract to be called, and the parameters are the data required to execute the smart contract. The smart transaction submitted by the user may be incomplete, meaning the total input value and the total output value may not be the same. For example... Figure 2 As shown, the method includes the following steps:

[0030] S1. Blockchain nodes receive smart transactions submitted by users; a smart transaction is a transaction that includes smart contract calls; users include people or electronic devices that are locally connected to the node or connected via a network; the output of a smart transaction defines the expectations of the smart transaction creator (i.e., the user);

[0031] S2. The node executes all smart contract calls in the smart transaction; during execution, the smart contract performs one of the following steps:

[0032] S2.1 Add input items to the associated smart trade;

[0033] S2.2, Add input items to the associated smart trade and:

[0034] S2.2.1 Add output items to the associated Smart Transaction.

[0035] S3, the node verifies the legality of smart transactions, including verifying the integrity of smart transactions;

[0036] S4. If the smart transaction is valid, the blockchain node accepts it; accepting a smart transaction includes adding it to the current block; if the smart transaction is invalid, the blockchain node abandons it.

[0037] Generally speaking, "expectation" is a subjective term. However, in this invention, we define "expectation" with an objective standard: an expectation is an unmet output in a transaction, that is, there is no matching input in the transaction, or the number of matching inputs is less than the output.

[0038] In traditional blockchain technology, transactions with incomplete outputs are considered invalid and will be rejected by nodes. However, in this invention, because smart contracts can add inputs to transactions, nodes do not immediately reject transactions with incomplete outputs. Instead, they wait until the smart contract execution is complete before determining the transaction's validity.

[0039] The current block is a new block that a blockchain node is currently constructing. After a blockchain node packages a certain number of legitimate transactions (including ordinary transactions without smart contract calls) into the current block, it adds the current block to its local blockchain and broadcasts it to the entire network.

[0040] Another embodiment of the present invention is a blockchain smart contract method. Other nodes can send new blocks to a node, and the new blocks contain smart transactions. The method includes the following steps:

[0041] S21. A blockchain node receives a block transmitted by other nodes. This block contains smart transactions; this block is called the current block.

[0042] S22. For each smart transaction in the current block, the node executes all smart contract calls within the smart transaction; the user's expectations are defined in the output of the smart transaction; during execution, the smart contract performs one of the following steps:

[0043] S2.1 Add input items to the associated smart trade;

[0044] S2.2, Add input items to the associated smart trade and:

[0045] S2.2.1 Add output items to the associated smart transaction;

[0046] S23. Nodes verify the legality of smart transactions, including verifying the integrity of smart transactions;

[0047] S24. If the smart transaction is invalid, abandon the current block;

[0048] If all transactions in the received block are valid (including ordinary transactions without smart contract calls), the blockchain node adds the current block to its local blockchain.

[0049] In steps S2.1, S2.2, and S2.2.1 of the above two embodiments, the operation of adding input / output can be performed multiple times and in any order.

[0050] In this embodiment of the invention, if any smart contract call fails, the node abandons the smart transaction; if the smart transaction belongs to a new block transmitted by another node, the node abandons the new block.

[0051] Verification of the legitimacy of a smart transaction includes: verifying the signature of the original input items, preventing double-spending, and verifying the integrity of the transaction. Original input items refer to the input items included in the smart transaction submitted by the user, not input items added to the smart transaction by the smart contract. For embodiments using UTXO accounting, preventing double-spending includes verifying that all input items in the smart transaction (including input items added during smart contract execution) reference unused transaction outputs. A legitimate transaction must be complete. Verifying transaction integrity includes verifying that the total value of all input tokens and the total value of all output tokens in the smart transaction are equal after all smart contract calls have been executed, taking transaction fees into account if necessary.

[0052] A transaction consists of a set of inputs and a set of outputs. Each output includes a token and a script. The script includes an output address; if the output address is a smart contract address, then the output is a call to the smart contract. The script also includes parameters for calling the smart contract. A smart transaction is a transaction that contains smart contract call outputs. A smart transaction can contain multiple outputs with smart contract calls, and blockchain nodes execute the smart contract calls in the smart transaction sequentially.

[0053] During the execution of a smart contract call, inputs or outputs can be added to the current smart transaction. Adding an input to a transaction means adding the input to the transaction's input list; adding an output to a transaction means adding the output to the transaction's output list.

[0054] Generally, to avoid executing smart contract calls every time transaction data is retrieved, the actual transaction data stored in the blockchain database includes the inputs and outputs added by the smart contract. However, when blocks are transmitted between nodes, the receiving node executes the smart contract calls within the transaction during transaction verification, generating the inputs and outputs added by the smart contract. Therefore, to reduce data transmission, the transactions in the transmitted block only contain the original inputs and outputs, excluding those added by the smart contract. If the transmitted block contains inputs and outputs added by the smart contract, to avoid redundant calculations during transaction verification, the inputs and outputs added by the smart contract need to be stripped before executing the smart contract. Therefore, it is necessary to distinguish which inputs / outputs are original (i.e., submitted by the user) and which are added by the smart contract in smart transactions. One method is to add an isolation item to the input / output list. Before adding any input / output to the smart transaction for the first time, an isolation item is added to the corresponding list. Inputs / outputs before the isolation item in the list are original inputs / outputs, and those after are added by the smart contract. Another approach is to add a flag to the input / output item to indicate whether the item was original or added by a smart contract.

[0055] In some embodiments of the present invention, a node includes a virtual machine capable of interpreting and executing smart contract programs. A smart contract program is a sequence of virtual machine instructions. The method by which a blockchain node executes a smart contract program includes starting the virtual machine to interpret and execute the called smart contract program. Starting the virtual machine includes reading the smart contract program from the blockchain based on the smart contract address in the smart contract call to be executed, setting the virtual machine's initial state based on the smart contract call parameters and the token in the transaction output item to which the smart contract call belongs, reading one instruction from the smart contract program determined according to the initial state, and interpreting and executing that instruction. For example, in a smart transaction, there is an output item whose token portion consists of 5 Class A tokens (denoted as 5A), and the script is a smart contract call. Specifically, the call includes a smart contract address B, and the call parameter is the smart contract's entry function C. The virtual machine will set its initial state to receive 5A, and the address of the first instruction will be the address of C. The virtual machine is a program that interprets and executes smart contract instructions. Instructions consist of two parts: instruction code and data. The instruction code defines the function to be executed. Therefore, each instruction code represents a type of instruction. All instruction types that the virtual machine can process constitute the virtual machine's instruction set.

[0056] The virtual machine reads an instruction from the smart contract program, interprets and executes it, and then reads the next instruction based on the virtual machine's state after interpretation and execution. This process continues until an instruction fails to execute or a termination instruction is reached. If an instruction fails to execute, the virtual machine returns a result of failure to the blockchain node. If a termination instruction is reached, the virtual machine returns a result of success or failure to the blockchain node based on its state at the end or the data from the termination instruction.

[0057] In embodiments of the present invention, during the interpretation and execution of a smart contract program, the virtual machine may add new input items and / or output items to the smart transaction that triggered the program's execution. One embodiment of the present invention is a blockchain smart contract virtual machine whose instruction set includes a spending instruction. When the virtual machine interprets and executes the spending instruction, it adds a new input item to the current transaction. Another embodiment of the present invention is a blockchain smart contract virtual machine whose instruction set includes a delivery instruction; when the virtual machine executes the delivery instruction, it adds a new output item to the current transaction.

[0058] In one embodiment of the present invention, the data of the spending instruction includes input item data. When the virtual machine interprets and executes the spending instruction, it verifies that the input item is owned by the called smart contract. For embodiments using UTXO accounting, the input item is a reference to another transaction output item; verifying that the called smart contract owns the input item includes verifying that the address in the script of the transaction output referenced by the input item is the address of the called smart contract. If the verification is successful, the input item is added to the input list of the current transaction, and the instruction execution is successful.

[0059] In one embodiment of the present invention, the delivery instruction data includes an output item, which includes a token and a script. When the virtual machine executes the delivery instruction, it verifies the validity of the token and script content. If the verification is successful, the output item is added to the output list of the current transaction, and the instruction is executed successfully.

[0060] In some embodiments of the present invention, the data of the input / output items added to the transaction by the aforementioned spending instructions and delivery instructions are included in the corresponding instruction data. For example, if the data of the spending instruction is U, the virtual machine will add U to the input list of the transaction when executing the instruction; if the data of the delivery instruction is V, the virtual machine will add V to the output list of the transaction when executing the instruction.

[0061] In other embodiments of the present invention, the above-mentioned spending instructions and delivery instructions do not directly contain the data of the input / output items to be added, but contain an address. These addresses may either store the input / output item data to be added to the transaction, in which case the virtual machine obtains the data from the address and adds it to the corresponding input / output list; or they may be the address of a program entry point, in which case the virtual machine executes the program and adds the execution result to the corresponding input / output list.

[0062] Smart contracts can implement the operations of adding inputs / outputs to transactions in the aforementioned steps S2.1, S2.2, and S2.2.1 by including spending instructions and delivery instructions in their programs.

[0063] In another embodiment of the invention, the smart contract program is not code that needs to be interpreted and executed by a virtual machine, but rather machine code that can be run directly on a computer. The operations of adding inputs / outputs to the transaction in the aforementioned steps S2.1, S2.2, and S2.2.1 are accomplished by calling the corresponding library functions provided by the blockchain.

[0064] Once all smart contract calls in a transaction have executed successfully, the node verifies the transaction's legality. Legality verification includes: verifying the signature of the original input items, preventing double-spending, and verifying the transaction's integrity after all smart contract calls have finished executing.

[0065] Double-spending prevention includes preventing double-spending on the original input and preventing double-spending on smart contracts. Preventing double-spending on smart contracts can be done either as a step in interpreting and executing spending instructions, or it can be done by blockchain nodes after all smart contract calls have been executed, treating the input items added by the smart contract and the original input items equally and processing them uniformly.

[0066] A valid transaction must be complete, meaning the total value of the tokens input and output (after taking transaction fees into account) must be equal. Nodes package valid transactions into blocks, add the valid blocks to their local blockchains, and broadcast them to other nodes.

[0067] In this embodiment, the token data includes two items: token type and token value. The token value can be one of the following two types:

[0068] a) A geometric shape; for example, a polygon represents a piece of land; the geometric shape in the token is not limited to polygons, but can be a polyhedron, or any mathematical geometric shape, such as a sphere, a curved surface, etc.

[0069] b) A unique value; a unique value is an identifier of an indivisible thing.

[0070] In other embodiments, token types are identified by type identifiers. Similarly, if two tokens are both polygon tokens but have different type identifiers, they are still considered to be tokens of different classes, and therefore their polygons cannot be merged.

[0071] In other embodiments, the token also includes a set of rights. That is, the token contains three pieces of data: a token type identifier, a token value, and a set of rights.

[0072] In some embodiments, using UTXO accounting, the inputs of a transaction contain references to the outputs of another transaction. We refer to the token in the referenced output as the input token.

[0073] In other embodiments, an account-based accounting method is used, where the input items for a transaction include a token and an address. We refer to this token as the input token.

[0074] If the tokens are typed, verifying transaction integrity includes verifying that, for each token type, the total amount of input tokens and the total amount of output tokens are equal (after taking transaction fees into account). For geometry-type tokens, the total amount is the combined geometry. For unique-value-type tokens, the total amount is the number of each unique value.

[0075] If the token also contains a set of stakes, verifying the integrity of the transaction includes verifying that for each token type, the input tokens and output tokens are split and merged separately, and verifying that the split and merged input token groups and output token groups contain the same tokens.

[0076] Using the method of this invention, smart contracts do not store the execution result as the internal state of the contract on the blockchain. Instead, they explicitly express the execution result by adding inputs / outputs to the transaction, and blockchain nodes can understand and process the transaction input and output data. Therefore, users can express the desired result by specifying outputs in their initiated transactions. In the sense of contract law, this is an expression of intent. Smart contracts provide appropriate inputs to satisfy the user's desired result. Blockchain nodes verify whether the inputs provided by the smart contract satisfy the user's desired result. In the sense of contract law, this is equivalent to verifying whether the intentions of both parties are consistent. Only transactions that pass verification are accepted by the blockchain. Therefore, smart contracts using the method of this invention are more in line with the legal definition of a contract. They can refuse to accept the execution result of a smart contract that does not meet the user's expectations.

[0077] Smart contracts can call other smart contracts. We call such calls secondary smart contract calls, and calls to smart contracts within user-submitted smart transactions are called primary smart contract calls. When a smart contract cannot directly meet a user's expectations, it can call another smart contract to fulfill those expectations. Secondary smart contract calls can be implemented using both traditional smart contract methods and the methods described in this invention.

[0078] Smart contracts can call other smart contracts. By deploying shareable, universal smart contracts on the blockchain to form a smart contract library, the storage space occupied by smart contracts can be effectively reduced, improving development efficiency. Allowing smart contracts to charge fees when called can increase the motivation of smart contract developers, leading to the development of more callable smart contracts and enriching the blockchain smart contract ecosystem.

[0079] One embodiment of the present invention is a blockchain system. For example... Figure 1 As shown, the system includes several nodes and several terminal devices connected in a network. The terminal devices send smart transactions to the nodes, the nodes send blocks to other nodes, and after receiving a smart transaction or block, the node processes the smart transaction or block using the aforementioned method.

[0080] One embodiment of the present invention is an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the aforementioned method when executing the program.

[0081] One embodiment of the present invention is a computer-readable storage medium, characterized in that the computer-readable storage medium stores a program for implementing the aforementioned method.

[0082] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0083] This invention is described with reference to a flow description (including flowcharts, block diagrams, and textual descriptions) of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each step in the flow description can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing one or more of the functions specified in the flow. These computer program instructions can also be stored in a computer-readable storage medium capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement one or more of the functions specified in the flow description.

[0084] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing one or more of the functions specified in the process description.

[0085] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0086] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0087] This application is described with reference to the steps of a method, apparatus (system), and computer program product according to embodiments of this application. It should be understood that each step can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more steps.

[0088] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the function specified in one or more steps.

[0089] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the function specified in one or more steps.

[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A smart contract method for blockchain, characterized in that, The method specifically includes the following steps: S1. The node receives smart transactions or blocks, and the blocks contain smart transactions; S2. The node executes all smart contract calls in the smart transaction. The smart contract adds input items to the transaction, or adds both input items and output items to the transaction. S3. The node verifies the legality of the smart transaction. The legality verification of the transaction includes verifying the integrity of the transaction after all smart contract calls have been executed. S4. If the verification result shows that the transaction is valid, accept the smart transaction; otherwise, reject the smart transaction. A smart transaction is a transaction that includes smart contract calls. The smart transaction defines the expectations of the smart transaction creator in the transaction's output. If a node receives a smart transaction, accepting the smart transaction means packaging the transaction and adding it to the current block; rejecting the smart transaction means abandoning it. If a node receives a block, rejecting the smart transaction means abandoning that block.

2. The smart contract method for blockchain as described in claim 1, characterized in that, The node uses a virtual machine to interpret and execute the program of the smart contract. The instruction set of the virtual machine includes spending instructions. The method of the virtual machine interpreting and executing the spending instructions includes the following steps: adding input items to the input list of the smart transaction.

3. The blockchain smart contract method as described in claim 2, characterized in that, The instruction set of the virtual machine includes at least one of the following instructions: payment instructions; The method for the virtual machine to interpret and execute the payment instruction includes the following steps: adding an output item to the output list of the smart transaction.

4. The smart contract method for blockchain as described in claim 3, characterized in that, The script in the output is a call to another smart contract.

5. The blockchain smart contract method as described in claim 3, characterized in that, When the virtual machine executes a payment instruction, it adds the output items contained in the payment instruction data to the smart transaction's output list.

6. The smart contract method for blockchain as described in claim 2, characterized in that, The method for a virtual machine to interpret and execute the overhead instructions further includes the following steps: The input item is the data in the spending instruction. The virtual machine verifies whether the input item is owned by the smart contract. Only if the verification result is yes will the input item be added to the input list of the smart transaction.

7. A blockchain system, characterized in that, The system includes several nodes and terminal devices. The terminal devices can send smart transactions to the nodes, and the nodes can send blocks to other nodes. After receiving a smart transaction or block, the node executes the blockchain smart contract method as described in any one of claims 1-6.

8. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the blockchain smart contract method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program that implements the blockchain smart contract method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Blockchain-based exchange with tokenisation

    CN108885745A