A method and device for publishing smart contracts in blockchain

By establishing a method of relying on trees and traversing smart contracts, the problem of low efficiency of smart contract release in existing technologies has been solved, and efficient and accurate smart contract releases are achieved, and the release process of smart contract releases is simplified.

CN110175844BActive Publication Date: 2025-01-28WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910373705.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-05-07
Publication Date
2025-01-28
Estimated Expiration
2039-05-07

AI Technical Summary

Technical Problem

In the existing technology, the release of smart contracts requires manual writing of release code, and the release order needs to be reorganized when smart contracts are updated or dependencies change, which is time-consuming and labor-intensive.

Method used

By obtaining smart contracts to be released, it traverses its dependence relationship, establishes n dependent trees, and starts from the leaf nodes of dependent trees, until the root node, and release the smart contracts corresponding to each node in turn.

Benefits of technology

Improve the release efficiency and accuracy of smart contracts, simplify the release process, do not need to organize the order of release, and just update the dependent tree when the smart contract is updated or rely on the change of dependency relationship.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110175844B_ABST
    Figure CN110175844B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention relate to the field of Fintech, and more particularly to a method and device for publishing smart contracts in a blockchain, so as to improve the publishing efficiency and accuracy of smart contracts. The embodiments of the present invention include: obtaining the smart contracts to be published; traversing the smart contracts to be published, and determining the dependencies between the smart contracts to be published; establishing N dependency trees based on the dependencies, wherein one node of the dependency tree corresponds to one smart contract; N≥1; for any dependency tree, starting from the leaf node of the dependency tree to the root node of the dependency tree, publishing the smart contracts corresponding to each node in turn.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to Fintech, and blockchain technology is no exception. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology.

[0003] Smart contract is a computer protocol designed to disseminate, verify or execute contracts in an information-based manner. Its execution process is consensus and confirmed on the blockchain in the form of transactions. Smart contracts allow for trusted transactions without a third party, and these transactions are traceable and irreversible.

[0004] Smart contracts are code snippets that run on the blockchain and need to be published on the blockchain before they can run. An existing blockchain application project sets up multiple modules according to functions, and each module is divided into several data structures according to functions. All functions are implemented using smart contracts and run on the blockchain.

[0005] Currently, each smart contract needs to be released separately. If the smart contract is updated, the previously written release code needs to be rewritten and the dependencies between the smart contracts need to be reorganized, which is time-consuming and labor-intensive. Summary of the invention

[0006] The present application provides a method and device for publishing smart contracts in a blockchain, so as to improve the efficiency and accuracy of publishing smart contracts.

[0007] An embodiment of the present invention provides a method for publishing a smart contract in a blockchain, comprising:

[0008] Get the smart contract to be published;

[0009] Traversing the smart contracts to be released, and determining the dependencies between the smart contracts to be released;

[0010] According to the dependency relationship, N dependency trees are established, and one node of the dependency tree corresponds to one smart contract; N≥1;

[0011] For any dependency tree, starting from the leaf node of the dependency tree to the root node of the dependency tree, the smart contracts corresponding to each node are published in sequence.

[0012] In an optional embodiment, before traversing the smart contracts to be published and determining the dependencies between the smart contracts to be published, the method further includes:

[0013] For any smart contract, perform the following steps:

[0014] Identify the address parameter called by the smart contract; the address parameter is used to indicate the smart contract called by the smart contract;

[0015] The address parameters are standardized to determine the smart contract corresponding to the address parameters.

[0016] In an optional embodiment, starting from the leaf node of the dependency tree to the root node of the dependency tree, publishing the smart contract corresponding to each node in sequence includes:

[0017] Publishing the smart contract corresponding to the leaf node of the dependency tree;

[0018] Remove the leaf node where the smart contract is successfully published from the dependency tree;

[0019] Repeat the step of publishing the smart contracts corresponding to the leaf nodes of the dependency tree until only the root node exists in the dependency tree;

[0020] The smart contract corresponding to the root node is published.

[0021] In an optional embodiment, after establishing N dependency trees according to the dependency relationship, the method further includes:

[0022] Receive smart contract change requests;

[0023] According to the smart contract change request, the nodes in the dependency tree are updated.

[0024] The embodiment of the present invention also provides a device for publishing a smart contract in a blockchain, comprising:

[0025] An acquisition unit, used to acquire the smart contract to be published;

[0026] A determination unit, configured to traverse the smart contracts to be published and determine dependencies between the smart contracts to be published;

[0027] An establishing unit, used to establish N dependency trees according to the dependency relationship, wherein one node of the dependency tree corresponds to one smart contract; N≥1;

[0028] The publishing unit is used to publish the smart contracts corresponding to each node in sequence, starting from the leaf node of the dependency tree to the root node of the dependency tree, for any dependency tree.

[0029] In an optional embodiment, the determining unit is further configured to:

[0030] For any smart contract, perform the following steps:

[0031] Identify the address parameter called by the smart contract; the address parameter is used to indicate the smart contract called by the smart contract;

[0032] The address parameters are standardized to determine the smart contract corresponding to the address parameters.

[0033] In an optional embodiment, the publishing unit is specifically used to:

[0034] Publishing the smart contract corresponding to the leaf node of the dependency tree;

[0035] Remove the leaf node where the smart contract is successfully published from the dependency tree;

[0036] Repeat the step of publishing the smart contracts corresponding to the leaf nodes of the dependency tree until only the root node exists in the dependency tree;

[0037] The smart contract corresponding to the root node is published.

[0038] In an optional embodiment, the acquisition unit is further used to receive a smart contract change request;

[0039] The establishing unit is also used to update the nodes in the dependency tree according to the smart contract change request.

[0040] An embodiment of the present invention further provides an electronic device, including:

[0041] at least one processor; and,

[0042] a memory communicatively connected to the at least one processor; wherein,

[0043] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described above.

[0044] An embodiment of the present invention further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method as described above.

[0045] In an embodiment of the present invention, a smart contract to be published is obtained, all smart contracts to be published are traversed, and the dependencies between smart contracts are determined. Based on the dependencies, N dependency trees are established, where one node of the dependency tree corresponds to one smart contract, and N≥1. For any dependency tree, starting from the leaf node of the dependency master to the root node of the dependency tree, the smart contracts corresponding to each node are published in sequence. Thus, by constructing a dependency tree to publish smart contracts, the smart contracts are automatically and efficiently published by traversing the tree, without the need to manually sort out the publishing order, without worrying about confusion, and improving the accuracy of smart contract publishing. In addition, if there is an update to the smart node or a change in the dependency relationship between the smart nodes, there is no need to rewrite the code. It is only necessary to change the nodes or node order in the dependency tree, reconstruct a new dependency tree, and re-execute the publishing and traversing of the dependency tree, thereby greatly simplifying the publishing process of the smart contract and improving the publishing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0047] Figure 1 A schematic diagram of a blockchain application project provided by an embodiment of the present invention;

[0048] Figure 2 A schematic diagram of a method for publishing a smart contract in a blockchain provided by an embodiment of the present invention;

[0049] Figure 3a-3f A schematic diagram of the structure of the dependency tree establishment process provided by an embodiment of the present invention;

[0050] Figure 4 A schematic diagram of the process of publishing a smart contract provided in the first specific embodiment of the present invention;

[0051] Figure 5 A flowchart of the publishing process of a smart contract after update provided in the second specific embodiment of the present invention;

[0052] Figure 6 A schematic diagram of the structure of a smart contract publishing device in a blockchain provided by an embodiment of the present invention;

[0053] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] To facilitate understanding, the terms that may be involved in the embodiments of the present invention are defined and explained below.

[0056] Blockchain: It is a chain composed of a series of blocks. In addition to recording the data of the current block, each block also records the Hash value of the previous block, forming a chain in this way. There are two core concepts of blockchain, one is cryptography technology, and the other is decentralization. Based on these two concepts, the historical information on the blockchain cannot be tampered with. A block consists of a block header and a block body. The block header definition includes important fields such as the block height h and the Hash value prevHash of the previous block, while the block body mainly stores transaction data.

[0057] Smart contract: A code snippet that can run on the blockchain. The execution of the smart contract will be agreed upon and confirmed on the blockchain in the form of a transaction.

[0058] Consensus: An algorithm by which nodes in a blockchain reach agreement on the correctness of a transaction.

[0059] web3j: A collection of libraries for interacting with local or remote Ethereum nodes using HTTP (Hyper Text Transfer Protocol) or IPC (Inter-Process Communication) connections.

[0060] WeIdentiy: A distributed multi-center technology solution that can carry the trusted mapping of the real identity of physical objects (people or things) and the identity on the chain, and realize secure access authorization and data exchange between physical objects.

[0061] Solidity: A high-level language for smart contracts that runs on the Ethereum Virtual Machine (EVM).

[0062] Java: An object-oriented programming language used to write desktop applications, web applications, distributed systems, embedded system applications, etc.

[0063] like Figure 1As shown, in an application scenario applicable to an embodiment of the present invention, an application project of a blockchain is divided into three modules according to functions, namely module A, module B and module C. Each module is further divided into multiple data structures according to functions. For example, module A is divided into three data structures A1, A2 and A3, module B is divided into three data structures B1, B2 and B3, and module C is divided into three data structures C1, C2 and C3. All these data structures are implemented by smart contracts and run on the blockchain, which are recorded as smart contract A1, smart contract B1, etc.

[0064] In the prior art, the smart contract written in Solidity is published by calling the web3j interface. Figure 1 The general release process is as follows:

[0065] Step 1: Publish module A, module B, and module C separately. Assuming that module A is published, start with smart contract A1, check the parameters in the construction method of smart contract A1, pass in the parameters, and call the web3j interface to publish. If the parameters of smart contract A1 contain other smart contracts, for example, the parameters of smart contract A1 contain the address parameters of smart contract A2 and smart contract B3, then you need to publish smart contract A2 and smart contract B3 first, and then publish smart contract A1.

[0066] Step 2: After each smart contract checks the parameters in the construction method according to step 1, write the release code and publish it until all modules are published.

[0067] Step 3: Finally, save the address of the smart contract to complete the release.

[0068] If there are subsequent updates to the smart contract or changes in dependencies, you will need to readjust the release code and re-release it according to the above steps.

[0069] In order to solve the above problems in the prior art, an embodiment of the present invention provides a method for publishing a smart contract in a blockchain, such as Figure 2 As shown, the method for publishing a smart contract in a blockchain provided by an embodiment of the present invention includes the following steps:

[0070] Step 201: Obtain the smart contract to be published.

[0071] Step 202: traverse the smart contracts to be released and determine the dependencies between the smart contracts to be released.

[0072] During the specific traversal process, according to the construction method of each smart contract, the address parameters in the smart contract are dynamically identified, and the dependency relationship is determined based on the address parameters. For example, if the construction method of smart contract A1 contains the address parameters of smart contract A2, then smart contract A1 is considered to be dependent on smart contract A2.

[0073] Step 203: Establish N dependency trees based on the dependency relationship, where one node of the dependency tree corresponds to one smart contract; N≥1.

[0074] The above steps dynamically construct multiple groups of tree-structured dependencies based on the dependencies within the smart contract scaffold. Each group of smart contracts with dependencies will form a dependency tree with a root node and multiple leaf nodes. If there is no dependency between any two smart contracts, the two smart contracts are located on two dependency trees respectively. In addition, each dependency tree has a root node, but not every dependency tree has leaf nodes. For example, if smart contract C1 does not depend on any other smart contract, and no other smart contract depends on smart contract C1, then smart contract C1 forms a dependency tree alone, which has only a root node corresponding to smart contract C1 and no leaf nodes.

[0075] Step 204: For any dependency tree, starting from the leaf node of the dependency tree to the root node of the dependency tree, publish the smart contracts corresponding to each node in sequence.

[0076] Specifically, after the dependency tree is dynamically constructed, each leaf node of the constructed dependency tree corresponds to a smart contract object. Assuming that the Java version of web3j is used to publish smart contracts, each smart contract can be converted into a Java class. If the construction method is constructed by matching the parameter name with the smart contract, then when publishing, the corresponding smart contract can be found by reflection and published dynamically.

[0077] In an embodiment of the present invention, a smart contract to be published is obtained, all smart contracts to be published are traversed, and the dependencies between smart contracts are determined. Based on the dependencies, N dependency trees are established, where one node of the dependency tree corresponds to one smart contract, and N≥1. For any dependency tree, starting from the leaf node of the dependency master to the root node of the dependency tree, the smart contracts corresponding to each node are published in sequence. Thus, by constructing a dependency tree to publish smart contracts, the smart contracts are automatically and efficiently published by traversing the tree, without the need to manually sort out the publishing order, without worrying about confusion, and improving the accuracy of smart contract publishing. In addition, if there is an update to the smart node or a change in the dependency relationship between the smart nodes, there is no need to rewrite the code. It is only necessary to change the nodes or node order in the dependency tree, reconstruct a new dependency tree, and re-execute the publishing and traversing of the dependency tree, thereby greatly simplifying the publishing process of the smart contract and improving the publishing efficiency.

[0078] In order to ensure that the dependency relationship between smart contracts is effectively established, before traversing the smart contracts to be published and determining the dependency relationship between the smart contracts to be published, the method further includes:

[0079] For any smart contract, perform the following steps:

[0080] Identify the address parameter called by the smart contract; the address parameter is used to indicate the smart contract called by the smart contract;

[0081] The address parameters are standardized to determine the smart contract corresponding to the address parameters.

[0082] Specifically, the construction method of a smart contract contains the address parameter of the smart contract called by the smart contract. For example, a section of the construction method of smart contract A1 is shown in code 1 below:

[0083]

[0084] Among them, CptController is the smart contract name of smart contract A1, cptDataAddress is the address of smart contract A2, and weIdContractAddress is the address of smart contract B1. The construction method of smart contract A1 contains the address parameters of smart contract A2 and the address parameters of smart contract B1, then smart contract A1 calls smart contract A2 and smart contract B1. In the prior art, it is necessary to publish smart contract A2 and smart contract B1 first, determine the addresses of smart contract A2 and smart contract B1, and then publish smart contract A1. In the embodiment of the present invention, it is not necessary to publish smart contract A2 and smart contract B1 first, but to determine from the construction method of smart contract A1 that smart contract A1 calls smart contract A2 and smart contract B1, and standardize the address parameters of smart contract A2 and smart contract B1. There are two situations for standardization here. The address parameters of the standardized smart contract can be directly written in the process of constructing smart contract A1; or, if smart contract A1 is referenced, the address parameters in smart contract A1 are standardized. Here, address parameter standardization can be to directly use the identifier of the smart contract as the address parameter, or to unify the naming format of the addresses of all smart contracts. For example, in the above code, smart contracts A1, A2, and B1 are named A1, A2, and B1 respectively, and the address parameters referenced by smart contract A1 are changed to A2 and B1 respectively, then the above code 1 can be rewritten as the following code 2:

[0085]

[0086]

[0087] Here, the smart contract identifier is referenced as the address parameter. Alternatively, you can set a unified format identifier for each smart contract address. For example, set the address of smart contract A2 to Aeee and the address of smart contract B2 to Beee. Then the above code 1 can be rewritten as the following code 3:

[0088]

[0089] Of course, the address parameters may also be standardized using other methods, which are not limited here.

[0090] After determining the dependencies between smart contracts based on the address parameters called by the smart contract, a dependency tree is established based on the dependencies.

[0091] In a specific construction process, sub-dependency trees can be established for different modules, and then multiple sub-dependency trees can be combined to form the final dependency tree; or the smart contracts in all modules can be traversed directly to directly establish the dependency tree.

[0092] The following example is used to illustrate. For ease of description, the smart contract A1 in the example is represented by A1, and other descriptions are similar. In a specific example, each module is traversed separately, and a sub-dependency tree of each smart contract is established for each module. Figure 1 For the smart contracts in module A, if the following dependencies exist, A1 depends on A2 and A3, and A3 depends on B1, B3, and C2, then nodes are used to represent smart contracts, and arrows are used to represent the dependencies between smart contracts, and we get: Figure 3a For the smart contract in module B, there is the following dependency relationship. B1 depends on B2 and C2, so the following is obtained: Figure 3b For the smart contract in module C, there is the following dependency relationship. C2 depends on C3, so the following is obtained: Figure 3c Finally, Figure 3a to Figure 3c The sub-dependency trees in are combined to form Figure 3d The two dependency trees 301 and 302 are shown. Dependency tree 301 includes a root node and leaf nodes, and dependency tree 302 only includes a root node.

[0093] For the dependency tree obtained above, the embodiment of the present invention directly traverses and publishes the dependency tree. Starting from the leaf nodes of the dependency tree to the root node of the dependency tree, the smart contracts corresponding to each node are published in sequence, including:

[0094] Publishing the smart contract corresponding to the leaf node of the dependency tree;

[0095] Remove the leaf node where the smart contract is successfully published from the dependency tree;

[0096] Repeat the step of publishing the smart contracts corresponding to the leaf nodes of the dependency tree until only the root node exists in the dependency tree;

[0097] The smart contract corresponding to the root node is published.

[0098] To publish Figure 3d For dependency tree 301, the leaf nodes include A2, B2, B3, C2 and C3. Then, first, smart contracts A2, B2, B3, C2 and C3 are published. After the publishing is completed, nodes A2, B2, B3, C2 and C3 in dependency tree 301 are removed, and the following is obtained: Figure 3e The dependency tree structure shown. Figure 3e The dependency tree in , whose leaf node is C2, and since C2 has been released, we can directly remove C2, and get Figure 3f The dependency tree structure shown. Figure 3fThe dependency tree in continues to process, B1 is published, and B1 is removed after the publication is successful. A3 is published again, and A3 is removed after the publication is successful. Finally, the root node A1 is left, and the root node A1 is published.

[0099] In particular, for the dependency tree 302, since it only contains the root node, it is only necessary to publish the smart contract C1 corresponding to the root node.

[0100] Finally, the root node can be saved as the identifier of the dependency tree. Figure 3d The dependency tree in , finally saves the root node A1 and the root node C1.

[0101] In the embodiment of the present invention, each time a smart contract is released, a dependency tree is constructed and the dependency tree is called and released. If the smart contract is updated or added or deleted, there is no need to rewrite the release code of the smart contract. After establishing N dependency trees based on the dependency relationship, it also includes:

[0102] Receive smart contract change requests;

[0103] According to the smart contract change request, the nodes in the dependency tree are updated.

[0104] In the specific implementation process, when smart contracts in the module are added or deleted, or the dependencies between smart contracts change, there is no need to rewrite the release code, only the nodes in the dependency tree need to be changed accordingly. For example, if a smart contract is deleted, the corresponding node in the dependency tree is removed; if a smart contract is added, a node is added to the corresponding position in the dependency tree; if the dependency in the smart contract changes, the arrow position and / or direction in the dependency tree is changed accordingly. After that, the new dependency tree can be executed. This simplifies the release process of smart contracts and improves the release efficiency.

[0105] In order to understand the present invention more clearly, the above process is described in detail with specific embodiments below. Specific embodiment 1 is the publishing process of the smart contract. The steps are as follows: Figure 4 As shown, including:

[0106] Step S401: Obtain the smart contract to be published.

[0107] Step S402: Identify the address parameters of the smart contract call.

[0108] Step S403: Replace the address parameter with the smart contract name corresponding to the address parameter.

[0109] Step S404: Determine the dependencies between all smart contracts to be released.

[0110] Step S405: N dependency trees are established based on the dependency relationship. One node of the dependency tree corresponds to one smart contract.

[0111] Step S406: Publish the smart contract corresponding to the leaf node of the dependency tree.

[0112] Step S407: Remove the leaf node on which the smart contract is successfully published from the dependency tree.

[0113] Step S408: Determine whether there is only a root node in the dependency tree. If so, execute step S409; otherwise, execute step S406.

[0114] Step S409: Publish the smart contract corresponding to the root node and save the root node.

[0115] Specific embodiment 2 is the publishing process after the smart contract is updated. The steps are as follows Figure 5 As shown, including:

[0116] Step S501: Receive a smart contract change request.

[0117] Step S502: According to the smart contract change request, obtain the corresponding dependency tree and update the nodes in the dependency tree.

[0118] Step S503: Publish the smart contract corresponding to the leaf node of the dependency tree.

[0119] Step S504: Remove the leaf node on which the smart contract is successfully published from the dependency tree.

[0120] Step S505: Determine whether there is only a root node in the dependency tree. If so, execute step S506; otherwise, execute step S503.

[0121] Step S506: Publish the smart contract corresponding to the root node and save the root node.

[0122] The embodiment of the present invention also provides a publishing device for a smart contract in a blockchain, such as Figure 6 As shown, including:

[0123] An acquisition unit 601 is used to acquire a smart contract to be published;

[0124] A determination unit 602 is used to traverse the smart contracts to be published and determine the dependencies between the smart contracts to be published;

[0125] An establishing unit 603 is used to establish N dependency trees according to the dependency relationship, where one node of the dependency tree corresponds to one smart contract; N≥1;

[0126] The publishing unit 604 is used to publish the smart contracts corresponding to each node in sequence, starting from the leaf node of the dependency tree to the root node of the dependency tree, for any dependency tree.

[0127] Optionally, the determining unit 602 is further configured to:

[0128] For any smart contract, perform the following steps:

[0129] Identify the address parameter called by the smart contract; the address parameter is used to indicate the smart contract called by the smart contract;

[0130] The address parameters are standardized to determine the smart contract corresponding to the address parameters.

[0131] Optionally, the publishing unit 604 is specifically configured to:

[0132] Publishing the smart contract corresponding to the leaf node of the dependency tree;

[0133] Remove the leaf node where the smart contract is successfully published from the dependency tree;

[0134] Repeat the step of publishing the smart contracts corresponding to the leaf nodes of the dependency tree until only the root node exists in the dependency tree;

[0135] The smart contract corresponding to the root node is published.

[0136] Optionally, the acquisition unit 601 is further used to receive a smart contract change request;

[0137] The establishing unit 603 is also used to update the nodes in the dependency tree according to the smart contract change request.

[0138] Based on the same principle, the present invention also provides an electronic device, such as Figure 7 As shown, including:

[0139] It includes a processor 701, a memory 702, a transceiver 703, and a bus interface 704, wherein the processor 701, the memory 702 and the transceiver 703 are connected via the bus interface 704;

[0140] The processor 701 is configured to read the program in the memory 702 and execute the following method:

[0141] Get the smart contract to be published;

[0142] Traversing the smart contracts to be released, and determining the dependencies between the smart contracts to be released;

[0143] According to the dependency relationship, N dependency trees are established, and one node of the dependency tree corresponds to one smart contract; N≥1;

[0144] For any dependency tree, starting from the leaf node of the dependency tree to the root node of the dependency tree, the smart contracts corresponding to each node are published in sequence.

[0145] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0146] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0147] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0148] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0149] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for publishing a smart contract in a blockchain, characterized in that: include: Get the smart contract to be published; Traversing the smart contracts to be released, and determining the dependencies between the smart contracts to be released; According to the dependency relationship, N dependency trees are established, and one node of the dependency tree corresponds to one smart contract; N≥1; For any dependency tree, starting from the leaf node of the dependency tree to the root node of the dependency tree, the smart contracts corresponding to each node are published in sequence, including: Publishing the smart contract on the leaf node of the dependency tree; Remove the published leaf nodes to obtain the second dependency tree; If there are published nodes in the second dependency tree, remove the published nodes and continue from the leaf nodes of the second dependency tree to the root node of the second dependency tree, and publish the smart contracts corresponding to each node in sequence.

2. The method according to claim 1, characterized in that Before traversing the smart contracts to be published and determining the dependencies between the smart contracts to be published, the method further includes: For any smart contract, perform the following steps: Identify the address parameter called by the smart contract; the address parameter is used to indicate the smart contract called by the smart contract; The address parameters are standardized to determine the smart contract corresponding to the address parameters.

3. The method according to claim 1, characterized in that After establishing N dependency trees according to the dependency relationship, the method further includes: Receive smart contract change requests; According to the smart contract change request, the nodes in the dependency tree are updated.

4. A device for publishing smart contracts in a blockchain, characterized in that: include: An acquisition unit, used to acquire the smart contract to be published; A determination unit, configured to traverse the smart contracts to be published and determine dependencies between the smart contracts to be published; An establishing unit, used to establish N dependency trees according to the dependency relationship, wherein one node of the dependency tree corresponds to one smart contract; N≥1; The publishing unit is used to publish the smart contracts corresponding to each node in sequence, starting from the leaf node of the dependency tree to the root node of the dependency tree, for any dependency tree, including: Publishing the smart contract on the leaf node of the dependency tree; Remove the published leaf nodes to obtain the second dependency tree; If there are published nodes in the second dependency tree, remove the published nodes and continue from the leaf nodes of the second dependency tree to the root node of the second dependency tree, and publish the smart contracts corresponding to each node in sequence.

5. The device according to claim 4, characterized in that The determining unit is further configured to: For any smart contract, perform the following steps: Identify the address parameter called by the smart contract; the address parameter is used to indicate the smart contract called by the smart contract; The address parameters are standardized to determine the smart contract corresponding to the address parameters.

6. The device according to claim 4, characterized in that The acquisition unit is further used to receive a smart contract change request; The establishing unit is also used to update the nodes in the dependency tree according to the smart contract change request.

7. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 3.

8. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute any one of the methods of claims 1 to 3.

Citation Information

Patent Citations

  • Block chain multistage intelligent contract-oriented data migration method

    CN107145521A