A blockchain smart contract generation method, device and storage medium

By analyzing the pending object class to determine the target key-value pair and generating corresponding smart contract codes, the problem of low efficiency in automatic generation of smart contract codes in the existing technology is solved, and the effect of simplifying the process and improving coding efficiency is achieved.

CN112433710BActive Publication Date: 2025-03-25WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011350009.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-26
Publication Date
2025-03-25
Estimated Expiration
2040-11-26

AI Technical Summary

Technical Problem

In the prior art, the efficiency of automatically generating smart contract codes based on SQL-like code is low, resulting in the process of automatically generating smart contract codes that are complex and the encoding efficiency is low.

Method used

By obtaining the pending object class, parsing it to determine the target key-value pair, and generating smart contract code corresponding to the target operation based on the target key-value pair.

Benefits of technology

It effectively simplifies the process of automatically generating smart contract codes, improves coding efficiency, and solves the problem of inefficiency in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112433710B_ABST
    Figure CN112433710B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a blockchain smart contract generation method, the method comprising: obtaining a to-be-processed object class; parsing the to-be-processed object class to determine at least one target key-value pair; wherein the target key-value pair has an association relationship with a class member of the to-be-processed object class; and based on at least one of the target key-value pairs, generating a smart contract code corresponding to a target operation. The embodiment of the present application also discloses a blockchain smart contract generation device and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain smart contract generation method, device and storage medium. Background Art

[0002] With the rapid development of computer technology, more and more technologies are applied in the financial field. Traditional finance is gradually transforming to Fintech. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. Blockchain has been widely used in the field of financial technology because of its decentralization, openness, autonomy and information immutability. In the operation of blockchain, smart contracts are usually used to ensure the operation security of blockchain. Smart contracts are a computer protocol that transmits, verifies or executes contracts in an information-based manner. Because smart contracts have the advantages of higher efficiency, irreversibility, secure transactions and fully automated processes when processing transactions, they have received widespread attention and rapid development in recent years. With the development of blockchain and smart contracts, the current development methods of smart contracts on blockchain are different on different blockchains (Ethereum and EOS), which makes the contracts of the two incompatible. Moreover, when the blockchain supports multiple language types, the programming language is difficult to understand and requires strong logical thinking ability, which increases the difficulty of smart contract development. How to reduce the difficulty of smart contract development is an urgent problem for relevant personnel to solve.

[0003] In order to reduce the difficulty of developing smart contracts, a method is proposed to mark the SQL-like codes of the four types of operations (Create, Retrieve, Update, Delete, CRUD), and generate a code syntax tree based on the markings to automatically generate smart contract code through the code syntax tree. However, in the current method of automatically generating smart contract code, a large amount of mapping between code fields and data table fields, data table condition judgment, return (Getter) and assignment (Setter) repetitive code needs to be written, which makes the process of automatically generating smart contract code more complicated and causes low coding efficiency.

[0004] Application Contents

[0005] In order to solve the above technical problems, the embodiments of the present application hope to provide a blockchain smart contract generation method, device and storage medium, which solves the current problem of low efficiency in automatically generating smart contract code based on SQL-like code, effectively simplifies the process of automatically generating smart contract code, improves coding efficiency, and enriches the implementation scheme of automatically generating smart contract code.

[0006] The technical solution of this application is implemented as follows:

[0007] In a first aspect, a blockchain smart contract generation method is provided, the method comprising:

[0008] Get the object class to be processed;

[0009] Parsing the object class to be processed to determine at least one target key-value pair; wherein the target key-value pair has an association relationship with a class member of the object class to be processed;

[0010] Based on at least one of the target key-value pairs, generate a smart contract code corresponding to the target operation.

[0011] In a second aspect, a blockchain smart contract generation device is provided, the blockchain smart contract generation device comprising: a memory, a processor, and a communication bus; wherein:

[0012] The memory is used to store executable instructions;

[0013] The communication bus is used to realize the communication connection between the processor and the memory;

[0014] The processor is used to execute the blockchain smart contract generation program stored in the memory to implement the steps of the blockchain smart contract generation method as described in any one of the above items.

[0015] In a third aspect, a storage medium is provided, on which a blockchain smart contract generation program is stored, and when the blockchain smart contract generation program is executed by a processor, the steps of the blockchain smart contract generation method as described in any one of the above items are implemented.

[0016] In the embodiment of the present application, the blockchain smart contract generation device obtains the object class to be processed, parses the object class to be processed, determines at least one target key-value pair, and then generates the smart contract code corresponding to the target operation based on the at least one target key-value pair. In this way, by parsing the object class to be processed to obtain at least one target key-value pair to generate the smart contract code corresponding to the target operation, the problem of low efficiency in automatically generating smart contract code based on SQL-like code is solved, the process of automatically generating smart contract code is effectively simplified, and the coding efficiency is improved, which enriches the implementation scheme of automatically generating smart contract code. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A flowchart of a blockchain smart contract generation method provided in an embodiment of the present application;

[0018] Figure 2 A flowchart of another blockchain smart contract generation method provided in an embodiment of the present application;

[0019] Figure 3A flowchart of another blockchain smart contract generation method provided in an embodiment of the present application;

[0020] Figure 4 A flowchart of a method for generating a blockchain smart contract provided in another embodiment of the present application;

[0021] Figure 5 A schematic diagram of an application scenario provided in an embodiment of the present application;

[0022] Figure 6 A schematic diagram of another application scenario provided by an embodiment of the present application;

[0023] Figure 7 A schematic diagram of the structure of a blockchain smart contract generation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0025] The embodiment of the present application provides a blockchain smart contract generation method, referring to Figure 1 As shown, the method is applied to a blockchain smart contract generation device, and the method comprises the following steps:

[0026] Step 101: Obtain the object class to be processed.

[0027] In the embodiment of the present application, the blockchain smart contract generation device is a device that has computing and analysis capabilities and can serve as a blockchain operation node. It can be a physical device such as various forms of servers, desktop computers, laptops, tablets, smart phones, and even car computers, etc., or it can be a virtual device.

[0028] The object class to be processed is a pre-marked object class, which can be obtained by manual marking by a user or by analysis and marking by a blockchain smart contract generation device.

[0029] Step 102: parse the object class to be processed and determine at least one target key-value pair.

[0030] The target key-value pair is associated with a class member of the object class to be processed.

[0031] In an embodiment of the present application, a blockchain smart contract generation device analyzes the object class to be processed, determines the class members in the object class to be processed, and determines to obtain at least one target key-value pair based on the class members in the object class to be processed.

[0032] Step 103: Generate a smart contract code corresponding to the target operation based on at least one target key-value pair.

[0033] In the embodiment of the present application, the target operation can be some common operations in smart contracts, such as add (Create), write (Insert), modify (Update), check (Select or Retrieve), delete (Remove or Delete), etc.; it can also be some operations unique to smart contracts, such as return (Set) operation and assignment (Get) operation. Based on at least one target key-value pair, a smart contract code corresponding to the target operation is generated, that is, at least one target key-value pair corresponding to one form of smart contract code is used to generate another form of smart contract code corresponding to the target operation.

[0034] In the embodiment of the present application, the blockchain smart contract generation device obtains the object class to be processed, parses the object class to be processed, determines at least one target key-value pair, and then generates the smart contract code corresponding to the target operation based on the at least one target key-value pair. In this way, by parsing the object class to be processed to obtain at least one target key-value pair to generate the smart contract code corresponding to the target operation, the problem of low efficiency in automatically generating smart contract code based on SQL-like code is solved, the process of automatically generating smart contract code is effectively simplified, and the coding efficiency is improved, which enriches the implementation scheme of automatically generating smart contract code.

[0035] Based on the above embodiments, the embodiments of the present application provide a method for generating a blockchain smart contract. Figure 2 As shown, the method is applied to a blockchain smart contract generation device, and the method comprises the following steps:

[0036] Step 201: Obtain the class of objects to be processed.

[0037] In the embodiment of the present application, the object class to be processed is pre-marked by the user as an example, and the object class to be processed pre-marked by the user is obtained from a form of smart contract code. The object class to be processed is a complete class (Class) defined in the smart contract code. Exemplarily, the object class to be processed obtained is Class A{Integerid,String aValue,Class B},B{Integer id,String bValue}.

[0038] Step 202: Parse the object class to be processed to obtain the class name of the object class to be processed.

[0039] In the embodiment of the present application, the class name of the object class to be processed is identification information used to identify the object class to be processed. The blockchain smart contract generation device parses Class A{Integer id,String aValue,Class B},B{Integerid,String bValue} to determine that A is the class name of the object class to be processed.

[0040] Step 203: Generate a class name key-value pair based on the class name of the object class to be processed and a preset class identifier.

[0041] Wherein, at least one target key-value pair includes a class name key-value pair.

[0042] In the embodiment of the present application, the class name key-value pair can be expressed in the form of <class name of the object class to be processed, preset class identifier> or <preset class identifier, class name of the object class to be processed>. The preset class identifier refers to a symbol used to represent a class, which can usually be expressed as Class, class or CLASS. Taking the preset class identifier as class as an example, the class name A of the object class to be processed and the preset class identifier class generate a class name key-value pair.<class,A> .

[0043] Step 204: parse the object class to be processed to obtain at least one class member included in the object class to be processed.

[0044] In the embodiment of the present application, in the actual application of the object class to be processed, the object class to be processed includes at least one class member. Exemplarily, the object class to be processed Class A{Integer id, String aValue, Class B}, B{Integer id, String bValue} is parsed to obtain all the class members included in the object class to be processed, which are Integerid, String aValue and Class B.

[0045] Step 205: Determine the data type and target member name of at least one class member.

[0046] In the embodiment of the present application, a class member is usually composed of a data type and a target member name, except for a subclass of a nested type. In this way, the data type of the subclass of the nested type can be preset, and the preset data type can be determined according to the characteristics of the smart contract to be generated. For example, for the class member Integer id, the data type can be determined to be Integer and the target member name can be id.

[0047] Step 206: Based on the data type and target member name of at least one class member, obtain a class member key-value pair of at least one class member.

[0048] Among them, at least one target key-value pair includes a class member key-value pair of at least one class member.

[0049] In an embodiment of the present application, the data type and target member name of each class member in the data type and target member name of at least one class member are processed to obtain a corresponding class member key-value pair. Exemplarily, assuming that there are two class members, Integerid and String aValue, the data types and target members of the two class members are: the data type Integer and target member name id of the class member Integer id, the data type String and target member name aValue of the class member String aValue, so that, correspondingly, the corresponding key-value pairs are generated according to the data type and target member name of each class member, and the class member key-value pairs of the corresponding two class members can be obtained:<Integer,id> and<String,aValue> .

[0050] Step 207: Determine the processing order when generating smart contract code for at least one target key-value pair.

[0051] In the embodiment of the present application, the processing order can be determined according to the order in which each target key-value pair is obtained. For example, for a class name key-value pair and a class member key-value pair of two class members:<Integer,id> and<String,aValue> When , the processing order that can be obtained is class name key value pair,<Integer,id> and<String,aValue> .in,<Integer,id> and<String,aValue> The order is determined according to the order of the corresponding class members in the object class to be processed.

[0052] Step 208: Determine the target operation.

[0053] In the embodiment of the present application, the target operation may be one or more of the operations such as Insert, Update, Select, Remove, Set and Get. The operations included in the target operation may be determined according to actual conditions. For example, the target operation is a Create operation.

[0054] Step 209: Process at least one target key-value pair in a processing order to generate a smart contract code corresponding to the target operation.

[0055] In the embodiment of the present application, the processing order is class name key value pair,<Integer,id> and<String,aValue> , first of all<class,A> After processing, the temporary code of the table smart contract corresponding to the target operation Create is obtained as "createTable("A");", and then<Integer,id> After processing, the temporary smart contract code corresponding to the target operation Create is obtained as "createTable("A", "id");", and finally,<String,aValue> After processing, the temporary smart contract code corresponding to the target operation Create is obtained as "createTable("A", "id", "aValue");".

[0056] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.

[0057] In the embodiment of the present application, the blockchain smart contract generation device obtains the object class to be processed, parses the object class to be processed, determines at least one target key-value pair, and generates the smart contract code corresponding to the target operation based on the at least one target key-value pair. In this way, by parsing the object class to be processed to obtain at least one target key-value pair to generate the smart contract code corresponding to the target operation, the problem of low efficiency in automatically generating smart contract code based on SQL-like code is solved, the process of automatically generating smart contract code is effectively simplified, and the coding efficiency is improved, and the implementation scheme of automatically generating smart contract code is enriched. In addition, the data types included in the target key-value pair are not limited, which effectively increases the application scenarios of the implementation scheme of automatically generating smart contract code, reduces the difficulty of developers who are not familiar with smart contracts or blockchains to manage blockchain data when developing blockchain applications, and effectively improves the user experience.

[0058] Based on the above embodiments, the embodiments of the present application provide a method for generating a blockchain smart contract. Figure 3 As shown, the method is applied to a blockchain smart contract generation device, and the method comprises the following steps:

[0059] Step 301: Obtain the class of objects to be processed.

[0060] Step 302: Parse the object class to be processed to obtain the class name of the object class to be processed.

[0061] Step 303: Generate a class name key-value pair based on the class name of the object class to be processed and a preset class identifier.

[0062] Wherein, at least one target key-value pair includes a class name key-value pair.

[0063] Step 304: parse the object class to be processed to obtain at least one class member included in the object class to be processed.

[0064] Step 305: Determine the class members of at least one class member that belong to the subclasses nested within the to-be-processed object class, and obtain the first target class member.

[0065] In the embodiment of the present application, the first target class member is a subclass of the object class to be processed. For example, when the object class to be processed Class A{Integer id,String aValue,Class B},B{Integer id,StringbValue} is parsed, all class members of the object class to be processed are obtained: Integer id, String aValue and Class B. It can be determined that Class B is a subclass of the object class to be processed, and the corresponding first target class member is Class B.

[0066] Step 306: Determine that the data type of the first target class member is a preset data type.

[0067] The preset data type is used to indicate the data type of the subclass.

[0068] In the embodiment of the present application, when the generated smart contract code is a Table smart contract, since the generated code is based on the Table contract, according to the characteristics of the Table, the allowed field types to be passed in are integer, string, and object, and when the field type is integer, the final generated contract code will be saved as a string type. Therefore, the preset data type of the first target class member can be determined as a string type, and the corresponding type is recorded as a string type.

[0069] Step 307: Obtain the data type of the second target class member from the object class to be processed.

[0070] The second target class members are class members in the object class to be processed except the first target class members.

[0071] In other embodiments of the present application, the second target class member is a common class member except for the subclasses nested in the object class to be processed. Exemplarily, when all class members included in the object class to be processed are obtained: Integer id, String aValue and Class B, the second target class member includes Integer id and String aValue. From the object class to be processed Class A{Integer id,String aValue,Class B},B{Integer id,String bValue}, it can be determined that the data type of the second target class member Integer id is integer Integer, and the data type of the second target class member String bValue is character String.

[0072] Step 308: Obtain a reference member name of at least one class member from the object class to be processed.

[0073] In the embodiment of the present application, the reference member name of at least one class member is the naming content of each class member in the object class to be processed. For example, in the object class to be processed Class A{Integer id,String aValue,ClassB},B{Integer id,String bValue}, the reference names of the three class members are id, aValue and B respectively.

[0074] Step 309: Based on the reference member name of at least one class member, obtain the target member name of at least one class member.

[0075] In an embodiment of the present application, the reference member name of at least one class member is processed to obtain the target member name of at least one class member. Exemplarily, the letters in the reference member name of at least one class member may be case-converted, such as converting uppercase letters to lowercase letters, or converting lowercase letters to uppercase letters, etc. Taking the conversion of uppercase letters to lowercase letters as an example, the target member names of at least one class member are obtained as a, id, avalue, and b.

[0076] Step 310: Based on the data type and target member name of at least one class member, obtain a class member key-value pair of at least one class member.

[0077] Among them, at least one target key-value pair includes a class member key-value pair of at least one class member.

[0078] In the embodiment of the present application, the class member key-value pair of at least one class member obtained includes:<class,a> ,<integer,id> ,<string,avalue> and<class,b> .

[0079] Step 311: Obtain a first reference class member marked as a target identity from the class of objects to be processed.

[0080] The first class member belongs to an external class of the object class to be processed, and the first reference class member belongs to at least one class member.

[0081] In the embodiment of the present application, the first reference class member of the target identity is an object existing in the object to be processed, which is used to indicate the specific object corresponding to the operation. Exemplarily, the target identity can be represented by a symbol ID or id, so that from the object class to be processed Class A{Integer id,String aValue,Class B},B{Integer id,String bValue}, it can be determined that the class member corresponding to the target identity ID or id is the Integerid corresponding to Class A and the Integer id corresponding to Class B, but Class B belongs to the nested subclass of Class A, so there is no need to consider the Integer id corresponding to Class B, so the first reference class member can be determined to be the Integer id corresponding to Class A.

[0082] Step 312: determine the order of the second reference class members except the first reference class members in the to-be-processed object class, and obtain the sorting order of the second reference class members.

[0083] Wherein, the second reference class member belongs to at least one class member.

[0084] In an embodiment of the present application, in the object class to be processed Class A{Integer id,String aValue,ClassB},B{Integer id,String bValue}, in addition to the first reference class member Integer id corresponding to Class A, it also includes class members String aValue and Class B, that is, the second reference class member String aValue and the second reference class member Class B, and determines that the order of the second reference class member String aValue in the second reference class members other than the first reference class members in the object class to be processed is 1, and the order of the second reference class member Class B is 2.

[0085] Step 313: determine that the class name of the object class to be processed is ranked first, the first reference class member is ranked second, and the ranking order of the second reference class member plus 2 is the processing order.

[0086] In the embodiment of the present application, illustratively, the processing order obtained is A, id, aValue and B.

[0087] Step 314: Determine the target operation.

[0088] In the embodiment of the present application, the target operation is an add operation creat operation as an example for description.

[0089] Step 315: Process at least one target key-value pair in a processing order to generate a smart contract code corresponding to the target operation.

[0090] In the embodiment of the present application, the class member key-value pair for at least one class member includes:<class,a> ,<integer,id> ,<string,avalue> and<class,b> Process them in sequence. First,<class,a> Processing is performed to generate a temporary smart contract code "createTable("a");" corresponding to the target operation creat, where a is the name of the generated Table table; second,<integer,id> Processing is performed to generate the temporary smart contract code "createTable("table_name", "id");" corresponding to the target operation creat; third,<string,avalue> Processing is performed to generate the temporary smart contract code "createTable("table_name", "id", "avalue");" corresponding to the target operation creat; finally,<class,b> After processing, the smart contract code corresponding to the target operation creat is generated, which is "createTable("table_name", "id", "avalue", "b");". That is, the smart contract code finally generated is "createTable("table_name", "id", "avalue", "b");".

[0091] Based on the above embodiment, in other embodiments of the present application, step 303 can be implemented by steps a11 to a14:

[0092] Step a11: Obtain the reference class name of the object class to be processed.

[0093] In the embodiment of the present application, the reference class name of the object class to be processed is the definition class name of the object class to be processed defined in the object class to be processed. For example, in the object class to be processed Class A{Integer id,String aValue,ClassB},B{Integer id,String bValue}, the reference class name of the object class to be processed is A.

[0094] After the smart contract device executes step a11, it selects to execute step a12, step a13, or step a14 according to the characteristics of the letters included in the reference class name of the object class to be processed. When the reference class name of the object class to be processed is camel case, step a12 is selected to execute; when the letters included in the reference class name of the object class to be processed are all uppercase letters, step a13 is selected to execute; when the letters included in the reference class name of the object class to be processed are all lowercase letters, step a14 is selected to execute.

[0095] Step a12: If the reference class name of the object class to be processed is camel case, add a target connector before the first type of letters included in the reference class name of the object class to be processed, and replace the first type of letters included in the class name of the object class to be processed with corresponding second type letters to obtain the class name of the object class to be processed.

[0096] Among them, the first type of letters are different from the second type of letters.

[0097] In the embodiment of the present application, if the first type of letters are uppercase letters, the corresponding second type of letters are lowercase letters, and if the first type of letters are lowercase letters, the corresponding second type of letters are uppercase letters. Assuming that the object class to be processed is Class AppTable{Integer id,String aValue,Class B},B{Integer id,String bValue}, the target connector is "_", the first type of letters are uppercase letters and the second type of letters are lowercase letters. The reference class name of the corresponding object class to be processed is AppTable, which belongs to the camel case naming method, and the class name of the object class to be processed is app_table.

[0098] Step a13: If the letters included in the reference class name of the object class to be processed are all first type letters, replace the letters included in the second reference member name with corresponding second type letters to obtain the class name of the object class to be processed.

[0099] In the embodiment of the present application, in the object class to be processed Class A{Integer id, String aValue, ClassB}, B{Integer id, String bValue}, the reference class name of the object class to be processed is A, and all the letters included are uppercase letters. Therefore, the class name of the object class to be processed is a.

[0100] Step a14: If the letters included in the reference class name of the object class to be processed are all second-type letters, the reference class name of the object class to be processed is used as the class name of the object class to be processed.

[0101] In the embodiment of the present application, in the object class to be processed Class a{Integer id,String aValue,ClassB},B{Integer id,String bValue}, the reference class name of the object class to be processed is a, and all the letters included are lowercase letters. Therefore, the class name of the object class to be processed is the reference class name a of the object class to be processed, and no conversion processing is required.

[0102] Correspondingly, step 309 can be implemented by steps b11 to b14:

[0103] Step b11, group the reference member names of at least one class member to obtain a first reference member name named in camel case, a second reference member name named in first type letters, and a third reference member name named in second type letters.

[0104] In the embodiment of the present application, the first type of letters are uppercase letters and the second type of letters are lowercase letters. Camel-Case, also known as camel-case naming, is a set of naming rules or naming conventions when writing computer programs. As its name CamelCase indicates, it refers to the use of mixed uppercase and lowercase letters to form the names of variables and functions. In order to make it easier for programmers to communicate their codes among peers, they often adopt a unified naming method with better readability. Exemplarily, by grouping the reference member names id, aValue and B of at least one class member, you can get a first reference member name aValue named in camel-case naming, get a second reference member name B named in the first type of letters, and get a third reference member name id named in the second type of letters.

[0105] Step b12: based on the first reference member name, add a target connector before the first type of letters included in the first reference member name, and replace the first type of letters included in the first reference member name with corresponding second type letters to obtain a first intermediate member name corresponding to the first reference member name.

[0106] In the embodiment of the present application, the target connector may be a connector symbol such as an underscore connector “_” or a connector “-”. For example, for the first reference member name aValue, the first intermediate member name a_value is obtained.

[0107] Step b13: Based on the second reference member name, replace the letters included in the second reference member name with corresponding second type letters to obtain a second intermediate member name corresponding to the second reference member name.

[0108] In the embodiment of the present application, illustratively, the second intermediate member name obtained by referring to the second member name B is b.

[0109] Step b14: Based on the first intermediate member name, the second intermediate member name and the third reference member name, obtain the target member name of the first target class member and the target member name of the second target class member.

[0110] The target member name of at least one class member includes a target member name of a first target class member and a target member name of a second target class member.

[0111] In the embodiment of the present application, because the third reference member name is already the agreed second type of letters, there is no need to convert the third reference member name. Since the first target class member is Class B, and the second target class member is Integer id and String aValue, the first intermediate member name, the second intermediate member name, and the third reference member name id, a_value, and b are grouped to obtain the target member name of the first target class member name as b, and the target member name of the second target class member name as id and a_value.

[0112] Based on the above embodiments, in other embodiments of the present application, step b14 can be implemented by steps b141 to b143:

[0113] Step b141, determine the member name corresponding to the first target class member from the first intermediate member name, the second intermediate member name and the third reference member name, and obtain the third intermediate member name of the first target class member.

[0114] In the embodiment of the present application, the third intermediate member name of the first target class member is determined to be b from the first intermediate member name, the second intermediate member name and the third reference member name id, a_value and b.

[0115] Step b142: Use the subclass identifier to identify the third intermediate member name to obtain the target member name of the first target class member.

[0116] In the embodiment of the present application, in order to distinguish the first target class member, i.e., the nested subclass, from the parent class, it is necessary to identify and distinguish the first target class member. Therefore, a subclass identifier for identifying a nested subclass can be used to achieve the distinction. The subclass identifier can be a pre-agreed symbol for identifying a nested subclass, or a character. For example, "join_" can be used as the subclass identifier, and correspondingly, the target member name of the first target class member is join_b. In this way, when the blockchain smart contract generation device recognizes the join_ character, it can determine that the corresponding class member is a nested subclass.

[0117] Step b143: determine the member name corresponding to the second target class member from the first intermediate member name, the second intermediate member name and the third reference member name, and obtain the target member name of the second target class member.

[0118] In other embodiments of the present application, since the second-category target class members are not special class members, no processing is required, and the class member name after the letter conversion processing can be directly determined as the corresponding target member name.

[0119] Correspondingly, step 315 can be implemented by steps c11 to c13:

[0120] Step c11: If at least one target key value includes a target member name with a subclass identifier, remove the subclass identifier of the target member name to obtain the target subclass name included in the target member name.

[0121] In an embodiment of the present application, if at least one target key value includes a target member name with a subclass identifier, each key-value pair of at least one target key-value pair is directly processed in the processing order to generate a generated code corresponding to the target operation.<class,a> ,<integer,id> ,<string,avalue> and<class,join_b> ,in,<class,join_b> The join_b in the example has the subclass identifier join_, so by removing join_, we can get the target subclass name b included in join_b.

[0122] Step c12: Based on the target subclass name, generate a detection code for detecting whether the blockchain data table corresponding to the target subclass name exists.

[0123] In the embodiment of the present application, in order to ensure that the table corresponding to the nested subclass has a mapped data table in the blockchain, it is necessary to generate a detection code, otherwise, the generated smart contract code implementation is meaningless.

[0124] Step c13: Generate a generated code corresponding to the target operation by processing each key-value pair of at least one target key-value pair in a processing order if the blockchain data table corresponding to the target subclass name exists.

[0125] Among them, the smart contract code includes detection code and generation code.

[0126] Based on the above embodiment, in other embodiments of the present application, step c12 can be implemented by steps c121 to c123:

[0127] Step c121: Generate a first code for obtaining a blockchain data table corresponding to the target subclass name.

[0128] In the embodiment of the present application, illustratively, the first code may be recorded as "Table tableB=openTable("b");".

[0129] Step c122: Generate a second code for determining whether a blockchain data table corresponding to the target subclass name is obtained.

[0130] Step c123: Generate a third code for generating a prompt message if the blockchain data table corresponding to the target subclass name is not obtained.

[0131] Among them, the prompt information is used to prompt that an error occurs in obtaining the blockchain data table corresponding to the target subclass name, and the detection code includes the first code, the second code and the third code.

[0132] Based on the above embodiments, the present application provides a method for generating a blockchain smart contract. Figure 4 As shown, including:

[0133] Step 41: Scan the marked object class to obtain the key-value pair.

[0134] Step 42: Insert the key-value pairs into a first-in-first-out (FIFO) cache queue in the scanning order.

[0135] When scanning a marked object class, the class name of the object class is scanned first, and then the class members in the object class, that is, each field, are scanned.

[0136] First, after scanning and obtaining the class name of the object class, put it into the FIFO cache queue as a class name key-value pair. For example, if the class name of user A is A, the corresponding data table name is mapped to a pure lowercase "a" table, with a class name key-value pair.<class,a> Put it into the cache queue; secondly, scan the field type and field name contained in the object class, that is, the aforementioned data type and target member name. Since the generated code is based on the Table contract, according to the characteristics of the Table, the incoming field type only supports integer, string, and object types. When the field type is integer, the final generated contract code will be saved as a string type. The object class contains at least one field marked as Id, which can be recorded as a field named id. The field marked as ID can be passed into the cache queue as the primary key value of the table. For example, the field marked as ID in the A object class is the integer field id. In this way, the key-value pair<int,id> Put it into the cache queue.

[0137] For example, when class A is class A{Integer id,String aValue,Class B},B{Integer id,String bValue}, it can be determined that the A object contains a primary key integer field id marked as Id, a string field aValue, and a nested subclass B object class, wherein the nested subclass B object class contains the primary key integer field id and string type aValue of the nested subclass B object.

[0138] The following example illustrates the process of scanning class A as class A{Integer id,String aValue,Class B},B{Integer id,String bValue}. The main process is as follows Figure 5 As shown, including:

[0139] Step 51, scanning object class;

[0140] Step 52, get the class name key-value pair;

[0141] Step 53: Store the class name key-value pair into the FIFO cache queue;

[0142] Step 54: Get the field key-value pair;

[0143] Step 55: Store the field key-value pairs in the FIFO cache queue in sequence according to the scanning order.

[0144] The field key-value pair corresponds to the class member key-value pair of the aforementioned at least one class member.

[0145] When executing step 51 to scan the class name of the object class, the capital letters in the class name are changed to lowercase letters. When the class name is A, the corresponding class name key-value pair is E1.<class,a> If the class name is AppTable, then the uppercase and lowercase letters in the class name are changed to the corresponding lowercase letters, and an underscore "_" is added before the subsequent uppercase letters to connect them, that is, AppTable is obtained.<class,app_table> After scanning the class name of class A, the E1 key-value pair of class A is inserted into the FIFO cache queue to obtain queue [E1].

[0146] After scanning the class name, scan each field in the object class, scan to obtain the key-value pairs of each field, record the total number of fields, and complete the scan when the queue length is the total number + 1. For a specific field key-value pair, check whether the field type is integer or string. For example, scan class A and determine that class A has 3 fields: Integer id, String aValue, and Class B; among them, scan field id and obtain integer field key-value pair E2<int,id> , insert it into the cache queue to get [E1, E2], scan the string field aValue of class A, convert the camel case format "aValue" to underline mode, that is, add an underscore "_" before the uppercase letters, and convert the uppercase letters to lowercase to get "a_value", and finally get the key-value pair E3<string,a_value> Insert into the queue to get [E1,E2,E3].

[0147] Continuing the scan, we can obtain the nested sub-object class B field. The type of B is not integer or string, but object class. At this time, the scan of sub-object class B only scans the class name, and does not scan the fields in the sub-class. Scan the class name of class B. The class name key-value pair E4 of class B is obtained as<class,b> , the class name key-value pair is not the first key-value pair, so it is a nested subclass key-value pair, and its value is "b", so it is converted to a string type field key-value pair, and the value is converted from the subclass name "b" to "join_b", resulting in E4<string,join_b> , insert E4 into the cache queue to get [E1, E2, E3, E4]. At this time, the queue length is 4, which is equal to the total number of class A fields 3 plus 1 (class A class name key-value pair), and the scan is completed. Start to take out the key-value pairs from the queue to generate code based on the Table contract.

[0148] Step 43: Take the key-value pair from the cache queue and generate a Table contract.

[0149] Among them, from the cache queue obtained after the scan is completed, the key-value pairs are taken out from the queue one by one in the FIFO first-in-first-out order. The process of taking out the key-value pairs can be referred to Figure 6 As shown, including:

[0150] Step 61, taking out the key-value pair from the FIFO cache queue;

[0151] Step 62: Determine whether the key-value pair retrieved is a class name key-value pair. If so, execute step 63; if not, execute step 64.

[0152] Step 63, generate the CreateTable table name code;

[0153] Step 64: Determine that the key-value pair is a field key-value pair;

[0154] Step 65, determine whether the field key-value pair is marked with id, if it is marked with id, execute step 66, if it is not marked with id, execute step 67;

[0155] Step 66, generate the CreatTable primary key id code;

[0156] Step 67: Determine that the field key-value pair is a non-primary key field key-value pair;

[0157] Step 68, determine whether the non-primary key field key-value pair begins with join_, if so, execute step 69, if not, execute step 610;

[0158] Step 69, remove the leading "join_" in the key-value pairs of non-primary key fields and generate the CreateTable column name code;

[0159] Step 610: directly generate the CreateTable column name code.

[0160] In step 62, when determining whether the retrieved key-value pair is a class name key-value pair, it can be achieved by determining whether the key of the key-value pair includes class. If it includes class, it is determined to be a class name key-value pair, and its value corresponds to the class name. Usually, the first and only class name key-value pair is the class name of the object class; the key in the class name key-value pair is usually of int or string type, and its value is the field name, and the code will be generated.

[0161] After executing steps 61 to 610, the general format of the generated smart contract code can be recorded as: "createTable("table_name", "id", "column1, column2, column3");", where the first parameter is the table name, the second parameter is the primary key value of the table, and the third parameter is the column names of the remaining columns. When there are multiple columns, they are separated by commas.

[0162] For example, the key of the key-value pair first taken out from the FIFO cache queue should be class, that is, the first class name key-value pair. According to the scanning result of class A above, the E1 key-value pair can be obtained as<class,a> , the key is "class" and the value is "a", so the key-value pair is the class name key-value pair. After passing it in, the temporary code for the first part can be generated as: "createTable("a");"

[0163] Continue to take out the key-value pairs from the FIFO cache queue in the cache order, and you can get the E2 key-value pair<int,id> , its key is int, so it is a field key-value pair, and the judgment field name is id, so this key-value pair is the primary key. Convert the id type to string and get<string,id> , after passing in, the second part of the code can be generated: "createTable("a", "id");"

[0164] Continue to take the next key-value pair from the FIFO cache queue in the cache order, and get E3<string,a_value> , its key is string, so it is a field key-value pair, and the field name is not id, so it is converted to a column name. If the field name is still id, an error of duplicate field name will be thrown. Passing it as a column name can generate the third part of the code: "createTable("a", "id", "a_value");"

[0165] Continue to read the next key-value pair from the FIFO cache queue in the cache order and get E4<string,join_b> , whose value is "join_b" and starts with "join_", indicating that the key-value pair is the result of the transformation of the class name key-value pair of the nested sub-object class. After removing "join_", the sub-class table name is "b". The nested sub-class needs to ensure that the sub-class table has a mapped data table in the blockchain. Therefore, an additional check is generated here to check whether the blockchain data table corresponding to the sub-class exists: according to the class name "b" of the sub-class, a temporary code "Table tableB = openTable("b"); assert tableB! = null;" is generated to obtain the table b on the chain and determine whether the return of b is empty. If it is empty, an error is thrown. At this point, the final generated smart contract code can be recorded as "TabletableB = openTable("b"); assert tableB! = null; createTable("a", "id", "a_value, join_b");".

[0166] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.

[0167] In the embodiment of the present application, the blockchain smart contract generation device obtains the object class to be processed, parses the object class to be processed, determines at least one target key-value pair, and generates the smart contract code corresponding to the target operation based on the at least one target key-value pair. In this way, by parsing the object class to be processed to obtain at least one target key-value pair to generate the smart contract code corresponding to the target operation, the problem of low efficiency in automatically generating smart contract code based on SQL-like code is solved, the process of automatically generating smart contract code is effectively simplified, and the coding efficiency is improved, and the implementation scheme of automatically generating smart contract code is enriched. In addition, the data types included in the target key-value pair are not limited, which effectively increases the application scenarios of the implementation scheme of automatically generating smart contract code, reduces the difficulty of developers who are not familiar with smart contracts or blockchains to manage blockchain data when developing blockchain applications, and effectively improves the user experience.

[0168] Based on the above embodiments, the embodiments of the present application provide a blockchain smart contract generation device, referring to Figure 7 As shown, the blockchain smart contract generation device 7 may include: a processor 71, a memory 72 and a communication bus 73, wherein:

[0169] A memory 72, for storing executable instructions;

[0170] A communication bus 73, used to realize the communication connection between the processor 71 and the memory 72;

[0171] The processor 71 is used to execute the blockchain smart contract generation program stored in the memory 72 to implement the following steps:

[0172] Get the object class to be processed;

[0173] Parsing the object class to be processed to determine at least one target key-value pair; wherein the target key-value pair has an association relationship with a class member of the object class to be processed;

[0174] Based on at least one target key-value pair, generate smart contract code corresponding to the target operation.

[0175] In other embodiments of the present application, when the processor executes the step of parsing the object class to be processed and determining at least one target key-value pair, it can be implemented by the following steps:

[0176] Parse the object class to be processed to obtain the class name of the object class to be processed;

[0177] Generate a class name key-value pair based on the class name of the object class to be processed and a preset class identifier; wherein at least one target key-value pair includes the class name key-value pair;

[0178] Parsing the object class to be processed to obtain at least one class member included in the object class to be processed;

[0179] Determine the data type and target member name of at least one class member;

[0180] Based on the data type and target member name of at least one class member, a class member key-value pair of at least one class member is obtained; wherein at least one target key-value pair includes the class member key-value pair of at least one class member.

[0181] In other embodiments of the present application, when the processor executes the step of determining the data type and target member name of at least one class member, it can be implemented by the following steps:

[0182] Determine a class member of at least one class member that belongs to a subclass included in the nested object class to be processed, and obtain a first target class member;

[0183] Determine that the data type of the first target class member is a preset data type; wherein the preset data type is used to indicate the data type of the subclass;

[0184] Obtaining data types of second target class members from the object class to be processed; wherein the second target class members are class members in the object class to be processed except the first target class members;

[0185] Obtain a reference member name of at least one class member from the object class to be processed;

[0186] Based on the reference member name of at least one class member, a target member name of at least one class member is obtained.

[0187] In other embodiments of the present application, when the processor executes the step of generating a class name key-value pair based on the class name of the object class to be processed and the preset class identifier, it can be implemented by the following steps:

[0188] Get the reference class name of the object class to be processed;

[0189] If the reference class name of the object class to be processed is camel case named, add a target connector before the first type of letters included in the reference class name of the object class to be processed, and replace the first type of letters included in the class name of the object class to be processed with corresponding second type of letters to obtain the class name of the object class to be processed; wherein the first type of letters are different from the second type of letters;

[0190] If the letters included in the reference class name of the object class to be processed are all letters of the first type, the letters included in the second reference member name are replaced with corresponding letters of the second type to obtain the class name of the object class to be processed;

[0191] If the reference class name of the to-be-processed object class includes letters of the second type, the reference class name of the to-be-processed object class is used as the class name of the to-be-processed object class.

[0192] In other embodiments of the present application, when the processor executes the step of obtaining the target member name of at least one class member based on the reference member name of at least one class member, it can be implemented by the following steps:

[0193] Grouping the reference member names of at least one class member to obtain a first reference member name named in camel case, a second reference member name named in first type letters, and a third reference member name named in second type letters;

[0194] Based on the first reference member name, a target connector is added before the first type of letters included in the first reference member name, and the first type of letters included in the first reference member name are replaced with corresponding second type letters to obtain a first intermediate member name corresponding to the first reference member name;

[0195] Based on the second reference member name, replacing the letters included in the second reference member name with corresponding second type letters to obtain a second intermediate member name corresponding to the second reference member name;

[0196] Based on the first intermediate member name, the second intermediate member name and the third reference member name, the target member name of the first target class member and the target member name of the second target class member are obtained; wherein, the target member name of at least one class member includes the target member name of the first target class member and the target member name of the second target class member.

[0197] In other embodiments of the present application, when the processor executes the step of obtaining the target member name of the first target class member and the target member name of the second target class member based on the first intermediate member name, the second intermediate member name and the third reference member name, it can be implemented by the following steps:

[0198] Determine the member name corresponding to the first target class member from the first intermediate member name, the second intermediate member name, and the third reference member name, and obtain the third intermediate member name of the first target class member;

[0199] The third intermediate member name is identified by using the subclass identifier to obtain the target member name of the first target class member;

[0200] The member name corresponding to the second target class member is determined from the first intermediate member name, the second intermediate member name and the third reference member name, and the target member name of the second target class member is obtained.

[0201] In other embodiments of the present application, when the processor executes the step of generating a smart contract code corresponding to a target operation based on at least one target key-value pair, it can be implemented by the following steps:

[0202] Determine a processing order when generating smart contract code for at least one target key-value pair;

[0203] Identify target operations;

[0204] Process at least one target key-value pair in a processing order to generate a smart contract code corresponding to the target operation.

[0205] In other embodiments of the present application, when the processor executes the step of determining the processing order when generating smart contract code for at least one target key-value pair, it can be implemented by the following steps:

[0206] Obtaining a first reference class member marked as a target identity from the class of the object to be processed; wherein the first class member belongs to an external class of the class of the object to be processed, and the first reference class member belongs to at least one class member;

[0207] Determine the order of the second reference class members except the first reference class members in the to-be-processed object class, and obtain the sorting order of the second reference class members; wherein the second reference class members belong to at least one class member;

[0208] Determine that the class name of the object class to be processed is ranked first, the first reference class member is ranked second, and the ranking order of the second reference class member plus 2 is the processing order.

[0209] In other embodiments of the present application, the processor executes the step of processing each key-value pair of at least one target key-value pair in the processing order to generate a smart contract code corresponding to the target operation, which can be achieved by the following steps:

[0210] If at least one target key value includes a target member name with a subclass identifier, remove the subclass identifier of the target member name to obtain the target subclass name included in the target member name;

[0211] Based on the target subclass name, generate a detection code for detecting whether the blockchain data table corresponding to the target subclass name exists;

[0212] Generate a generated code corresponding to the target operation by processing each key-value pair of at least one target key-value pair in a processing order if a blockchain data table corresponding to the target subclass name exists; wherein the smart contract code includes a detection code and a generation code.

[0213] In other embodiments of the present application, when the processor executes the step of generating a detection code for detecting whether a blockchain data table corresponding to the target subclass name exists based on the target subclass name, it can be implemented by the following steps:

[0214] Generate a first code for obtaining a blockchain data table corresponding to a target subclass name;

[0215] Generate a second code for determining whether a blockchain data table corresponding to the target subclass name is obtained;

[0216] A third code is generated for realizing generating a prompt message if the blockchain data table corresponding to the target subclass name is not obtained; wherein the prompt message is used to prompt that an error occurs in obtaining the blockchain data table corresponding to the target subclass name, and the detection code includes a first code, a second code, and a third code.

[0217] It should be noted that the specific implementation process of information interaction between the units and modules in the blockchain smart contract generation device in this embodiment can be referred to Figures 1 to 3 The implementation process of the blockchain smart contract generation method provided in the corresponding embodiment will not be repeated here.

[0218] In the embodiment of the present application, the blockchain smart contract generation device obtains the object class to be processed, parses the object class to be processed, determines at least one target key-value pair, and generates the smart contract code corresponding to the target operation based on the at least one target key-value pair. In this way, by parsing the object class to be processed to obtain at least one target key-value pair to generate the smart contract code corresponding to the target operation, the problem of low efficiency in automatically generating smart contract code based on SQL-like code is solved, the process of automatically generating smart contract code is effectively simplified, and the coding efficiency is improved, and the implementation scheme of automatically generating smart contract code is enriched. In addition, the data types included in the target key-value pair are not limited, which effectively increases the application scenarios of the implementation scheme of automatically generating smart contract code, reduces the difficulty of developers who are not familiar with smart contracts or blockchains to manage blockchain data when developing blockchain applications, and effectively improves the user experience.

[0219] Based on the foregoing embodiments, the embodiments of the present application provide a computer-readable storage medium, referred to as a storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the following. Figures 1 to 3 The implementation process of the blockchain smart contract generation method provided by the corresponding embodiment will not be repeated here.

[0220] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0221] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 generate 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.

[0222] 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.

[0223] 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.

[0224] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.

Claims

1. A blockchain smart contract generation method, characterized in that: The method comprises: Get the object class to be processed; Parsing the object class to be processed to determine at least one target key-value pair; wherein the target key-value pair has an association relationship with a class member of the object class to be processed, wherein the parsing the object class to be processed to determine at least one target key-value pair includes: parsing the object class to be processed to obtain a class name of the object class to be processed; generating a class name key-value pair based on the class name of the object class to be processed and a preset class identifier; wherein the at least one target key-value pair includes the class name key-value pair; parsing the object class to be processed to obtain at least one class member included in the object class to be processed; Determine the data type and target member name of at least one of the class members; wherein, the determination of the data type and target member name of at least one of the class members includes: determining the class members of the at least one class member that belong to the subclass nested and included in the object class to be processed, and obtaining a first target class member; determining that the data type of the first target class member is a preset data type; wherein, the preset data type is used to indicate the data type of the subclass; obtaining the data type of a second target class member from the object class to be processed; wherein, the second target class member is a class member in the object class to be processed other than the first target class member; obtaining a reference member name of at least one of the class members from the object class to be processed; and obtaining a target member name of at least one of the class members based on the reference member name of at least one of the class members; Based on the data type and the target member name of at least one of the class members, obtain a class member key-value pair of at least one of the class members; wherein the at least one target key-value pair includes a class member key-value pair of at least one of the class members; Based on at least one of the target key-value pairs, generate a smart contract code corresponding to the target operation.

2. The method according to claim 1, characterized in that: The step of generating a class name key-value pair based on the class name of the object class to be processed and a preset class identifier includes: Obtaining a reference class name of the object class to be processed; If the reference class name of the object class to be processed is camel case, a target connector is added before the first type of letters included in the reference class name of the object class to be processed, and the first type of letters included in the class name of the object class to be processed are replaced with corresponding second type of letters to obtain the class name of the object class to be processed; wherein the first type of letters are different from the second type of letters; If the letters included in the reference class name of the object class to be processed are all letters of the first type, the letters included in the second reference member name are replaced with corresponding letters of the second type to obtain the class name of the object class to be processed; If the letters included in the reference class name of the to-be-processed object class are all second-type letters, the reference class name of the to-be-processed object class is used as the class name of the to-be-processed object class.

3. The method according to claim 1, characterized in that The step of obtaining a target member name of at least one class member based on a reference member name of at least one class member comprises: Grouping the reference member name of at least one of the class members to obtain a first reference member name named in camel case, a second reference member name named in first type letters, and a third reference member name named in second type letters; Based on the first reference member name, a target connector is added before the first type of letters included in the first reference member name, and the first type of letters included in the first reference member name are replaced with corresponding second type letters to obtain a first intermediate member name corresponding to the first reference member name; Based on the second reference member name, replacing letters included in the second reference member name with corresponding second type letters to obtain a second intermediate member name corresponding to the second reference member name; Based on the first intermediate member name, the second intermediate member name and the third reference member name, the target member name of the first target class member and the target member name of the second target class member are obtained; wherein, the target member name of at least one of the class members includes the target member name of the first target class member and the target member name of the second target class member.

4. The method according to claim 3, characterized in that: The obtaining, based on the first intermediate member name, the second intermediate member name and the third reference member name, a target member name of the first target class member and a target member name of the second target class member includes: Determine the member name corresponding to the first target class member from the first intermediate member name, the second intermediate member name and the third reference member name, and obtain the third intermediate member name of the first target class member; Using a subclass identifier to identify the third intermediate member name, to obtain a target member name of the first target class member; The member name corresponding to the second target class member is determined from the first intermediate member name, the second intermediate member name and the third reference member name, and the target member name of the second target class member is obtained.

5. The method according to claim 1, characterized in that The generating a smart contract code corresponding to the target operation based on the at least one target key-value pair includes: Determining a processing order for generating the smart contract code for at least one of the target key-value pairs; determining the target operation; The at least one target key-value pair is processed in the processing order to generate the smart contract code corresponding to the target operation.

6. The method according to claim 5, characterized in that The determining of a processing order for generating the smart contract code for at least one of the target key-value pairs includes: From the class of objects to be processed, obtaining a first reference class member marked as a target identity identifier; wherein the first reference class member belongs to at least one of the class members; Determine the order of second reference class members other than the first reference class member in the class of objects to be processed, and obtain the sorting order of the second reference class members; wherein the second reference class members belong to at least one class member; Determine that the class name of the to-be-processed object class is ranked first, the first reference class member is ranked second, and the ranking order of the second reference class member plus 2 is the processing order.

7. The method according to claim 5, characterized in that The processing of each key-value pair of the at least one target key-value pair in the processing order to generate the smart contract code corresponding to the target operation includes: If the at least one target key value includes a target member name with a subclass identifier, removing the subclass identifier from the target member name to obtain a target subclass name included in the target member name; Based on the target subclass name, generate a detection code for detecting whether a blockchain data table corresponding to the target subclass name exists; Generate a generated code corresponding to the target operation, if the blockchain data table corresponding to the target subclass name exists, process each key-value pair of the at least one target key-value pair according to the processing order; wherein the smart contract code includes the detection code and the generation code.

8. The method according to claim 7, characterized in that The generating, based on the target subclass name, a detection code for detecting whether a blockchain data table corresponding to the target subclass name exists includes: Generate a first code for obtaining a blockchain data table corresponding to the target subclass name; Generate a second code for determining whether a blockchain data table corresponding to the target subclass name is obtained; Generate a third code for generating a prompt message if the blockchain data table corresponding to the target subclass name is not obtained; wherein the prompt message is used to prompt that an error occurs in obtaining the blockchain data table corresponding to the target subclass name, and the detection code includes the first code, the second code and the third code.

9. A blockchain smart contract generation device, characterized in that: The blockchain smart contract generation device includes: a memory, a processor and a communication bus; wherein: The memory is used to store executable instructions; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute the blockchain smart contract generation program stored in the memory to implement the steps of the blockchain smart contract generation method as described in any one of claims 1 to 8.

10. A storage medium, characterized in that: The storage medium stores a blockchain smart contract generation program, which, when executed by a processor, implements the steps of the blockchain smart contract generation method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for automatically generating intelligent contract

    CN106681739A

  • Code file generation method and device, computer device, and storage medium

    CN109032662A