Block chain intelligent contract processing method and device, equipment, storage medium and program product

By using natural language processing models to generate and split smart contracts, the problem of low storage efficiency of smart contracts is solved, and more efficient generation and storage procedures are achieved.

CN119848140APending Publication Date: 2025-04-18INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411973632.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The storage efficiency of smart contracts is mainly due to the large code and data of smart contracts, which leads to the consumption of computing resources and network bandwidth. The generation process relies on manual interpretation and processing, which is inefficient.

Method used

Quickly generate smart contracts by pre-stored natural language processing models, reducing manual dependencies, and splitting the smart contracts into multiple code blocks through the target natural language processing model. Each code block has a corresponding hash value, only different hash values ​​and code blocks are stored, and only one code block with the same hash value is stored.

Benefits of technology

It improves the generation and storage efficiency of smart contracts, saves storage space, reduces dependence on manual interpretation, and improves splitting efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848140A_ABST
    Figure CN119848140A_ABST
Patent Text Reader

Abstract

The invention provides a block chain intelligent contract processing method and device, equipment, a storage medium and a program product, and relates to the technical field of block chains. The method comprises the steps of performing data processing on smart contract creation demand information according to a pre-stored natural language processing model to obtain a plurality of smart contract text fragments; generating a to-be-stored smart contract; performing model training on a pre-stored natural language processing model according to the historical intelligent contract data and the pre-stored contract splitting mark data; inputting the to-be-stored smart contract into the target natural language processing model to obtain a split to-be-stored smart contract code snippet; determining an index hash value; and when it is detected that one index hash value has the same index hash value in the block chain storage space, only the index hash value is stored in the block chain storage space. According to the method, the generation efficiency of the smart contract and the storage efficiency of the smart contract are improved.
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 processing method, device, equipment, storage medium and program product. Background Art

[0002] With the rapid development of blockchain technology, smart contracts, as automatically executed programs on blockchain, are becoming more and more widely used. Smart contracts usually contain complex business logic and a large amount of data operations. However, in actual applications, the generation process of smart contracts is too dependent on manual interpretation and processing, and the storage of smart contracts is also inefficient.

[0003] Therefore, there is an urgent need for a blockchain smart contract processing method to solve the above technical problems. Summary of the invention

[0004] The present application provides a blockchain smart contract processing method, device, equipment, storage medium and program product to solve the technical problem of low storage efficiency of smart contracts.

[0005] In the first aspect, the present application provides a blockchain smart contract processing method, comprising:

[0006] Obtain smart contract creation requirement information, and perform data processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments;

[0007] Generate a smart contract to be stored according to the multiple smart contract text fragments;

[0008] Acquire historical smart contract data, and perform model training on the pre-stored natural language processing model according to the historical smart contract data and pre-stored contract splitting mark data to obtain a target natural language processing model;

[0009] Input the smart contract to be stored into the target natural language processing model to obtain split smart contract code fragments to be stored, and determine an index hash value according to each smart contract code fragment to be stored;

[0010] Store each smart contract code snippet to be stored and a corresponding index hash value into the blockchain storage space in turn;

[0011] When it is detected that an index hash value exists in the blockchain storage space with the same index hash value, only the index hash value is stored in the blockchain storage space; otherwise, the index hash value and the smart contract code fragment to be stored corresponding to the index hash value are stored in the blockchain storage space until the smart contract to be stored is stored.

[0012] In a second aspect, the present application provides a blockchain smart contract processing device, comprising:

[0013] A smart contract construction module is used to obtain smart contract creation requirement information, and perform data processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments;

[0014] The smart contract construction module is further used to generate a smart contract to be stored according to the multiple smart contract text fragments;

[0015] A model training module, used to obtain historical smart contract data, and perform model training on the pre-stored natural language processing model according to the historical smart contract data and pre-stored contract splitting mark data to obtain a target natural language processing model;

[0016] A smart contract storage module, used to input the smart contract to be stored into a target natural language processing model, obtain split smart contract code fragments to be stored, and determine an index hash value according to each smart contract code fragment to be stored;

[0017] The smart contract storage module is further used to store each smart contract code fragment to be stored and a corresponding index hash value into the blockchain storage space in sequence;

[0018] The smart contract storage module is also used to store only the index hash value in the blockchain storage space when it is detected that an index hash value exists in the blockchain storage space with the same index hash value; otherwise, the index hash value and the smart contract code fragment to be stored corresponding to the index hash value are stored in the blockchain storage space until the smart contract to be stored is stored.

[0019] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the processor;

[0020] The memory stores computer-executable instructions;

[0021] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect.

[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.

[0023] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which implements the method described in the first aspect when executed by a processor.

[0024] The present application provides a blockchain smart contract processing method, device, equipment, storage medium and program product, wherein the method first quickly generates a smart contract by pre-storing a natural language processing model, reduces the reliance on manual work in the process of generating smart contracts, and improves the efficiency of smart contract generation, and then divides the smart contract into multiple code blocks by using the target natural language processing model obtained through model training, each code block has a corresponding hash value, and only different hash values ​​and corresponding code blocks are stored, and only one code block with the same hash value is stored. While saving storage space, the storage efficiency of smart contracts is improved. Moreover, the prediction natural language processing model is used to generate the smart contract, and the target natural language processing model is used to split the stored smart contract later. The logic of processing data of the two models is similar, so the splitting process is more efficient, which improves the splitting efficiency and accuracy while also improving storage efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0026] Figure 1 A schematic diagram of an application scenario of the blockchain smart contract processing method provided in an embodiment of the present application;

[0027] Figure 2 A flowchart of a blockchain smart contract processing method provided in an embodiment of the present application;

[0028] Figure 3 A schematic diagram of the structure of a blockchain smart contract processing device provided in an embodiment of the present application;

[0029] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.

[0030] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

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

[0032] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0033] In addition, this application involves conducting big data analysis of user information (including but not limited to personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.), and using artificial intelligence technology to make automated decisions, and making technical solutions that have a significant impact on personal rights and interests based on the results of automated decisions. The application provides users with corresponding operation entrances for them to choose to agree or reject the results of automated decisions; if the user chooses to reject, the expert decision-making process will be entered.

[0034] It should be noted that the blockchain smart contract processing method, device, equipment, storage medium and program product provided in this application can be used in the field of blockchain technology, and can also be used in any field outside the field of blockchain technology. The application field of the blockchain smart contract processing method, device, equipment, storage medium and program product in this application is not limited.

[0035] In the prior art, smart contracts usually contain complex business logic and a large amount of data operations. However, in the actual application of smart contracts, the inventors found that the storage efficiency of smart contracts as a whole is often low. This is mainly because the code and data of smart contracts are usually large, and one-time loading and parsing will consume a lot of computing resources and network bandwidth, resulting in low storage efficiency of smart contracts. In addition, the generation process of smart contracts relies on manual interpretation and processing of text content, which is inefficient. Therefore, the problem of low storage efficiency of smart contracts needs to be solved urgently.

[0036] In order to solve the above technical problems, the inventors proposed the following concept: create a smart contract to be stored based on a natural speech processing model, and continuously improve the recognition accuracy of the natural speech processing model in smart contracts through model training, and then use the trained natural language model to split the smart contract to be stored generated by the natural language processing model, and use the hash value to associate with each code fragment of the smart contract, so that only one smart contract code fragment associated with the same hash value is saved until the entire smart contract to be stored is saved, thereby improving the storage efficiency of the smart contract.

[0037] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0038] Figure 1 Schematic diagram of the application scenario of the blockchain smart contract processing method provided in the embodiment of this application. Figure 1 As shown, the application scenario includes: a smart contract development terminal 101 and a blockchain 102.

[0039] Among them, the smart contract development terminal 101 can be a server that can perform artificial intelligence large model training or other computer equipment with similar functions. The smart contract development terminal 101 receives the development requirements of the smart contract, generates a smart contract according to the development requirements, and then stores the smart contract on the blockchain 102. The process of deploying a smart contract on the blockchain 102 is the process of storing the smart contract.

[0040] Figure 2 A flowchart of a blockchain smart contract processing method provided in an embodiment of the present application. Figure 2 As shown, the execution subject of the blockchain smart contract processing method provided in the embodiment of the present application is Figure 1 The smart contract development terminal 101 shown can, of course, also be other computer-related devices with the same control function, which is not limited in this embodiment.

[0041] like Figure 2 As shown, the blockchain smart contract processing method includes:

[0042] S201: Obtain smart contract creation requirement information, and perform data processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments.

[0043] In this embodiment, the smart contract creation requirement information can be information on smart contract development requirements provided by the business party to the developer, such as: task information to be executed by the smart contract, node information to be stored on the blockchain by the smart contract, and execution step information of the smart contract.

[0044] In this embodiment, data processing can be a process of using a pre-stored natural language processing model to perform text recognition and sorting on the smart contract creation requirement information. The pre-stored natural language processing model can be an open source text processing model in the field of artificial intelligence, such as: NLP model or other deep learning model with text recognition function, recurrent neural network RNN ​​or deep learning model Transformer based on self-attention mechanism.

[0045] Specifically, in an optional embodiment of the present application, in step S201, data processing is performed on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments, including:

[0046] S201a: Perform text recognition processing on the smart contract creation requirement information according to the pre-stored natural language processing model to obtain the smart contract text information.

[0047] S201b: Split the smart contract text information according to the contract steps based on the pre-stored natural language processing model to obtain multiple smart contract text fragments.

[0048] In this embodiment, the text recognition process may be a process of identifying key text content related to the compilation of the smart contract in the smart contract creation requirement information. The splitting process may be a process of splitting the key text content related to the smart contract into text segments related to a single execution step according to the execution steps of the smart contract. For example: a text content containing 10 natural paragraphs, each natural paragraph of the text content corresponds to an execution step, and the text content of the 10 natural paragraphs obtained by splitting corresponds to 10 smart contract text segments.

[0049] In this embodiment, the text recognition processing of the smart contract is performed by using a pre-stored natural language processing model, which is more efficient than manual interpretation and recognition.

[0050] S202: Generate a smart contract to be stored based on multiple smart contract text fragments.

[0051] In this embodiment, generating a smart contract to be stored based on multiple smart contract text fragments can be a process of writing a smart contract code that can execute the contract steps required by the content of the smart contract text fragments according to the content of the smart contract text fragments.

[0052] Specifically, in an optional embodiment of the present application, step S202 includes:

[0053] S202a: Execute a contract encoding operation according to the multiple smart contract text fragments to obtain multiple smart contract code fragments, wherein each smart contract text fragment has one and only one corresponding smart contract code fragment;

[0054] S202b: Combine all smart contract code snippets according to the contract steps to obtain the smart contract to be stored.

[0055] In this embodiment, executing the contract encoding operation according to the smart contract text fragment can be a process of automatically completing the encoding of the smart contract code fragment using an existing encoding tool. Combining the smart contract code fragments according to the contract steps can be a process of encapsulating the smart code contract to form a complete smart contract.

[0056] In this embodiment, by automatically executing contract coding operations and combining them according to contract steps, the development cycle of the smart contract to be stored is shortened and the generation efficiency is higher.

[0057] S203: Obtain historical smart contract data, and perform model training on a pre-stored natural language processing model based on the historical smart contract data and pre-stored contract splitting and marking data to obtain a target natural language processing model.

[0058] In this embodiment, the historical smart contract data may be the smart contracts that have been written before the smart contract to be stored is generated and the data related to these smart contracts. The model training process may be a process of comparing the smart contract generated by using the contract requirement information in the historical smart contract data and the pre-stored natural language processing model with the smart contract that has been written, and adjusting the pre-stored natural language processing model.

[0059] Specifically, in an optional embodiment of the present application, step S203 includes:

[0060] S203a: Perform text conversion processing based on historical smart contract data to obtain a text format contract.

[0061] In an optional embodiment of the present application, step S203a specifically includes the following steps:

[0062] Step a1: Perform text recognition processing based on historical smart contract data to obtain a first vocabulary.

[0063] In this embodiment, the first vocabulary may include all possible words and phrases, keywords, variable names, function names, and data types used in the smart contract code.

[0064] For example, the first vocabulary may be as follows:

[0065] Keywords: function, conditional statement if, selection statement else, return return, unsigned integer uint, address address.

[0066] Variable name: balance, user owner.

[0067] Function name: transfer, withdraw.

[0068] Data type: Boolean bool.

[0069] Step a2: Establish a mapping relationship between special characters in the first vocabulary and historical smart contract data and a mapping relationship between keywords and data types based on the first vocabulary and historical smart contract data.

[0070] In this embodiment, a mapping relationship between the vocabulary and the special characters, keywords and data types in the smart contract code is established. A mapping relationship is associated between each entry in the vocabulary and its corresponding text.

[0071] Step a3: traverse each part of the historical smart contract data, and replace each element in the historical smart contract data with the corresponding text content according to the mapping relationship between the first vocabulary and the special characters in the historical smart contract data and the mapping relationship between the keywords and the data types to obtain a text format contract.

[0072] In this embodiment, each element in the historical smart contract is replaced with the corresponding text content through a mapping relationship, so that the obtained text format contract data is more accurate, providing more accurate data for subsequent model training, thereby improving the accuracy of the target natural language processing model.

[0073] S203b: Perform word segmentation processing according to the text format contract to obtain a contract word sequence.

[0074] Specifically, in an optional embodiment of the present application, step S203b includes:

[0075] Step b1: Perform identification processing according to the text format contract to obtain the text format type.

[0076] Step b2: Select a target word segmentation tool from a pre-stored word segmentation tool library according to the text format type.

[0077] In this embodiment, the pre-stored word segmentation tool library contains many open source word segmentation tools to choose from, such as: the jieba library that focuses on Chinese word segmentation, the natural language toolkit library NLTK, or word segmentation libraries of other languages. If you are processing Chinese text, you can choose jieba; for English, you can choose the natural language toolkit library NLTK or use the natural language processing tool spaCy as a word segmentation tool.

[0078] Step b3: Segment the text format contract into word sequences consisting of words and / or tokens using a target word segmentation tool.

[0079] In this embodiment, the text format contract is segmented into a word sequence consisting of words, a word sequence consisting of tags, and a word sequence consisting of words and tags by a target word segmentation tool.

[0080] For example, if the input text format contract is "Smart contracts are used to manage assets. They contain multiple functions, such as transfer, deposit and withdrawal", the word sequence obtained after word segmentation can be "['smart contract', 'used for', 'management', 'digital', 'assets', '.', 'contains', 'multiple', 'functions', 'such as', 'transfer', '、', 'deposit', 'withdrawal', '.'].

[0081] In this embodiment, by selecting different target word segmentation tools, the obtained contract word sequence is made more accurate and more conducive to subsequent model training.

[0082] S203c: Perform model training on the pre-stored natural language processing model according to the contract word sequence to obtain an intermediate natural language processing model.

[0083] S203d: Use the pre-stored contract split labeled data as the validation set and the test set to perform model adjustment training on the intermediate natural language processing model in turn to obtain the target natural language processing model.

[0084] In this embodiment, the pre-stored natural language processing model is trained by using the contract word sequence obtained through text conversion and word segmentation, and then the model is adjusted using the pre-stored contract split labeled data as the verification set and test set. The final target natural language processing model has a higher accuracy rate and is more efficient in generating smart contracts to be stored.

[0085] S204: Input the smart contract to be stored into the target natural language processing model to obtain the split smart contract code fragments to be stored, and determine an index hash value according to each smart contract code fragment to be stored.

[0086] In this embodiment, the target natural language processing model obtained after model training has the function of identifying keywords and tags in the smart contract to be stored, and can automatically identify and split the smart contract to be stored to obtain the split smart contract code fragments to be stored.

[0087] In this embodiment, according to the smart contract code snippet, determining the index hash value can be to generate a fixed-length output of the input smart contract code snippet through a hash algorithm, and the fixed-length output is the index hash value. Only the same code snippet can obtain the same index hash value. Any modification to the smart contract will result in a change in the hash value.

[0088] S205: Store each smart contract code snippet to be stored and a corresponding index hash value into the blockchain storage space in turn.

[0089] In this embodiment, starting from the first smart contract code snippet to be stored of the smart contract to be stored, the first smart contract code snippet to be stored and the corresponding index hash value are stored in the blockchain storage space, and then the second smart contract code snippet to be stored and the corresponding index hash value are stored in the blockchain storage space, and so on.

[0090] S206: When it is detected that an index hash value has the same index hash value in the blockchain storage space, only the index hash value is stored in the blockchain storage space. Otherwise, the index hash value and the smart contract code fragment to be stored corresponding to the index hash value are stored in the blockchain storage space until the smart contract to be stored is stored.

[0091] In this embodiment, whenever there is an index hash value and a smart contract code snippet to be stored, it is necessary to detect whether the index hash value already stored in the blockchain storage space is the same as the index hash value to be stored. If there is a same index hash value, then at this time, just store the index hash value in the blockchain storage space. If it is detected that there is no same index hash value, the same method as in step S205 is used to store the index hash value and the smart contract code snippet to be stored corresponding to the index hash value in the blockchain storage space until the smart contract to be stored is stored.

[0092] In this embodiment, storage completion may mean that all index hash values ​​corresponding to all the smart contract code snippets to be stored of the smart contract to be stored are stored in the blockchain storage space.

[0093] In order to make the blockchain smart contract processing method provided in the embodiment of the present application easier for those skilled in the art to understand, the storage process of the entire digital asset management smart contract will be described below as an example:

[0094] 1. The developer collects development requirement information of the digital asset management smart contract from the business side.

[0095] 2. Perform data processing on development requirement information through a pre-stored natural language processing model to obtain multiple smart contract text fragments.

[0096] 3. Generate smart contract code snippets based on smart contract text snippets and form smart contracts to be stored.

[0097] 4. Use the trained target natural language processing model to split the smart contract to be stored into five smart contract code snippets to be stored. These five smart contract code snippets to be stored represent the five operation steps of deposit, A's outward transfer, withdrawal, deposit and A's outward transfer.

[0098] 5. Based on the five smart contract code snippets to be stored, a hash algorithm is used to generate three hash values ​​in sequence, namely Hash1 corresponding to the first deposit operation step, Hash2 corresponding to the first A outward transfer operation step, Hash3 corresponding to the withdrawal operation step, Hash1 corresponding to the second deposit operation step, and Hash2 corresponding to the second A outward transfer operation step.

[0099] 6. When storing the hash value and the smart contract snippet to be stored in step 5, first store Hash1 corresponding to the first deposit operation step and the smart contract code snippet 1 to be stored in the blockchain storage space, and then store Hash2 corresponding to the first A outward transfer operation step and the smart contract code snippet 2 to be stored in the blockchain storage space. When storing the fourth Hash1, it is detected that there is already a Hash1 in the blockchain storage space. At this time, there is no need to store the smart code snippet 4 to be stored, only Hash1 is needed, because the smart code snippet 4 to be stored is the same as the smart contract code snippet 1 to be stored, and there is no need to store it repeatedly. By analogy, the smart contract code snippets to be stored in the blockchain storage space include: [smart contract code snippet 1 to be stored, smart contract snippet 2 to be stored, smart contract snippet 3 to be stored]. The index hash values ​​in the blockchain storage space include: [Hash1, Hash2, Hash3, Hash1, Hash2].

[0100] Based on the above embodiment, the blockchain smart contract processing method provided in an optional embodiment of the present application further includes:

[0101] Step A: Get existing smart contract data.

[0102] Step B: Classify and process the existing smart contract data to obtain multiple groups of different types of existing smart contract data.

[0103] Step C: Perform text recognition processing on each type of existing smart contract data to obtain a second vocabulary corresponding to each type of smart contract data.

[0104] Step D: Merge all the second vocabulary lists with the first vocabulary list to obtain an updated first vocabulary list.

[0105] In this embodiment, the existing smart contract data may be data related to smart contracts of different fields, different types, and different task purposes. The existing smart contract data includes the existing smart contract code and the existing smart contract creation requirement information. The classification process may be a process of dividing the smart contract data into multiple groups according to the task type or field of the smart contract or the final task purpose, and the types of each group of smart contract data are different.

[0106] In this embodiment, the principle of step C is similar to the principle of step a1 in the above embodiment, so this embodiment will not be repeated here. The process of merging all the second vocabulary tables with the first vocabulary table in step D refers to the process of adding the keywords, symbols, data types and other data in the second vocabulary table that are different from the first vocabulary table to the first vocabulary table to obtain the updated first vocabulary table.

[0107] In this embodiment, by updating the first vocabulary, different types of vocabularies are used for the subsequent generation and storage of different types of smart contracts, thereby further improving accuracy and efficiency.

[0108] In an optional embodiment of the present application, it also includes:

[0109] Step E: Regularly obtain new smart contract creation requirement information, and perform data processing on the new smart contract creation requirement information according to the target natural language processing model to obtain multiple new smart contract text fragments.

[0110] Step F: Generate a new smart contract to be stored based on multiple new smart contract text fragments.

[0111] Step G: Perform contract detection on the new smart contract to be stored and obtain the detection result.

[0112] Step H: Adjust the target natural language processing model according to the detection results to obtain an adjusted target natural language processing model.

[0113] In this embodiment, the principles of step E and step F are similar to those of step S201 to step S202 in the above embodiment, so they are not described again in this embodiment.

[0114] It should be noted that the purpose of contract detection for new smart contracts to be stored is to detect whether the new smart contracts to be stored are generated according to the needs of the business party, and whether they are close to or even the same as the smart contracts actually required by the business party.

[0115] In this embodiment, by improving the target natural language processing model, the subsequent generation and storage efficiency of smart contracts can be higher, and the generated smart contracts are more in line with development requirements.

[0116] In summary, a blockchain smart contract processing method provided by an embodiment of the present application quickly generates a smart contract by pre-storing a natural language processing model, which reduces the reliance on manual labor in the process of generating smart contracts and improves the efficiency of smart contract generation. Then, the smart contract is divided into multiple code blocks by using the target natural language processing model obtained through model training. Each code block has a corresponding hash value, and only different hash values ​​and corresponding code blocks are stored. Only one code block with the same hash value is stored. While saving storage space, the storage efficiency of smart contracts is improved. Moreover, the prediction natural language processing model is used to generate the smart contract, and the target natural language processing model is used to split the stored smart contract later. The logic of processing data of the two models is similar. Therefore, the splitting process is more efficient, which improves the splitting efficiency and accuracy while also improving storage efficiency.

[0117] Figure 3 A schematic diagram of the structure of a blockchain smart contract processing device provided in an embodiment of the present application.

[0118] like Figure 3 As shown, the blockchain smart contract processing device provided in the embodiment of the present application includes: a smart contract construction module 31, a model training module 32 and a smart contract storage module 33.

[0119] The smart contract construction module 31 is used to obtain smart contract creation requirement information, and perform data processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments.

[0120] The smart contract construction module 31 is also used to generate a smart contract to be stored based on multiple smart contract text fragments.

[0121] The model training module 32 is used to obtain historical smart contract data, and to perform model training on a pre-stored natural language processing model based on the historical smart contract data and pre-stored contract splitting mark data to obtain a target natural language processing model.

[0122] The smart contract storage module 33 is used to input the smart contract to be stored into the target natural language processing model, obtain the split smart contract code fragments to be stored, and determine an index hash value according to each smart contract code fragment to be stored.

[0123] The smart contract storage module 33 is also used to store each smart contract code fragment to be stored and a corresponding index hash value into the blockchain storage space in sequence.

[0124] The smart contract storage module 33 is also used to store only the index hash value in the blockchain storage space when it is detected that an index hash value exists in the blockchain storage space. Otherwise, the index hash value and the smart contract code fragment to be stored corresponding to the index hash value are stored in the blockchain storage space until the smart contract to be stored is stored.

[0125] In an optional embodiment of the present application, the smart contract construction module 31 is specifically used to: perform text recognition processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain smart contract text information; split the smart contract text information according to the contract steps according to the pre-stored natural language processing model to obtain multiple smart contract text fragments.

[0126] In an optional embodiment of the present application, the smart contract construction module 31 is specifically used to: perform contract encoding operations according to multiple smart contract text fragments to obtain multiple smart contract code fragments, wherein each smart contract text fragment has one and only one corresponding smart contract code fragment; combine all smart contract code fragments according to the contract steps to obtain the smart contract to be stored.

[0127] In an optional embodiment of the present application, the model training module 32 is specifically used to: perform text conversion processing based on historical smart contract data to obtain a text format contract; perform word segmentation processing based on the text format contract to obtain a contract word sequence; perform model training on a pre-stored natural language processing model based on the contract word sequence to obtain an intermediate natural language processing model; use the pre-stored contract split label data as a verification set and a test set to perform model adjustment training on the intermediate natural language processing model in turn to obtain a target natural language processing model.

[0128] In an optional embodiment of the present application, the model training module 32 is further specifically used to: perform text recognition processing based on historical smart contract data to obtain a first vocabulary; establish a mapping relationship between the first vocabulary and special characters in the historical smart contract data, and a mapping relationship between keywords and data types based on the first vocabulary and the historical smart contract data; traverse each part of the historical smart contract data, and replace each element in the historical smart contract data with corresponding text content based on the mapping relationship between the first vocabulary and special characters in the historical smart contract data, and the mapping relationship between keywords and data types, so as to obtain a text format contract.

[0129] In an optional embodiment of the present application, the model training module 32 is further specifically used to: perform recognition processing according to the text format contract to obtain the text format type; select a target word segmentation tool from a pre-stored word segmentation tool library according to the text format type; and divide the text format contract into a word sequence composed of words and / or tags through the target word segmentation tool.

[0130] In an optional embodiment of the present application, the model training module 32 is also used to: obtain existing smart contract data; perform classification processing based on the existing smart contract data to obtain multiple groups of existing smart contract data of different types; perform text recognition processing based on each type of existing smart contract data to obtain a second vocabulary corresponding to each type of smart contract data; merge all second vocabularies with the first vocabulary to obtain an updated first vocabulary.

[0131] In an optional embodiment of the present application, the model training module 32 is also used to: regularly obtain new smart contract creation requirement information, and perform data processing on the new smart contract creation requirement information according to the target natural language processing model to obtain multiple new smart contract text fragments; generate a new smart contract to be stored based on the multiple new smart contract text fragments; perform contract detection processing on the new smart contract to be stored to obtain detection results; adjust the target natural language processing model according to the detection results to obtain an adjusted target natural language processing model.

[0132] The blockchain smart contract processing device provided in this embodiment can be used to execute the above Figure 2 The technical solution of the method embodiment shown has similar implementation principles and technical effects, and will not be described in detail in this embodiment.

[0133] Figure 4 The hardware structure diagram of the electronic device provided in the embodiment of the present application is shown in FIG. Figure 4 As shown, the electronic device includes: at least one processor 401 , and a memory 402 communicatively connected to the processor 401 .

[0134] The memory 402 stores computer-executable instructions.

[0135] The processor 401 executes the computer-executable instructions stored in the memory 402 to implement the various steps involved in the method embodiment of the above blockchain smart contract processing method. For details, please refer to the relevant description in the above method embodiment.

[0136] Optionally, the memory 402 may be independent or integrated with the processor 401 .

[0137] When the memory 402 is independently provided, the electronic device further includes a bus 403 for connecting the memory 402 and the processor 401 .

[0138] The embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the above-mentioned blockchain smart contract processing method is implemented.

[0139] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above blockchain smart contract processing method when executed by a processor.

[0140] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0141] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0142] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0143] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0144] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.

[0145] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0146] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0147] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0148] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A blockchain smart contract processing method, characterized in that: include: Obtain smart contract creation requirement information, and perform data processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments; Generate a smart contract to be stored according to the multiple smart contract text fragments; Acquire historical smart contract data, and perform model training on the pre-stored natural language processing model according to the historical smart contract data and pre-stored contract splitting mark data to obtain a target natural language processing model; Input the smart contract to be stored into the target natural language processing model to obtain split smart contract code fragments to be stored, and determine an index hash value according to each smart contract code fragment to be stored; Store each smart contract code snippet to be stored and a corresponding index hash value into the blockchain storage space in turn; When it is detected that an index hash value exists in the blockchain storage space with the same index hash value, only the index hash value is stored in the blockchain storage space; otherwise, the index hash value and the smart contract code fragment to be stored corresponding to the index hash value are stored in the blockchain storage space until the smart contract to be stored is stored.

2. The method according to claim 1, characterized in that The smart contract creation requirement information is processed according to the pre-stored natural language processing model to obtain multiple smart contract text fragments, including: Performing text recognition processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain smart contract text information; The smart contract text information is split and processed according to the contract steps according to the pre-stored natural language processing model to obtain multiple smart contract text fragments.

3. The method according to claim 2, characterized in that The step of generating a smart contract to be stored according to the multiple smart contract text fragments includes: Execute a contract encoding operation according to the multiple smart contract text fragments to obtain multiple smart contract code fragments, wherein each smart contract text fragment has one and only one corresponding smart contract code fragment; Combine all smart contract code snippets according to the contract steps to obtain the smart contract to be stored.

4. The method according to claim 1, characterized in that: The performing model training on the pre-stored natural language processing model according to the historical smart contract data and the pre-stored contract splitting mark data to obtain a target natural language processing model includes: Perform text conversion processing according to the historical smart contract data to obtain a text format contract; Perform word segmentation processing according to the text format contract to obtain a contract word sequence; Performing model training on the pre-stored natural language processing model according to the contract word sequence to obtain an intermediate natural language processing model; The pre-stored contract split labeled data is used as a verification set and a test set to perform model adjustment training on the intermediate natural language processing model in turn to obtain a target natural language processing model.

5. The method according to claim 4, characterized in that The text conversion process is performed according to the historical smart contract data to obtain a text format contract, including: Performing text recognition processing on the historical smart contract data to obtain a first vocabulary; Establishing a mapping relationship between special characters in the first vocabulary and historical smart contract data and a mapping relationship between keywords and data types according to the first vocabulary and the historical smart contract data; Traverse each part of the historical smart contract data, and replace each element in the historical smart contract data with corresponding text content according to the mapping relationship between the first vocabulary and special characters in the historical smart contract data and the mapping relationship between keywords and data types to obtain a text format contract.

6. The method according to claim 4, characterized in that The word segmentation processing is performed according to the text format contract to obtain a contract word sequence, including: Perform identification processing according to the text format contract to obtain a text format type; Selecting a target word segmentation tool from a pre-stored word segmentation tool library according to the text format type; The text format contract is segmented into word sequences consisting of words and / or tokens by the target word segmentation tool.

7. The method according to claim 5, characterized in that Also includes: Get existing smart contract data; Classify and process the existing smart contract data to obtain multiple groups of different types of existing smart contract data; Perform text recognition processing on each type of existing smart contract data to obtain a second vocabulary corresponding to each type of smart contract data; All second vocabulary lists are merged with the first vocabulary list to obtain an updated first vocabulary list.

8. The method according to any one of claims 1 to 7, characterized in that Also includes: Regularly obtain new smart contract creation requirement information, and perform data processing on the new smart contract creation requirement information according to the target natural language processing model to obtain multiple new smart contract text fragments; Generate a new smart contract to be stored according to the multiple new smart contract text fragments; Performing contract detection processing on the new smart contract to be stored to obtain a detection result; The target natural language processing model is adjusted according to the detection result to obtain an adjusted target natural language processing model.

9. A blockchain smart contract processing device, characterized in that: include: A smart contract construction module is used to obtain smart contract creation requirement information, and perform data processing on the smart contract creation requirement information according to a pre-stored natural language processing model to obtain multiple smart contract text fragments; The smart contract construction module is further used to generate a smart contract to be stored according to the multiple smart contract text fragments; A model training module, used to obtain historical smart contract data, and perform model training on the pre-stored natural language processing model according to the historical smart contract data and pre-stored contract splitting mark data to obtain a target natural language processing model; A smart contract storage module, used to input the smart contract to be stored into a target natural language processing model, obtain split smart contract code fragments to be stored, and determine an index hash value according to each smart contract code fragment to be stored; The smart contract storage module is further used to store each smart contract code fragment to be stored and a corresponding index hash value into the blockchain storage space in sequence; The smart contract storage module is also used to store only the index hash value in the blockchain storage space when it is detected that an index hash value exists in the blockchain storage space with the same index hash value; otherwise, the index hash value and the smart contract code fragment to be stored corresponding to the index hash value are stored in the blockchain storage space until the smart contract to be stored is stored.

10. An electronic device, characterized in that: include: at least one processor, and a memory in communication with the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.

12. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 8 when being executed by a processor.

Citation Information

Patent Citations

  • Block chain smart contract storage method and device

    CN114091111A

  • Block chain smart contract generation method and device, and electronic equipment

    CN115268847A

  • Smart contract creation and monitoring for event identification in a blockchain

    US20190108140A1

  • System and a method for automatic generation of smart contracts across blockchain platforms

    US20230072988A1