Intelligent contract generation method and device and computer readable storage medium

By using the large language model LLM for the requirements analysis and code generation of smart contracts, the problems of high professional threshold and low efficiency in writing existing smart contracts are solved, and high-quality smart contracts are quickly generated.

CN120179212APending Publication Date: 2025-06-20HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD +1
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202311743439.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-18
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

There are problems with high professional thresholds and low efficiency in writing existing smart contracts. Developers need to have high pre-knowledge and familiarity with the underlying logic and cryptographic algorithms of blockchain, resulting in low writing efficiency and poor code reusability.

Method used

By obtaining business demand information, we can determine whether there is a matching contract template in the contract template library. If it does not exist, we use the large language model LLM for requirements analysis and code generation, and perform quality verification to form a smart contract in the target business scenario.

Benefits of technology

It lowers the professional threshold for smart contract writing, improves writing efficiency, and ensures the accuracy and security of generated contract instances through quality verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179212A_ABST
    Figure CN120179212A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a smart contract generation method and device and a computer readable storage medium, and the method comprises the steps: obtaining the business demand information of a target business scene, and obtaining the business demand information used for indicating the demand of a smart contract in the target business scene; whether a contract template matched with the business demand information exists in a contract template library or not is judged, under the condition that the contract template matched with the business demand information does not exist in the contract template library, based on the business demand information, a large language model LLM is called, the business demand information serves as input of the LLM, demand analysis is conducted based on the business demand information through the LLM, and the business demand information is obtained. And performing code generation based on the demand analysis result, and performing quality verification on the generated contract instance to form an intelligent contract in the target business scene. According to the method, the intelligent contract can be quickly generated, and meanwhile, quality verification is performed on the generated contract instance, so that the professional threshold of intelligent contract compiling can be reduced, and the compiling efficiency of the intelligent contract is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technologies, and more specifically, to a method and apparatus for generating intelligent contracts and a computer-readable storage medium. Background Art

[0002] As a distributed and decentralized technology, blockchain provides a secure and reliable storage and verification mechanism for data and transactions. The inherent characteristics of blockchain technology, such as high security and transparency, enable it to better solve problems such as high maintenance costs, low reliability, and low data security in centralized architectures. And intelligent contracts, as an important part of blockchain technology, provide the ability for blockchain to handle complex business logics. By deploying executable code on the blockchain, intelligent contracts are closely integrated with the blockchain, and the two together build a decentralized application ecosystem.

[0003] Currently, the writing of intelligent contracts requires certain prerequisite knowledge, which sets a relatively high threshold for developers. In order to write intelligent contracts that conform to business logics, developers need to have a full understanding of the underlying execution logics of the blockchain. In order to meet the requirements for privacy protection and data security in various application scenarios, developers should also be familiar with the basic principles of cryptographic algorithms so as to incorporate relevant cryptographic algorithms into intelligent contracts. For beginners in intelligent contract development, mastering these prerequisite knowledge takes a lot of time, thus making it impossible to quickly develop intelligent contracts. On the other hand, the current contract codes lack summarization and induction, resulting in poor reusability of the contract codes. In practical applications, there are a large number of similar development requirements in intelligent contract application scenarios, and developers often need to repeatedly implement such codes. The repeated implementation of the same functions leads to low writing efficiency of intelligent contracts. Summary of the Invention

[0004] The embodiments of the present application provide a method and apparatus for generating intelligent contracts and a computer-readable storage medium to alleviate the problems of high professional threshold and low efficiency existing in the writing of existing intelligent contracts.

[0005] In a first aspect, the embodiments of the present application provide an intelligent contract method, the method including: obtaining business requirement information for indicating the requirements of an intelligent contract in a target business scenario, determining whether there is a contract template in the contract template library that matches the business requirement information, in the case where there is no contract template in the contract template library that matches the business requirement information, calling a large language model (LLM) based on the business requirement information, using the business requirement information as the input of the LLM, performing requirement parsing by the LLM based on the business requirement information, generating code based on the requirement parsing result, and performing quality verification on the generated contract instance to form an intelligent contract in the target business scenario. Wherein, the contract template library includes contract templates for pre-configured business scenarios.

[0006] Based on the method described in the first aspect, by obtaining the business requirement information of the target business scenario, when the contract template library does not include a contract template that matches the business requirement information, the business requirement information is used as the input of the large language model (LLM) to generate an intelligent contract for the target business scenario. This can quickly realize the generation of intelligent contracts. At the same time, by using the business requirement information as the input of the LLM, the LLM performs requirement analysis based on the business requirement information, generates code based on the requirement analysis result, and performs quality verification on the generated contract instance to form an intelligent contract for the target business scenario, reducing the professional threshold of code writing and further improving the writing efficiency of intelligent contracts.

[0007] In a possible implementation, the specific implementation is as follows: Based on the business requirement information, calling the LLM to generate an intelligent contract for the target business scenario includes the following processing stages: using the business requirement information as the input of the LLM and calling the LLM to generate a business requirement list for the target business scenario; using the business requirement list as the input of the LLM and calling the LLM to generate a contract instance for the target business scenario; calling the LLM to perform quality verification on the contract instance for the target business scenario to generate an intelligent contract for the target business scenario.

[0008] Based on this possible implementation, the LLM performs requirement analysis on the business requirement information to form a business requirement list, generates a contract instance based on the formed business requirement list, and performs quality verification on the generated contract instance to form an intelligent contract, realizing the entire process of intelligent contract development. By performing quality verification on the contract instance, the accuracy of the generated intelligent contract is guaranteed.

[0009] In a possible implementation, the specific implementation is as follows: Calling the LLM to generate an intelligent contract for the target business scenario includes multiple processing stages; among them, each processing stage corresponds to a prompt message; the prompt message includes at least one of a role prompt, a background input, a task instruction, and a paradigm prompt.

[0010] Based on this possible implementation, guiding the LLM to generate an intelligent contract through the prompt message can improve the output accuracy of the LLM. And through the paradigm prompt, reference data is provided for the output of the LLM, guiding the LLM to output results with a unified format that meets the paradigm prompt, further improving the output accuracy of the LLM.

[0011] In a possible implementation, the specific implementation is as follows: The prompt message corresponding to each processing stage is obtained according to the prompt message template and the requirement information of the processing stage; the prompt message template includes a role prompt, a background input, a task instruction, and a paradigm prompt.

[0012] Based on this possible implementation, a prompt message is formed by filling in a prompt message template, standardizing the format of the prompt message, simplifying the generation steps of the prompt message, and improving the generation efficiency of the smart contract.

[0013] In one possible implementation, it is specifically implemented as follows: the prompt message template further includes at least one of a thought chain and an evaluation prompt;

[0014] wherein, the thought chain is used to indicate the sub-processing stages included in the LLM processing stage and the execution logic between the sub-processing stages; the evaluation prompt is used to indicate the LLM to evaluate the matching degree of the output result of the LLM.

[0015] Based on this possible implementation, the processing stage of the prompt message is divided into multiple sub-processing stages through the thought chain, and the large language model (LLM) is guided to execute these sub-processing stages one by one to ensure the successful completion of the processing stage of the prompt message, and to prevent the LLM from missing information or execution steps; and an evaluation prompt is added to enable the LLM to perform self-review and evaluation before outputting the result, ensuring the quality and accuracy of the finally output smart contract.

[0016] In one possible implementation, it is specifically implemented as follows: when the processing stage is to use the business requirement information as the input of the LLM and call the LLM to generate a business requirement list for the target business scenario, the role prompt is a requirements analyst; the background input is the business requirement information; the task instruction is to perform requirements analysis based on the business requirement information to form a business requirement list; the paradigm prompt is a sample business requirement list in the contract template library that matches the target business scenario; the contract template library includes contract templates for pre-configured business scenarios and the corresponding business requirement lists for each contract template.

[0017] Based on this possible implementation, when generating business requirement information through the LLM, a sample business requirement list in the contract template library that matches the target business scenario is used as the paradigm prompt, the requirements analyst is used as the role prompt, and the business requirement information is used as the background input to guide the LLM to perform requirements analysis based on the business requirement information and output a business requirement list that is consistent with the sample business requirement list, further improving the output accuracy of the LLM.

[0018] In one possible implementation, when using the business requirement list as the input of the LLM and calling the LLM to generate a contract instance for the target business scenario, it is specifically implemented as follows: using the business requirement list as the input of the LLM and calling the LLM to generate a contract template for the target business scenario; filling the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario.

[0019] Based on this possible implementation, the LLM generates a contract template based on the business requirement list, and the user selects component instances to fill the template to form a contract instance, realizing the flexible customization of smart contracts.

[0020] In a possible implementation, the specific implementation is as follows: In the processing stage, when the business requirement list is used as the input of the LLM and the LLM is called to generate a contract template for the target business scenario, the role prompt is the developer; the background input is the business requirement list of the target business scenario; the task instruction is to design the smart contract code according to the business requirement list of the target business scenario to form a design idea, and according to the design idea, write the contract code to form a contract template; the paradigm is a contract template example matching the target business scenario; the contract template example is obtained from the contract template library.

[0021] Based on this possible implementation, in the process of generating a contract template based on the LLM, the contract template matching the target business scenario in the contract template library is used as the paradigm prompt, the business requirement list is used as the background input, and the role prompt of the LLM is determined as the developer, guiding the LLM to generate a contract based on the business requirement list to form a contract template, further improving the output accuracy of the large language model LLM.

[0022] In a possible implementation, filling the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario, the specific implementation is as follows:

[0023] Output the code editing page view;

[0024] Obtain the component information input by the user based on the code editing page view;

[0025] Based on the component information and the preset component decision model, obtain candidate component instances matching the component information from the contract component library; the contract component library includes multiple pre-configured component instances;

[0026] In response to the component selection operation input by the user based on the candidate component instances, determine the component instances selected by the user;

[0027] Fill the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario.

[0028] Based on this possible implementation, by selecting the corresponding component instances through the input component information in the code editing page to fill the contract template, the generation of the contract instance is realized, which can simplify the development process of the smart contract, lower the development threshold of the smart contract, and improve the intelligent generation efficiency.

[0029] In a possible implementation, the component instances selected by the user are filled into the contract template to obtain a contract instance for the target business scenario. The specific implementation is as follows:

[0030] Output the code editing page view;

[0031] In the code editing page view, display the candidate component instances in the contract component library that match the target business scenario; the contract component library includes multiple pre-configured component instances;

[0032] In response to the component selection operation input by the user based on the candidate component instances, determine the component instances selected by the user;

[0033] Fill the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario.

[0034] Based on this possible implementation, display the component instances corresponding to the business development scenario in the code editing page view. By reducing the component instances displayed in the code editing page view, the selection efficiency of the component instances is improved, and thus the generation efficiency of the smart contract is improved.

[0035] In a possible implementation, the specific implementation is as follows: in the processing stage, when calling the LLM to perform quality verification on the contract instance of the target business scenario to generate a smart contract for the target business scenario, the background input is the business requirement list of the target business scenario and the contract instance; the task instruction is to detect whether the contract instance is correct and whether the contract instance meets the business requirement list; the paradigm prompt is the preset security vulnerability examples in the contract template library.

[0036] Based on this possible implementation, in the quality verification, use the preset security vulnerability examples in the contract template library as the paradigm prompt to detect whether there are vulnerabilities in the contract instance and whether the contract instance meets the business requirement list, ensuring that the generated smart contract meets the business requirement list while reducing security vulnerabilities and improving the quality of the smart contract.

[0037] In a possible implementation, the specific implementation is as follows: the processing stage includes a first sub-processing stage and a second sub-processing stage; the evaluation prompt includes the evaluation prompt of the first sub-processing stage and the evaluation prompt of the second sub-processing stage;

[0038] The first sub-processing stage is used to instruct the LLM to detect whether the contract instance of the target business scenario is correct, and in the case where the contract code is incorrect, determine the vulnerabilities existing in the contract instance;

[0039] The second sub-processing stage is used to instruct the LLM to detect whether the contract instance meets the business requirement list based on the business requirement list, and in the case where the contract instance does not meet the business requirement list, determine the requirements missed by the contract instance;

[0040] The evaluation prompt for the first sub - processing stage is to determine whether there are vulnerabilities in the contract instance other than security vulnerability examples.

[0041] The evaluation prompt for the second sub - processing stage is to determine whether there are requirements in the contract instance that are missing other than the business requirement list.

[0042] Based on this possible implementation method, through the chain of thought, the processing stages indicated by the prompt information corresponding to quality verification are divided into the first sub - processing stage of security vulnerability detection and the second sub - processing stage of logical vulnerability detection. By performing security vulnerability detection and logical vulnerability detection on the contract instance, the large - language model is guided to complete each sub - processing stage one by one, effectively improving the accuracy of the output result of the large - language model; at the same time, the evaluation prompt for the sub - processing stage is added, and self - checking and correction are performed before the large - language model outputs the result, further improving the accuracy of the output result of the large - language model.

[0043] In a possible implementation method, the business requirement information is used as the input of the LLM, and the LLM is called to generate a business requirement list for the target business scenario. The specific implementation is as follows: The following process is repeatedly executed until a business requirement list confirmed by the user is obtained:

[0044] Show the business requirement list output by the LLM to the user;

[0045] In response to the user's modification operation, modify the business requirement list output by the LLM, and re - input the modified business requirement list and the business requirement list into the LLM to obtain a new business requirement list.

[0046] Based on this possible implementation method, after the large - language model returns the business requirement list, the business requirement list is displayed. In the case of the user inputting a modification operation, the business requirement list is modified, increasing the interaction with the user to ensure that the generated business requirement list meets the user's needs.

[0047] In a possible implementation method, the business requirement list is used as the input of the LLM, and the LLM is called to generate a contract instance for the target business scenario. The specific implementation is as follows: The following process is repeatedly executed until a contract template confirmed by the user is obtained, and then the component instances selected by the user are filled into the contract template to obtain a contract instance for the target business scenario:

[0048] Show the contract template output by the LLM to the user;

[0049] In response to the user's modification operation, modify the contract template output by the LLM, and re - input the modified contract template and the business requirement list into the LLM to obtain a new contract template.

[0050] Based on this possible implementation, after the large language model returns the smart contract template, the smart contract template is displayed. In the case where the user inputs a modification operation, the smart contract template is modified, increasing the interactivity with the user and further improving the accuracy of the generated smart contract template, thereby improving the accuracy of the generated smart contract.

[0051] In one possible implementation, the specific implementation is as follows: After calling the LLM to perform quality verification on the contract instance of the target business scenario and generating the smart contract under the target business scenario, the business requirement list of the target business scenario and the contract template corresponding to the business requirement list are associated and written into the contract template library.

[0052] Based on this possible implementation, in the case where there is a contract template in the contract template library that matches the business requirement information, after generating the contract template under the target business scenario through the LLM and filling the contract template to form a contract instance, and calling the LLM to perform quality verification on the contract instance of the target business scenario, the contract template under the target business scenario and the business requirement list of the target business scenario are associated and written into the contract template library. In this way, by increasing the number and types of contract templates in the contract template library, more reusable contract templates are provided, thereby reducing the difficulty of writing smart contracts and improving the writing efficiency of smart contracts.

[0053] In one possible implementation, calling the LLM to perform quality verification on the contract instance of the target business scenario and generating the smart contract under the target business scenario is specifically implemented as follows:

[0054] Show the user the quality verification result of the contract instance output by the LLM; the quality verification result indicates whether there are vulnerabilities in the contract instance and whether there are missing requirements;

[0055] In response to the result confirmation operation input by the user, obtain the quality verification result confirmed by the user;

[0056] Use the quality verification result confirmed by the user as the input of the LLM, call the LLM for code correction, and generate code modification suggestions for the contract instance, as well as the location and cause of the vulnerabilities in the contract instance;

[0057] Based on the code modification suggestions, the location of the vulnerabilities in the contract instance, and the cause of the vulnerabilities, obtain the smart contract under the target business scenario.

[0058] Based on this possible implementation method, after the large language model outputs the quality verification result of the contract instance, the quality verification result of the contract instance is presented to the user. After obtaining the quality verification result confirmed by the user, the LLM performs code correction based on the quality verification result confirmed by the user to form code modification suggestions for the contract instance, as well as the location and cause of vulnerabilities in the contract instance. Vulnerabilities are repaired based on the code modification suggestions for the contract instance, as well as the location and cause of vulnerabilities in the contract instance to form an intelligent contract in the target business scenario. By adding the input of the confirmation operation of the quality verification result, false detection and missed detection of vulnerabilities are ensured, and the accuracy of the generated intelligent contract is further guaranteed. At the same time, based on the quality verification result confirmed by the user, code modification suggestions are formed, and based on the code modification suggestions, the contract instance is corrected to obtain an intelligent contract, improving the quality of the intelligent contract.

[0059] In one possible implementation method, the specific implementation is as follows: When there is a contract template matching the business requirement information in the contract template library, the component instances selected by the user are filled into the contract template to obtain a contract instance for the target business scenario; the LLM is called to perform quality verification on the contract instance for the target business scenario to generate an intelligent contract in the target business scenario.

[0060] Based on this possible implementation method, when there is a contract template matching the business requirement information in the contract template library, the contract template matching the business requirement information is reused to implement the generation of the intelligent contract, simplifying the development difficulty of the intelligent contract and improving the development efficiency of the intelligent contract.

[0061] In one possible implementation method, the specific implementation is as follows: The business requirement information for the target business scenario is obtained based on the business requirement question list; the business requirement question list includes multiple requirements to be written, and each requirement is used to describe the requirement information of the intelligent contract to be generated.

[0062] Based on this possible implementation method, by pre-constructing the requirement question list, when obtaining the business requirement information, the business requirement information is obtained from the requirement question list. In this way, the standardized acquisition of the business requirement information is realized through the requirement question list.

[0063] In a possible implementation, the specific implementation is as follows: Compare the business requirement list corresponding to the contract template with the requirements indicated by the business requirement information to detect whether the business requirement list corresponding to the contract template included in the contract template library includes the requirements indicated by the business requirement information. When the business requirement list corresponding to the contract template included in the contract template library includes all the requirements indicated by the business requirement information, determine that there is a contract template in the contract template library that matches the business requirement information. When the business requirement list corresponding to the contract template included in the contract template library does not fully include all the requirements indicated by the business requirement information, determine that there is no contract template in the contract template library that matches the business requirement information.

[0064] Based on this possible implementation, by comparing the business requirement list corresponding to the contract template with the requirements indicated by the business requirement information to detect whether the business requirement list corresponding to the contract template included in the contract template library includes the requirements indicated by the business requirement information, and thus determining whether there is a contract template in the contract template library that matches the business requirement information, it is possible to simplify the contract template detection method and improve the development efficiency of smart contracts.

[0065] In a possible implementation, the specific implementation is as follows: The above method is executed by a smart contract coding tool; among them, the smart contract coding tool includes a display layer, an agent layer, a core layer, a code resource layer, and a storage layer;

[0066] The display layer is used to provide interface interaction for the smart contract coding tool;

[0067] The agent layer is used to reverse proxy the business functions of the smart contract coding tool; the business functions include at least one of code resource management, business requirement analysis, code generation, and contract quality verification;

[0068] The core layer is used to provide the business functions of the smart contract coding tool;

[0069] The code resource layer is used to store the code resources of the smart contract coding tool; the code resources include contract templates and component instances;

[0070] The storage layer is used to provide the storage function of the smart contract coding tool and store data other than the code resources of the smart contract coding tool.

[0071] Based on this possible implementation, the full-process development of smart contracts is realized through the smart contract coding tool, reducing the development difficulty of smart contracts and improving the development efficiency of smart contracts.

[0072] In a possible implementation, the specific implementation is as follows: The code resource layer is provided with a contract template library and a contract component library;

[0073] A contract template library, including contract templates for multiple business scenarios and a business requirement list corresponding to each contract template;

[0074] A contract component library, including component instances for calling contract templates in the contract template library.

[0075] Based on this possible implementation method, a contract template library and a contract component library are set in the code resource layer to realize the reuse of contract templates and the reuse of component instances, reduce the development difficulty of smart contracts, and improve the development efficiency of smart contracts.

[0076] In a possible implementation method, the specific implementation is as follows: the contract component library is divided into at least one component sub-layer according to the component type of the component instance; each component sub-layer corresponds to a component type, and each component sub-layer stores component instances of the corresponding component type; the component type includes at least one of general operation components, algorithm tool components, basic operation components, and data structure components.

[0077] Based on this possible implementation method, contract components are stored through a hierarchical storage structure, and component instances related to general operations and algorithm tools are stored separately in layers to facilitate the search and management of component instances.

[0078] In a second aspect, an embodiment of the present application provides a smart contract generation device, which can be a computer cluster for executing the smart contract generation method, or a computing device in the computer cluster, or a chip or system-on-chip in the computing device, or a functional module in the computing device for implementing the method in the first aspect or any possible implementation method of the first aspect. The smart contract generation device can implement the functions executed by the method computing device in the first aspect or any possible implementation method of the first aspect. The functional module can be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. For example: an acquisition module, a judgment module, and a contract generation module. Optionally, the computer cluster includes at least one computing device.

[0079] Among them, the acquisition module is used to obtain the business requirement information of the target business scenario; the business requirement information is used to indicate the requirements for generating a smart contract under the target business scenario;

[0080] The judgment module is used to judge whether there is a contract template in the contract template library that matches the business requirement information;

[0081] A contract generation module is used to call a large language model (LLM) to generate an intelligent contract in a target business scenario based on business requirement information when the contract template library does not include a contract template that matches the business requirement information. The contract template library includes contract templates for pre-configured business scenarios. The LLM is used to perform requirement parsing based on the business requirement information, generate code based on the requirement parsing result, and perform quality verification on the generated contract instance to form an intelligent contract in the target business scenario.

[0082] Specifically, for the relevant processing actions and their beneficial effects of the acquisition module, the judgment module, the first contract generation module, and the second contract generation module, reference can be made to the first aspect or any possible implementation manner of the first aspect, and details will not be elaborated here.

[0083] In a third aspect, an intelligent contract generation device is proposed. The intelligent contract generation device can be a computer cluster for executing the intelligent contract generation method, or a computing device in the computer cluster, or a chip or system-on-chip in the computing device. It can also be a functional module in the computing device for implementing the method functions in the first aspect or any possible implementation manner of the first aspect. The intelligent contract generation device can implement the functions executed by the method computing device in the first aspect or any possible implementation manner of the first aspect. The functional module can be implemented by hardware. In a possible implementation manner, the intelligent contract generation device includes a processor and a memory. Among them, the memory is used to store the necessary computer execution instructions and data of the intelligent contract generation device, and the processor is used to execute the necessary computer execution instructions and data stored in the memory, so that the intelligent contract generation device executes the method as described in the first aspect or any possible implementation manner of the first aspect.

[0084] In a fourth aspect, a computer-readable storage medium is provided, including computer program instructions. When the computer program instructions are executed by the intelligent contract generation device, the intelligent contract generation device executes the instructions in the computing program stored in the computer-readable storage medium to execute the method as described in the first aspect or any possible implementation manner of the first aspect.

[0085] Based on the above solution, the smart contract generation method, device, and computer-readable storage medium according to the embodiments of the present application obtain the business requirement information of the target business scenario. When the contract template library does not include a contract template that matches the business requirement information, the business requirement information is used as the input of the large language model (LLM) to generate a smart contract for the target business scenario, which can quickly realize the generation of the smart contract. At the same time, by using the business requirement information as the input of the LLM, the LLM performs requirement analysis based on the business requirement information, generates code based on the requirement analysis result, and performs quality verification on the generated contract instance to form a smart contract for the target business scenario, reducing the professional threshold of code writing and further improving the writing efficiency of the smart contract. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Figure 1 is a schematic diagram of the application scenario of the smart contract generation method provided by the embodiments of the present application;

[0087] Figure 2 is a schematic flowchart of the smart contract generation method provided by the embodiments of the present application;

[0088] Figure 3 is a schematic diagram of the structure of the smart contract coding tool provided by the embodiments of the present application;

[0089] Figure 4 is a schematic diagram of the storage structure of the code resource layer 114 provided by the embodiments of the present application;

[0090] Figure 5 is a schematic diagram of the processing process in the smart contract writing scenario provided by the embodiments of the present application;

[0091] Figure 6 is another schematic diagram of the processing process in the smart contract writing scenario provided by the embodiments of the present application;

[0092] Figure 7 is a schematic diagram of the prompt information provided by the embodiments of the present application;

[0093] Figure 8 is a schematic diagram of the prompt information in the requirement analysis sub-processing stage provided by the embodiments of the present application;

[0094] Figure 9 is a schematic diagram of the requirement problem list template provided by the embodiments of the present application;

[0095] Figure 10 is a schematic flowchart of the business requirement information acquisition method based on the requirement problem list provided by the embodiments of the present application;

[0096] Figure 11 is a schematic diagram of the smart contract generation process based on the large language model provided by the embodiments of the present application;

[0097] Figure 12 It is a schematic diagram of the business requirement list generation process provided by an embodiment of the present application;

[0098] Figure 13 It is a schematic diagram of generating corresponding prompt information for the business requirement list provided by an embodiment of the present application;

[0099] Figure 14 It is a schematic diagram of the contract template generation process provided by an embodiment of the present application;

[0100] Figure 15 It is a schematic diagram of generating corresponding prompt information for the contract template provided by an embodiment of the present application;

[0101] Figure 16 It is a schematic diagram of the quality verification processing flow provided by an embodiment of the present application;

[0102] Figure 17 It is a schematic diagram of generating prompt information based on a prompt information template provided by an embodiment of the present application;

[0103] Figure 18 It is a schematic diagram of the corresponding prompt information when the processing stage is step S221 provided by an embodiment of the present application;

[0104] Figure 19 It is a schematic diagram of the corresponding prompt information when the processing stage is step S222 provided by an embodiment of the present application;

[0105] Figure 20 It is a schematic diagram of the corresponding prompt information when the processing stage is step S223 provided by an embodiment of the present application;

[0106] Figure 21 It is a schematic diagram of the contract instance correction process provided by an embodiment of the present application;

[0107] Figure 22 It is a schematic diagram of the structure of the intelligent contract generation device provided by an embodiment of the present application;

[0108] Figure 23 It is another schematic diagram of the structure of the intelligent contract generation device provided by an embodiment of the present application;

[0109] Figure 24 It is a schematic diagram of the structure of the computing device provided by an embodiment of the present application. Detailed implementation manners

[0110] First, several terms involved in the present application are explained:

[0111] Blockchain: A decentralized, immutable, traceable, and multi-party jointly maintained distributed data ledger that realizes the trustworthy distributed storage of data through the integration of multiple technologies such as peer-to-peer (P2P) protocols, asymmetric encryption, and consensus mechanisms.

[0112] Smart contract: A code program that runs synchronously on multiple nodes of a blockchain platform and can be executed automatically without relying on a central institution.

[0113] Large language model (LLM): A deep learning model trained using a large amount of text data that can generate natural language text or understand the meaning of language text. Large language models can handle various natural language tasks such as text classification, question answering, and dialogue, and they also have the potential in handling complex tasks such as code generation and vulnerability detection.

[0114] Prompt engineering: A human-computer interaction design method that provides detailed prompts and suggestions for an LLM, aiming to guide the model to generate specific types of content. In this method, the user provides specific instructions, questions, or contexts to the LLM to form prompt information, and then inputs the prompt information into the LLM to guide the LLM to generate responses, code, articles, or other texts that meet expectations. By giving clear prompts, prompt engineering can guide the LLM to express the required information more precisely and targeted in language generation tasks.

[0115] Role prompting: An output optimization strategy used to assign a specific person or role to an LLM, guiding the LLM to provide more relevant, domain-specific, and context-specific responses. By endowing artificial intelligence (AI) with roles or expertise, users can better customize the interaction relationship and focus on the conversation content.

[0116] Paradigm prompting: An output optimization strategy in prompt engineering that allows users to prompt the model by giving one or more paradigms (examples), enabling the model to quickly obtain the desired result pattern and thus generate results under the specified paradigm.

[0117] Chain of thought: An improved prompt information strategy that decomposes the processing stages of a complex task indicated by the prompt information into multiple sub-processing stages and guides the LLM to complete these sub-processing stages one by one to ensure the successful completion of the task. It helps ensure that each sub-processing stage of the task is properly handled and avoids the omission of key information or steps.

[0118] Self-evaluation: A method for checking the output content of an LLM that encourages the LLM to conduct self-review and evaluation before outputting results to ensure the quality and accuracy of the output content.

[0119] Customizable Coding: A programming method that allows developers to flexibly customize and adjust the implementation of code according to specific requirements and scenarios. In customizable coding, developers can select appropriate code modules, components, or algorithms according to the project requirements, and then modify, expand, and configure them as needed to generate the final program or application.

[0120] Contract Template: It can be replaced with Business Intelligence Contract Template. It is a reusable code block predefined for abstract scenario-based businesses, aiming to provide a reusable and easy-to-understand basic code structure for smart contract developers in various fields to guide and assist users in development. However, since it is not a complete and runnable smart contract, it requires developers to further fill in and improve it.

[0121] Contract Instance: That is, Business Intelligence Contract Instance or Smart Contract Instance. It is a deployable and runnable smart contract generated by developers after filling in and improving the contract template according to the business requirements of specific scenarios.

[0122] Contract Component: The underlying component of a smart contract. It is a collection of commonly used classes and functions in the field of smart contracts, including blockchain interaction operations, cryptographic algorithms, data structures and their operations, etc. It provides directly usable code resources for contract instance development to lower the learning threshold for users and simplify the contract development process.

[0123] Component Instance: That is, Smart Contract Component Instance. It is the specific implementation of a contract component.

[0124] Domain-Driven Design (DDD): An object-oriented software development methodology. By emphasizing the core concepts, rules, and relationships of the business domain, it establishes a business domain model, shifting the attention of software developers from technical details to the solution of actual business problems to achieve better software design quality and system maintainability.

[0125] In related technologies, the development of smart contracts mainly has the difficulties of long development cycle, high professional threshold, and low code quality. How to provide coding support for smart contract developers to reduce the contract writing difficulty and improve the contract code reuse rate has become a research hotspot in the current smart contract direction.

[0126] Currently, in industrial applications, there are mainly three solutions to reduce the contract writing difficulty and improve the contract code reuse rate.

[0127] Among them, the first solution is to provide support functions for the entire process of contract development in the form of coding tools.

[0128] For example, the Ethereum development framework Truffle provides functions such as compilation, linking, and deployment. Truffle has automated testing capabilities that can help developers test and modify smart contracts immediately after development is completed. However, although Truffle provides relatively complete support for the contract development process, its support for contract coding is relatively weak, and for developers who lack contract development experience, coding assistance is limited. For another example, the web application Remix provides a large number of contract developers with an environment for writing smart contracts in the contract-based programming language (Solidity) online. Remix provides functions such as code prompts and syntax checking, which facilitates the coding of smart contracts. However, Remix does not manage and reuse contract code resources. Developers often need to write smart contracts from scratch, and many common functional codes cannot be directly reused, which leads to developers frequently "reinventing the wheel".

[0129] The second way is to provide reusable contract code resources (or reusable code resources). Developers can use reusable code resources to reduce the amount of handwritten code and improve contract coding efficiency.

[0130] For example, the open source framework openzeppelin provides a series of smart contract code resources that have been tested and verified. By importing the contract code of openzeppelin into the contract project, contract developers can directly reuse high-quality function codes, thereby lowering the professional threshold for contract development. However, openzeppelin mainly provides cryptographic algorithm contracts that are biased towards the bottom layer, and provides fewer contract templates for specific business scenarios. In addition, openzeppelin has not built coding support tools on its smart contract code library, and has not designed coding support functions around contract code resources, so contract developers need to use other tools to reuse these code libraries. For another example, by providing rich contract code resources and decomposing contract code resources into multiple code modules according to different implementation functions, contract developers can choose code resources according to their needs. This way of decomposing code resources improves the ease of use of contract code resources to a certain extent. However, this work did not perform structural design on the decomposed code modules, and all code modules were encapsulated in the toolkit, resulting in a relatively chaotic calling relationship between code modules and poor overall maintainability of code resources. For another example, the Financial Blockchain Cooperation Alliance (Fisco Bcos) encapsulates the smart contracts that users are concerned about during programming into the upper layer of code resources, called contract templates, from the perspective of user use; and encapsulates the function code involving the underlying complex logic of the blockchain into the lower layer of code resources, called contract components. Although this work divides the contract code resources into application scenarios, the effect of the division is general, and there is a lack of obvious boundaries between the contract code resources of different application scenarios, which results in a poor selection guide for users for reusable code resources. For example, in Fisco Bcos, the contract templates for "sending red envelopes" and "marriage certificates" are divided into the same application scenario, which obviously ignores the detailed analysis of businesses in different fields.

[0131] The third way is to provide coding support to contract developers through a platform that deploys coding tools and reusable code resources.

[0132] For example, the blockchain technology platform (building block service, BCS) supports the writing, testing, and deployment of smart contracts. At the same time, the platform organizes smart contracts for different business scenarios and provides reusable contract templates for contract developers. The contract templates mainly abstract and implement business logic. Developers can select contract templates with different functions according to their development needs, thus improving the code reuse rate of smart contracts. The foundation (accord) that develops legal templates also provides a large number of reusable contract code resources and adds coding tools on this basis, enabling users to directly reuse code resources in the coding tools for development, greatly improving the contract coding efficiency. However, the reusable code resources provided by the foundation that develops legal templates lack the division of application scenarios. Moreover, the foundation that develops legal templates uses a scripting language (ergo) to write contract code resources, and this language is tightly bound to accord, making the written smart contracts unable to be directly deployed and run on other blockchain platforms. Therefore, the generality of this project is insufficient.

[0133] As can be seen from the above, there are many challenges in the current development of smart contracts, such as long development cycles, high professional thresholds, and low code quality. As shown in Table 1, although existing smart contract coding tools provide basic functions such as development, testing, and deployment, the optimization of the development process is far from enough. First of all, compared with the development of other software, smart contracts are significantly different in programming languages, interaction logics, etc., resulting in smart contract developers often having difficulty finding reference and reusable code resources for development on this basis, causing the phenomenon of "reinventing the wheel" to occur frequently. Although some existing coding tools provide some reference and reusable code resources in the form of templates or examples, these code resources are often few in number and chaotic in division, unable to meet the customized needs in a variety of application scenarios; secondly, the introduction of new programming languages, interaction logics, and the strong dependence on cryptographic algorithms require a lot of knowledge to be learned before developing contracts, resulting in a relatively high threshold for smart contract development. The manual coding method commonly used by existing tools is not friendly to developers, especially non-professional developers; finally, since smart contracts cannot be modified once they are on the chain, the requirements for code correctness and security of contracts are higher than those of other software. Junior developers are extremely likely to produce code with low code quality, causing potential safety hazards.

[0134] Table 1 Description of contract generation methods in related technologies

[0135]

[0136] Based on this, in order to solve the problems of long development cycle, high professional threshold, and low reuse rate existing in the writing of smart contracts, and at the same time ensure the code quality of the generated smart contracts, the embodiments of the present application provide a smart contract generation method, device, and computer-readable storage medium. By obtaining the business requirement information of the target business scenario, when the contract template library does not include a contract template that matches the business requirement information, the business requirement information is used as the input of the LLM to generate a smart contract for the target business scenario, which can quickly realize the generation of smart contracts. At the same time, taking the business requirement information as the input of the LLM, the LLM performs requirement parsing based on the business requirement information, generates code based on the requirement parsing result, and performs quality verification on the generated contract instance to form a smart contract for the target business scenario, reducing the professional threshold of code writing and further improving the writing efficiency of smart contracts.

[0137] It can be understood that the smart contract generation method provided by the embodiments of the present application can not only be used for the generation / development of smart contracts, but also for the development of business code, such as web development code, application code development, microservice code development, etc., without limitation. The present application takes the generation / development of smart contracts as an example for illustration, and the development of other business codes can refer to the method provided by the present application.

[0138] It can be understood that the smart contract generation method provided by the embodiments of the present application can be applied to financial business scenarios, medical business scenarios, educational business scenarios, etc. In other words, it can generate smart contracts for one or more of financial business scenarios, medical business scenarios, and educational business scenarios.

[0139] Exemplarily, taking the generation of a smart contract for grade management in an educational business scenario as an example, an application illustration of the smart contract generation method in the educational business scenario is provided, as follows Figure 1 shown Figure 1 is a schematic diagram of the application scenario of the smart contract generation method provided by the embodiments of the present application. As Figure 1 shown, this application scenario includes a user, a smart contract generation system 10, and a large language model LLM 20.

[0140] Among them, the smart contract generation system 10 and the large language model LLM can be deployed in the same computing device, or the smart contract generation system 10 and the large language model LLM 20 can be deployed in different computing devices.

[0141] Among them, the large language model LLM 20 is used to perform requirement parsing according to the business requirement information input by the smart contract generation system 10, generate code based on the requirement parsing result, perform quality verification on the generated contract instance, form a smart contract for grade management in the educational business scenario, and return the smart contract for grade management in the educational business scenario to the smart contract generation system 10.

[0142] Among them, the smart contract generation system 10 is used to generate a smart contract for grade management in the education business scenario based on the business requirement information of the smart contract for grade management in the education business scenario input by the user.

[0143] Specifically, the smart contract generation system 10 obtains the business requirement information of the smart contract for grade management in the education business scenario input by the user, queries the contract template library, and determines whether there is a contract template in the contract template library that matches the business requirement information of the smart contract for grade management in the education business scenario. In the case where there is no contract template in the contract template library that matches the business requirement information of the smart contract for grade management in the education business scenario, the large language model LLM20 is called based on this business requirement information, the business requirement information is used as the input of the LLM, and the smart contract for grade management in the education business scenario returned by the large language model LLM20 is obtained, and the smart contract for grade management in the education business scenario is displayed to the user.

[0144] Among them, the contract template library is used to store pre-configured contract templates for different business scenarios. In a possible implementation, the contract template library can be set in the smart contract generation system 10. In another possible implementation, the contract template library may not be set in the smart contract generation system 10. For example, the contract template library can be deployed in a storage device or can be deployed on a cloud platform.

[0145] Exemplarily, taking the contract template library being set in the smart contract generation system 10 as an example, as Figure 1 shown, the smart contract generation system 10 includes a user terminal 11, an agent node 12, a server 13, a management terminal 14, and a contract template library.

[0146] Among them, the user terminal 11 communicates with the server 13 through the agent node 12. The agent node 12 communicates with the user terminal 11 and the server 13 respectively. The server 13 communicates with the contract template library. The management terminal 14 communicates with the contract template library.

[0147] Among them, the user terminal 11 is used to obtain the business requirement information of the smart contract for grade management in the education business scenario input by the user, and to display the smart contract for grade management in the education business scenario returned by the LLM to the user.

[0148] The management terminal 14 is used to provide the contract template management function of the intelligent contract generation system 10, obtain the template management operations input by the user, and add, delete, adjust, etc. the contract templates in the contract template library based on the template management operations. Among them, the template management operations include contract template addition, contract template deletion, and contract template adjustment, etc. Among them, the contract template adjustment can be to adjust the code in the contract template, or to adjust the business scenario corresponding to the contract template, etc., which is not limited in this embodiment of the present application.

[0149] The proxy node 12 is used to realize data interaction between the user terminal 11 and the server terminal 13. For example, it transmits the business requirement information of the intelligent contract for grade management in the education business scenario input by the user obtained by the user terminal 11 to the server terminal 13.

[0150] The server terminal 13 is used to execute the intelligent contract generation method based on the business requirement information of the intelligent contract for grade management in the education business scenario input by the user terminal 11, generate the intelligent contract for grade management in the education business scenario, and return the intelligent contract for grade management in the education business scenario to the user terminal 11 through the proxy node 12.

[0151] The contract template library is used to provide pre-configured contract templates for different business scenarios to the server terminal 13.

[0152] Specifically, based on Figure 1 the provided application scenario, the user inputs the business requirement information of the intelligent contract for grade management in the education business scenario through the user terminal 11; the user terminal 11 transmits the obtained business requirement information of the intelligent contract for grade management in the education business scenario to the server terminal 13 through the proxy node 12; the server terminal 13, based on the business requirement information of the intelligent contract for grade management in the education business scenario, queries the contract template library to determine whether there is a contract template in the contract template library that matches the business requirement information of the intelligent contract for grade management in the education business scenario. In the case that there is no contract template in the contract template library that matches the business requirement information of the intelligent contract for grade management in the education business scenario, the large language model LLM20 is called based on the business requirement information, the business requirement information is used as the input of the LLM, and the intelligent contract for grade management in the education business scenario returned by the LLM20 is obtained, and the intelligent contract for grade management in the education business scenario is returned to the user terminal 11 through the proxy node 12.

[0153] Among them, in the case that there is a contract template in the contract template library that matches the business requirement information of the intelligent contract for grade management in the education business scenario, refer to the following Figure 6In the provided embodiments, the component instances selected by the user are filled into the contract template. The smart contract for grade management in the education business scenario will be returned to the user terminal 11 through the proxy node 12. The embodiments of the present application will not be described in detail here.

[0154] In a possible implementation, the proxy node 12, the server 13, and the contract template library can be deployed in the same device, or can be deployed in different devices. It is understandable that when the proxy node 12, the server 13, and the contract template library are deployed in different devices, it may not be the case that the proxy node 12, the server 13, and the contract template library are all deployed in one device. For example, the proxy node 12 and the server 13 are deployed in one device, and the contract template library is deployed in another device; when the proxy node 12, the server 13, and the contract template library are deployed in different devices, it can also be that the proxy node 12, the server 13, and the contract template library are respectively deployed in different devices. The embodiments of the present application do not limit this.

[0155] It should be noted that Figure 1 These are only exemplary drawings and do not constitute a limitation on the smart contract generation method provided by the embodiments of the present application. In actual application scenarios, the smart contract generation method can be applied to other business scenarios, such as financial business scenarios, medical business scenarios, etc. And Figure 1 The naming and grouping of the smart contract generation system 10 are illustrative and are only a logical function grouping. In actual implementation, there can be other grouping methods. For example, the smart contract generation system 10 can also be divided into a code resource management module, a business requirement analysis module, a code customization generation module, and a contract quality verification module. Specifically, another division example can be referred to in the Figure 23 corresponding example. In addition, the smart contract generation system 10 can also be named a smart contract coding tool, and this smart contract coding tool can include modules different from Figure 1 those shown. This smart contract coding tool can refer to the Figure 3 corresponding embodiments. The embodiments of the present application will not be described in detail here.

[0156] Based on Figure 1 the application scenario shown, Figure 2 The flowchart of the smart contract generation method provided by the present application is shown. The method may include:

[0157] Step S210, obtaining the business requirement information of the target business scenario.

[0158] Step S220, determining whether there is a contract template in the contract template library that matches the business requirement information.

[0159] Step S230, when the contract template library does not include a contract template that matches the business requirement information, based on the business requirement information, call the LLM to generate a smart contract for the target business scenario.

[0160] Step S240, when the contract template library includes a contract template that matches the business requirement information, fill the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario, call the LLM to perform quality verification on the contract instance for the target business scenario, and generate a smart contract for the target business scenario.

[0161] Based on Figure 2 The method shown above, by obtaining the business requirement information of the target business scenario, when the contract template library does not include a contract template that matches the business requirement information, taking the business requirement information as the input of the LLM to generate a smart contract for the target business scenario, can quickly realize the generation of the smart contract. At the same time, taking the business requirement information as the input of the LLM, through the LLM to perform requirement parsing based on the business requirement information, perform code generation based on the requirement parsing result, and perform quality verification on the generated contract instance to form a smart contract for the target business scenario, reducing the professional threshold of code writing. Further, in order to improve the writing efficiency of the smart contract, when there is a contract template that matches the business requirement information in the contract template library, after generating the contract template for the target business scenario through the LLM, filling the contract template to form a contract instance, and calling the LLM to perform quality verification on the contract instance for the target business scenario, associate the contract template for the target business scenario and the business requirement list for the target business scenario and write them into the contract template library. In this way, by increasing the quantity and variety of contract templates in the contract template library, providing more reusable contract templates, the writing difficulty of the smart contract can be reduced and the writing efficiency of the smart contract can be improved.

[0162] Optionally, the smart contract generation method provided by this application can be applied to the smart contract generation system 10, or can be applied to an electronic device with data processing capabilities.

[0163] Taking the application to the smart contract generation system 10 as an example, as Figure 3 shown, the smart contract generation system 10 may include a smart contract coding tool 110, and the smart contract coding tool 110 can be used to execute the smart contract generation method provided by this application. Among them. The smart contract coding tool 110 can be at least one of a platform, a system framework, and an application program that provides smart contract writing services, and the smart contract coding tool 110 can be deployed in a computing device, such as a server, a server cluster, etc.

[0164] In a possible implementation, a call interface for the LLM20 is set in the smart contract coding tool 110, and the smart contract coding tool 110 can call the LLM20 through the call interface to generate smart contract code.

[0165] In a possible implementation, as Figure 3 shown, during the interaction between the smart contract coding tool 110 and the LLM20, the interaction process between them is guided by the prompt information of the smart contract coding tool 110. Among them, the prompt information includes background input, role prompt, paradigm prompt, thought chain, and evaluation prompt.

[0166] Among them, a contract template library is set in the smart contract coding tool 110, which includes contract templates for pre-configured business scenarios.

[0167] Among them, the smart contract coding tool 110 may include multiple functional layers. As Figure 1 shown, the smart contract coding tool 110 may include a display layer 111, a proxy layer 112, a core layer 113, a code resource layer 114, and a storage layer 115. It should be understood that the naming of each functional layer in this application is not limited, and it can also be named other names without limitation.

[0168] Among them, the display layer 111 is used to provide interface interaction or user interface (i.e., UI interface) of the smart contract coding tool 110, so as to receive information input by the user through this interface and / or display the processing result of the smart contract coding tool 110 to the user. Specifically, function controls are set in the interface displayed by the display layer 111. When a function control in the display layer 111 is clicked, the display layer 111 transmits the operation information corresponding to the clicked function control to the core layer 113 in the server 13 through the proxy layer 112. The core layer 113 performs corresponding operations based on the operation information to obtain a processing result, and returns the processing result to the display layer 111 through the proxy layer 112, and the display layer 111 displays the processing result. It can be understood that the operation information includes smart contract generation, smart contract verification, etc., and the processing result can be a contract instance, smart contract code, etc.

[0169] The proxy layer 112 is used to reverse proxy the business services provided by the smart contract coding tool 110, transmit the information input by the user received by the display layer 111 to the core layer 113, and transmit the processing result of the core layer 113 to the display layer 111 for display. In some embodiments, the proxy layer 112 may use ngnix to reverse proxy the various business services of the core layer 113.

[0170] The core layer 113 is used to provide business services for the smart contract coding tool 110, and form the processing result of the smart contract coding tool 110 based on the information input by the user received by the presentation layer. In a possible implementation, as Figure 3 shown, the business services provided in the core layer 113 include code resource management service, application requirement analysis service, code customization generation service, and contract quality verification service.

[0171] Among them, the code resource management service is used to access the code resource layer 114 and provide read and write services for code resources. The read and write services for code resources can be writing data to the code resource layer 114 and reading data from the code resource layer 114, etc.

[0172] The application requirement analysis service is used to provide requirement information analysis services, such as obtaining business requirement information, or calling the LLM20 to use the business requirement information as the input of the LLM20 to obtain a business requirement list for indicating the requirements information of the smart contract to be generated.

[0173] The code customization generation service is used to provide a service for generating smart contract code. For example, calling the LLM20 and using the business requirement information as the input of the LLM20 to obtain a contract instance corresponding to the business requirement list.

[0174] The contract quality verification service is used to provide a contract code verification service. For example, performing quality verification on the generated contract instance based on the business requirement list, and correcting the contract instance based on the quality verification result to obtain a smart contract in the target business scenario.

[0175] Among them, the code resource layer 114 is used to store code resources and provide data support for the core layer 113. Among them, the code resources include contract templates for different business scenarios, business requirement lists corresponding to each contract template, and component instances for contract template calls. Specifically, as Figure 3 shown, the code resource layer 114 includes a contract template library and a contract component library. Among them, the contract template library stores multiple business contract templates and business requirement lists corresponding to each business contract template. The contract component library includes component instances and component decision models.

[0176] The storage layer 115 is used to manage the code resources of the smart contract coding tool 110 and other generated data through data storage technologies. Among them, the data storage technologies include but are not limited to relational database management software (relational database management system, mysql), remote dictionary service (remote dictionary server, redis), etc.

[0177] In a possible implementation, the presentation layer 111, the proxy layer 112, the core layer 113, the code resource layer 114, and the storage layer 115 can be deployed in the same device. For example, the presentation layer 111, the proxy layer 112, the core layer 113, the code resource layer 114, and the storage layer 115 are deployed in a server, a personal computer, or other computer devices.

[0178] In another possible implementation, the presentation layer 111, the proxy layer 112, the core layer 113, the code resource layer 114, and the storage layer 115 can be deployed in different devices. For example, the presentation layer 111 is deployed in a display device, and the proxy layer 112, the core layer 113, the code resource layer 114, and the storage layer 115 are deployed in a computing device. The display device and the computing device are connected through a network. Among them, the display device includes but is not limited to computer terminals and mobile phone terminals, such as personal computers, laptops, smart phones, etc.; the computing device includes but is not limited to servers, cloud servers, server clusters, etc.

[0179] In another possible implementation, the smart contract coding tool 110 includes a user side 11 and a server side 13. Among them, the presentation layer 111 is deployed in the user side 11, and the core layer 113, the code resource layer 114, and the storage layer 115 are deployed in the server side 13. The user side 11 communicates with the server side 13 through a network.

[0180] In a possible implementation, in order to facilitate the storage and query of code resources, when storing component instances and contract templates in the code resource layer 114, ddd is used to divide the code resources according to business scenarios, and the component instances and contract templates are stored in a hierarchical storage structure. Exemplarily, as Figure 4 shown, Figure 4 is a schematic diagram of the storage structure of the code resource layer 114 provided by an embodiment of the present application. The shown code resource layer 114 from top to bottom is successively a scenario layer, a business process layer, a general operation layer, an algorithm tool layer, a basic operation layer, and a data structure layer.

[0181] Among them, the scenario layer is a virtual layer for dividing the business scenarios of business resources. The business process layer serves as a contract template library for storing contract templates under various business scenarios and the business requirement lists corresponding to the contract templates. The general operation layer, the algorithm tool layer, the basic operation layer, and the data structure layer constitute a contract component library. The general operation layer, the algorithm tool layer, the basic operation layer, and the data structure layer respectively serve as component sub-layers in the contract component library. The general operation layer, the algorithm tool layer, the basic operation layer, and the data structure layer are used to store component instances called by the contract templates under various business scenarios.

[0182] Among them, the general operation layer, the algorithm tool layer, the basic operation layer, and the data structure layer store component instances of different component types. For example, the general operation layer, the algorithm tool layer, the basic operation layer, and the data structure layer store component instances of general operation components, algorithm tool components, basic operation components, and data structure components, respectively.

[0183] Among them, the general operation components include, but are not limited to, component instances for data verification, component instances for signature registration, component instances for data uploading to the chain, etc.; the algorithm tool components include, but are not limited to, component instances for one-way hashing, component instances for symmetric encryption, and component instances for digital signatures; the basic operation components include, but are not limited to, component instances for data operation, component instances for integer conversion, component instances for character operation, component instances for data operation, and component instances for address operation; the data structure components include, but are not limited to, component instances for heap, component instances for stack, component instances for queue, and component instances for set, etc.

[0184] Exemplarily, taking the basic operation layer as an example, the basic operation layer stores component instances for data operation, component instances for integer conversion, component instances for character operation, component instances for data operation, and component instances for address operation.

[0185] To better illustrate the application scenario of the smart contract generation method in the smart contract writing scenario, the following takes Figure 3 each layer in the provided smart contract coding tool 110, taking the display layer 111, the proxy layer 112, the core layer 113, the code resource layer 114, and the storage layer 115 deployed on different ends as an example, and combining Figure 5 and Figure 6 to illustrate the interaction process of each layer in the smart contract coding tool 110 in the smart contract writing scenario.

[0186] As Figure 5 shown, Figure 5 is a schematic diagram of the processing process in the smart contract writing scenario provided by an embodiment of the present application. This processing process is applicable to the case where the contract template library does not include a contract template matching the business requirement information. This processing process may include:

[0187] Step S510: In response to the user's operation on the display layer 111, the core layer 113 obtains the business requirement information of the target business scenario.

[0188] Among them, the business requirement information is used to indicate the requirements for generating a smart contract in the target business scenario. Among them, the requirements may include, but are not limited to, development language, deployment platform, business type, and implemented functions. The target business scenario may include, but is not limited to, medical scenarios, educational scenarios, and financial scenarios.

[0189] Among them, the development language is used to indicate which programming language is used to implement the smart contract. The deployment platform is used to indicate the running platform of the smart contract, etc. For example, mobile terminals, computer terminals, web pages, cloud platforms, blockchain platforms, etc. The business type is used to indicate the specific process that the smart contract needs to execute, and the implemented function is used to indicate the functions that the smart contract needs to implement.

[0190] It can be understood that the above basic business information is only an illustrative description. In actual application scenarios, there may be more or fewer basic business information. Exemplarily, taking the business development scenario as the development of a smart contract, in the development of a smart contract, the basic business information includes but is not limited to the deployment platform, development language, involved roles, implemented functions, role permissions, data storage, business type, security protection, data protection, contract call, external system interaction, etc.

[0191] Among them, the deployment platform is used to indicate the blockchain platform on which the smart contract needs to be deployed. The involved roles are used to indicate the roles included in the smart contract, where the roles include administrators, participants, certificate issuing authorities, etc. Role permissions are used to indicate the relationship between the roles involved in the smart contract and the usage permissions of each function, such as data writing permissions, viewing permissions, etc. Data storage is used to indicate what the core data that the smart contract needs to store includes. Security protection is for the data protection method in the smart contract, such as data encryption algorithms. Data protection is used to indicate the protection method of sensitive data in the smart contract, such as sensitive data desensitization, sensitive data encrypted storage, etc. Contract call is used to indicate whether cross-contract calls are made when the smart contract is applied, and when cross-contract calls are made, the call methods of other smart contracts. External system interaction is used to indicate whether the smart contract interacts with external systems. Among them, the external system is understood as a system outside the blockchain platform on which the smart contract is deployed, such as other blockchain platforms, databases, etc.

[0192] In a possible implementation manner, the business requirement information can be input through an interface view.

[0193] For example, the presentation layer 111 displays an interface view of the smart contract coding tool 110. In response to a smart contract writing operation input based on the interface view of the smart contract coding tool 110, business requirement information is obtained, and the smart contract writing operation and the business requirement information are transmitted to the core layer 113 through the proxy layer 112. For another example, when the smart contract method provided in this application is executed by a computing device, a function module for inputting business requirement information is set in the interface view of the smart contract coding tool 110. When a developer clicks on the function module for inputting business requirement information, the presentation layer 111 in the smart contract coding tool 110 outputs a business requirement information input page in response to the click operation of the function module for inputting business requirement information. The developer inputs data content based on the business requirement information input page view. The presentation layer 111 obtains the data content input based on the business requirement information input page view, and transmits the data content to the core layer 113 through the proxy layer 112. The core layer 113 forms business requirement information based on the received data content.

[0194] In yet another possible implementation, the business requirement information may be sent by other devices. For example, when the smart contract method provided in this application is executed by a computing device, the business requirement information sent by other devices to the computing device. Among them, the other devices may be computing devices other than those executing the smart contract method, or may also be terminal devices.

[0195] In yet another possible implementation, the business requirement information may also be obtained through data recognition. For example, in front-end development, the presentation layer 111 obtains interface interaction view data, and transmits the interface interaction view data to the core layer 113 through the proxy layer 112. The core layer 113 performs image recognition on the interface interaction view data to obtain business requirement information.

[0196] In yet another possible implementation, the business requirement information may also be extracted from a requirements question list. Among them, the requirements question list includes multiple requirement items for implementing smart contract development, such as deployment platforms, development languages, implemented functions, etc. When the smart contract method provided in this application is executed by a computing device, the computing device may obtain business requirement information by extracting the data content of each requirement item in the requirements question list.

[0197] Among them, the requirement problem list can be sent by an external device or filled and generated based on the data content input by the developer. Taking the case of filling and generating a requirement problem list based on the data content input by the developer as an example, when the intelligent contract method provided in this application is executed by a computing device, the computing device can display a pre-constructed requirement problem list template in the interface view, fill the data content input by the developer based on the requirement problem list template view into the requirement problem list template to form a requirement problem list, and the computing device obtains business requirement information by extracting the data content of each requirement item in the requirement problem list. The specific implementation process can be referred to below Figure 9 For the method for obtaining business requirement information based on the requirement problem list provided, the embodiments of this application will not be described in detail here.

[0198] Step S520, the core layer 113 determines whether there is a contract template in the contract template library that matches the business requirement information.

[0199] Among them, the contract template library includes contract templates for pre-configured business scenarios and the business requirement list corresponding to the contract templates. Among them, the business requirement list is used to indicate the requirements implemented by the contract template.

[0200] In a possible implementation manner, the requirements indicated by the business requirement information can be compared with the business requirement list of the contract templates in the contract template library, and based on the comparison result, it is determined whether there is a contract template in the contract template library that matches the business requirement information.

[0201] Among them, when there is a business requirement list in the contract template that includes all the requirements indicated by the business requirement information, it is determined that there is a contract template in the contract template library that matches the business requirement information, and the contract template corresponding to the business requirement list that includes all the requirements indicated by the business requirement information is determined as the contract template that matches the business requirement information.

[0202] Among them, when there is a business requirement list in the contract template that does not include all the requirements indicated by the business requirement information, it is determined that there is no contract template in the contract template library that matches the business requirement information.

[0203] In an alternative implementation, the contract template library can be queried according to the target business scenario to obtain the contract template under the target business scenario included in the contract template library. The requirements indicated by the business requirement list of the contract template under the target business scenario included in the contract template library are compared with the requirements indicated by the business requirement information. In the case where there is a business requirement list in the contract template that does not include all the requirements indicated by the business requirement information, it is determined that the contract template library does not include a contract template that matches the business requirement information. In the case where there is a business requirement list in the contract template that includes all the requirements indicated by the business requirement information, it is determined that the contract template library includes a contract template that matches the business requirement information. The contract template corresponding to the business requirement list that includes all the requirements indicated by the business requirement information is determined as the contract template that matches the business requirement information.

[0204] For example, taking the existence of contract template A, contract template B, and contract template C in the contract template library as an example, where the requirements indicated by the business requirement list of contract template A are: development language XX1, deployment platform XX2, business type XX5, and implemented function SS2, and the target business scenario is the financial scenario; the requirements indicated by the business requirement list of contract template B are: development language XX1, deployment platform XX2, business type XX5, implemented function SS2, and contract call XX3, and the target business scenario is the financial scenario; the requirements indicated by the business requirement list of contract template C are: development language SS1, deployment platform XX2, business type XX5, and implemented function SS2, and the target business scenario is the financial scenario. When the requirements indicated by the business requirement list are development language XX1, deployment platform XX2, contract call XX3, and the target business scenario is the financial scenario, the business requirement list of contract template B includes all the requirements indicated by the business requirement information, so contract template B is determined as the contract template that matches the business requirement information. When the requirements indicated by the business requirement list are development language SS1, deployment platform SS2, contract call XX3, and the target business scenario is the financial scenario, since the requirements indicated by the respective business requirement lists of contract template A, contract template B, and contract template C do not all include all the requirements indicated by the business requirement information, it is determined that the contract template library does not include a contract template that matches the business requirement information.

[0205] Optionally, the core layer 113 performs an intelligent contract writing operation, accesses the code resource layer 114, queries the contract template library in the code resource layer 114 based on the business requirement information, and determines whether the contract template library includes a contract template that matches the business requirement information. In the case where the contract template library does not include a contract template that matches the business requirement information, S530 is executed.

[0206] Step S530: The core layer 113 uses the call interface of the LLM, takes the business requirement information as the input of the LLM, calls the LLM, performs requirement parsing based on the business requirement information, generates code based on the requirement parsing result, performs quality verification on the generated contract instance, forms an intelligent contract in the target business scenario, and returns the intelligent contract to the presentation layer 111 through the proxy layer 112.

[0207] Among them, the quality verification can be to detect vulnerabilities in the generated intelligent contract. For example, it can detect whether there are security vulnerabilities in the generated intelligent contract, such as detecting whether there are logical vulnerabilities in the generated intelligent contract. The quality verification can also be to generate test cases and test the generated intelligent contract based on the generated test cases. The quality verification can also be to detect whether the generated intelligent contract meets the business requirement information. The quality verification can also be to detect vulnerabilities in the generated intelligent contract and detect whether the generated intelligent contract meets the business requirement information. Specifically, it can refer to the Figure 16 processing flow of the quality verification of the intelligent contract provided below. The embodiments of the present application will not expand the description here.

[0208] Among them, the requirement parsing result can be a business requirement list.

[0209] Among them, the LLM is trained based on a deep neural network model. In one example, the LLM can be trained based on a generative deep neural network model with a transformer structure. For example, the GT4 model, chatgpt4, etc.

[0210] In a possible implementation, when the contract template library does not include a contract template that matches the business requirement information, based on the business requirement information, the LLM is called, the business requirement information is taken as the input of the LLM, the LLM performs requirement parsing based on the business requirement information, generates code based on the requirement parsing result, performs quality verification on the generated contract instance, and forms an intelligent contract in the target business scenario.

[0211] In one example, to ensure the accuracy of the output result of the LLM, the LLM is guided to generate an intelligent contract through a prompt message. Specifically, when calling the LLM to generate an intelligent contract, a prompt message for the LLM is formed based on the business requirement information, the prompt message is input into the LLM, the LLM performs requirement parsing based on the business requirement information, generates code based on the requirement parsing result, performs quality verification on the generated contract instance, and forms an intelligent contract in the target business scenario.

[0212] Among them, the prompt information includes role prompts, background inputs, task instructions, and paradigm prompts. For example, taking business requirement information as the background input of the prompt information, taking developers as the role prompt, performing requirement analysis based on the business requirement information, generating code based on the requirement analysis results, performing quality verification on the generated contract instances, and forming an intelligent contract in the target business scenario as the task instruction, and taking the contract template in the contract template library that matches the target business scenario as the paradigm prompt, to form a prompt information such as Figure 7 shown.

[0213] Among them, to ensure the generation efficiency of the intelligent contract, a prompt information template can be pre-constructed, and the prompt information is generated based on the prompt information template. The prompt information template includes role prompts, background inputs, task instructions, and paradigm prompts. When based on the prompt information template, at least one of the role prompt, background input, task instruction, and paradigm prompt is filled into the prompt information template to form the prompt information. For example, in the case that the contract template library does not include a contract template that matches the business requirement information, taking the business requirement information as the background input of the prompt information template, and taking the contract template in the contract template library that matches the target business scenario as the paradigm prompt, to form a prompt information such as Figure 7 shown.

[0214] In one example, to further improve the accuracy of the LLM output result, the processing stage of the intelligent contract generation by the large language model can be divided into multiple sub-processing stages in advance through the chain of thought. Each sub-processing stage corresponds to prompt information, and the LLM is guided to execute the processing stage of the intelligent contract generation one by one through the prompt information of each sub-processing stage, to generate an intelligent contract in the target business scenario.

[0215] Exemplarily, the processing stage of the intelligent contract generation is divided into a requirement analysis sub-processing stage, a contract generation sub-processing stage, and a contract quality verification sub-processing stage. Among them, as Figure 8As shown, in the requirement analysis sub - processing stage, the prompt information of the requirement analysis sub - processing stage takes the business requirement information as the background input, the requirement analyst as the role prompt, and conducts requirement analysis based on the business requirement information. Imitating the business requirement list sample provided by the paradigm prompt, generating a business requirement list as the task instruction, taking the business requirement list corresponding to the contract template that matches the business requirement scenario in the contract template library as the paradigm prompt, the LLM conducts requirement analysis according to the prompt information of the requirement analysis sub - processing stage, forms a business requirement list corresponding to the business requirement information, and returns the business requirement list. In the contract generation sub - processing stage, taking the business requirement list returned by the requirement analysis sub - processing stage as the background input, taking the developer as the role prompt, taking code generation based on the business requirement list as the role prompt, and taking the contract template that matches the target business scenario in the contract template library as the paradigm prompt, forming the prompt information of the contract generation sub - processing stage, guiding the LLM to execute code generation, and forming a contract instance. In the contract quality verification sub - stage, taking the generated contract instance as the background input, taking the pre - stored vulnerability instances as the paradigm prompt, taking the vulnerability inspection tool as the role prompt, and taking quality verification of the generated contract instance to form a smart contract in the target business scenario as the task instruction, forming the prompt information of the contract quality verification sub - stage, guiding the LLM to conduct quality verification on the generated contract instance, and forming a smart contract in the target business scenario.

[0216] In another example, to further improve the accuracy of the LLM output result and enhance the interactivity with the user, in the case that the contract template library does not include a contract template that matches the business requirement information, based on the business requirement information, calling the LLM to generate a smart contract in the target business scenario includes a requirement analysis processing stage, a contract generation processing stage, and a contract quality verification processing stage. For each processing stage, generate the prompt information of that processing stage, input the prompt information of each processing stage into the LLM, guide the LLM to process each processing stage, and output the processing result of each processing stage. Specifically, reference can be made to the Figure 11 smart contract generation process based on the large - language model provided, which will not be elaborated in this embodiment of the present application.

[0217] As Figure 6 shown, Figure 6 is another schematic diagram of the processing process in the smart contract writing scenario provided by the embodiment of the present application. This processing process is applicable to the case where the contract template library includes a contract template that matches the business requirement information. In Figure 6 the shown processing process, after S520, in the case that the contract template library includes a contract template that matches the business requirement information, the smart contract coding tool 110 executes Figure 6In step S540, when there is a contract template in the contract template library that matches the business requirement information, the core layer 113 fills the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario, and calls the LLM to perform quality verification on the contract instance of the target business scenario to generate a smart contract for the target business scenario.

[0218] Specifically, as Figure 6 shown, step S540 may include:

[0219] Step S5401: The core layer 113 returns the contract template that matches the business requirement information to the presentation layer 111.

[0220] Step S5402: The presentation layer 111 displays the contract template that matches the business requirement information in the interface view. In response to the code editing operation input by the user, it outputs a code editing page view and passes the code editing operation to the core layer 113 through the proxy layer 112.

[0221] Step S5403: The core layer 113 accesses the code resource layer 114 and returns the component instances in the contract component library that can be called by the contract template that matches the business requirement information to the presentation layer 111.

[0222] Step S5404: The presentation layer 111 displays the component instances in the contract component library that can be called by the contract template that matches the business requirement information in the code editing page view. In response to the component selection operation input based on the code editing page view, it determines the selected component instances and passes the selected component instances to the core layer 113 through the proxy layer 112.

[0223] In a possible implementation, a component selection control can be provided in the presentation layer 111. The user clicks the component selection control, and a code editing page is output in the presentation layer 111. The component instances provided in the contract component library are displayed in the code editing page. In response to the component selection operation input by the user based on the code editing page view, the contract components selected by the user are determined, and the component instances selected by the user are filled into the contract template to obtain a contract instance for the target business scenario.

[0224] In another possible implementation, considering that when the number of component instances provided in the contract component library is large, it will increase the difficulty of selecting component instances and reduce the generation efficiency of smart contracts. Based on this, a component selection control is provided in the presentation layer 111. The user clicks the component selection control, and a code editing page is output in the presentation layer 111. The candidate component instances that match the target business scenario are displayed in the code editing page. In response to the component selection operation input by the user based on the candidate component instances, the component instances selected by the user are determined, and the component instances selected by the user are filled into the contract template to obtain a contract instance for the target business scenario.

[0225] In another possible implementation, considering that when the number of component instances provided in the contract component library is large, it will increase the difficulty of selecting component instances, reduce the generation efficiency of smart contracts, and the knowledge reserve requirements for the underlying logic of the blockchain and cryptographic algorithms are relatively high when only selecting component instances through component selection operations. In the case where the user has a low or insufficient knowledge reserve in the underlying logic of the blockchain and cryptographic algorithms, it will increase the generation difficulty of smart contracts. Based on this, in order to improve the generation efficiency of smart contracts, reduce the generation difficulty of smart contracts, and reduce the knowledge reserve requirements of users in the underlying logic of the blockchain and cryptographic algorithms, a component decision model can be established in advance based on the description information of component instances in the contract component library. A component selection control is provided on the presentation layer 111. When the user clicks the component selection control, a code editing page is output on the presentation layer 111. A component information input text box is provided in the code editing page. The component information input by the user based on the component information input text box provided in the code editing page is obtained, and the component decision model is called. The component information is input into the component decision model. The component decision model obtains candidate component instances matching the component information from the contract component library, and the candidate component instances matching the component information are displayed in the code editing page view. In response to the component selection operation input by the user based on the candidate component instances, the component instance selected by the user is determined; the component instance selected by the user is filled into the contract template to obtain a contract instance for the target business scenario.

[0226] Among them, the description information of the component instance includes but is not limited to the input, output, functions implemented, business scenarios used, and advantages and disadvantages of the component instance, etc. The component decision model can be a decision tree of component instances established according to the description information of component instances. It can be understood that after obtaining the component information input by the user, the component decision model makes a prediction based on the component information and selects candidate component instances from the contract component library whose description information matches the component information.

[0227] Among them, the candidate component instances whose description information matches the component information can be component instances whose similarity between the description information and the component information is greater than or equal to a preset threshold, or component instances whose distance between the description information and the component information is greater than or equal to a preset distance threshold. The candidate component instances whose description information matches the component information can also be component instances whose probability of being a candidate component instance is greater than or equal to a preset probability threshold. Among them, the probability of a component instance being a candidate component instance can be obtained through the similarity between the description information and the component information, or through the distance between the description information and the component information.

[0228] Step S5405: The core layer 113 fills the selected component instances into the contract template that matches the business requirement information to form a contract instance. Through the call interface of the LLM, the LLM is called to perform quality verification on the generated contract instance, forming an intelligent contract in the target business scenario, and the intelligent contract is returned to the presentation layer 111 through the proxy layer 112.

[0229] Among them, the quality verification can be to detect vulnerabilities in the generated contract instance, such as detecting whether there are security vulnerabilities in the generated contract instance, such as detecting whether there are logical vulnerabilities in the generated contract instance. The quality verification can also be to generate test cases and test the generated contract instance based on the generated test cases. The quality verification can also be to detect whether the generated contract instance meets the business requirement information. The quality verification can also be to detect vulnerabilities in the generated contract instance and detect whether the generated contract instance meets the business requirement information. Specifically, reference can be made to the following Figure 16 processing flow of the quality verification of the provided contract instance, which is not elaborated in this embodiment of the present application.

[0230] The intelligent contract generation method provided by the embodiment of the present application obtains the business requirement information of the target business scenario through the core layer 113 of the intelligent contract coding tool 110. When the contract template library does not include a contract template that matches the business requirement information, the business requirement information is used as the input of the LLM to generate an intelligent contract in the target business scenario, which can quickly realize the generation of the intelligent contract. At the same time, the core layer 113 of the intelligent contract coding tool 110 uses the business requirement information as the input of the LLM, performs requirement parsing based on the business requirement information through the LLM, generates code based on the requirement parsing result, performs quality verification on the generated contract instance, and forms an intelligent contract in the target business scenario, reducing the professional threshold of code writing and further improving the writing efficiency of the intelligent contract.

[0231] In a possible implementation, considering that there are differences in data processing logic, secure data protection, permission management, etc. between smart contract generation and other business code development, in order to ensure the reasonableness of the business requirement information and avoid users missing requirements, before obtaining the business requirement information of the target business scenario, a requirement question list template is pre-constructed by the smart contract coding tool 110. When the smart contract coding tool 110 executes the above step S210, the pre-constructed requirement question list template is displayed in the interface view of the display layer 111. The smart contract coding tool 110 obtains the data content input by the user based on the requirement question list template view, fills the obtained data content into the requirement question list template to form a filled requirement question list, and obtains the business requirement information by extracting the data content of each requirement item in the filled requirement question list. In this way, the requirement question list template guides the user to input business requirement information item by item, provides more accurate background input for the LLM, and thus improves the accuracy of the generated smart contract.

[0232] Among them, the requirement question list template includes, but is not limited to, requirements in aspects such as language and platform, role and function, data and process, data and security, etc. Exemplarily, as Figure 9 shown, Figure 9 is a schematic diagram of the requirement question list template of the embodiment of the present application. It can be understood that Figure 9 the provided requirement question list template is only for exemplary illustration and does not constitute a limitation on the smart contract generation method provided by the embodiment of the present application. The requirement items in the requirement question list can be adjusted according to the actual application scenario.

[0233] Specifically, as Figure 10 shown, Figure 10 is a schematic flowchart of the method for obtaining business requirement information based on a requirement question list provided by the embodiment of the present application. The method for obtaining business requirement information based on a requirement question list shown includes steps S211 to S213:

[0234] Step S211, in response to the contract customization operation, display the pre-constructed requirement question list.

[0235] In a possible implementation, a function control for providing the contract customization operation is set in the display layer 111 of the smart contract coding tool 110. The user clicks the function control for the contract customization operation, and in response to the click operation of the function control for the contract customization operation, the contract customization operation is triggered and responded to, and the pre-constructed requirement question list as Figure 9 shown is displayed in the interface view of the display layer 111.

[0236] Step S212: In response to an input operation based on the requirements issue list view, write the data content corresponding to the input operation into the requirements items of the requirements issue list, forming a filled requirements issue list.

[0237] Step S213: Obtain business requirements information from the filled requirements issue list.

[0238] In a possible implementation, the filled requirements issue list can be used as the business requirements information.

[0239] In another possible implementation, data extraction can be performed on the filled requirements issue list to obtain business requirements information. For example, extract the data content corresponding to each requirements item from the filled requirements issue list to obtain the business requirements information.

[0240] Based on this embodiment, before obtaining the business requirements information of the target business scenario, the smart contract coding tool 110 pre-constructs a requirements issue list. After responding to the smart contract customization operation, the pre-constructed requirements issue list is displayed in the interface view of the display layer 111 of the smart contract coding tool 110. The smart contract coding tool 110 obtains the data content input by the user based on the requirements issue list template view, fills the obtained data content into the requirements issue list, forming a filled requirements issue list, and extracts the data content of each requirements item in the requirements issue list through the core layer 113 of the smart contract coding tool 110 to obtain the business requirements information. In this way, by guiding the user to input business requirements information item by item through the requirements issue list, more accurate background input is provided for the LLM, thereby improving the accuracy of the generated smart contract.

[0241] In a possible implementation, after obtaining the business requirements information, the smart contract coding tool 110 uses the business requirements information as the input of the LLM according to the above step S220 to generate a smart contract in the target business scenario.

[0242] Among them, to ensure the accuracy of the output result of the LLM, the smart contract coding tool 110 divides the execution of the above step S220 into multiple processing stages, and guides the LLM to execute each processing stage one by one to generate a smart contract in the target business scenario. In this way, to ensure the successful generation of the smart contract and avoid omission of key information or steps.

[0243] Specifically, as Figure 11 shown, Figure 11 is the intention of the smart contract generation process based on the large language model provided by the embodiment of the present application. The shown smart contract generation process based on the large language model includes steps S221 - S223:

[0244] Step S221: Use the business requirement information as the input of the LLM, and call the LLM to generate a business requirement list for the target business scenario.

[0245] In a possible implementation, to further improve the accuracy of the generated smart contract and enhance the interactivity with the user at the same time, after obtaining the business requirement list output by the LLM, the smart contract coding tool 110 displays the business requirement list output by the LLM to the user through the display layer 111 of the smart contract coding tool 110. In response to the user's modification operation, the core layer 113 of the smart contract coding tool 110 modifies the business requirement list output by the LLM, and re-enters the modified business requirement list and the business requirement information into the LLM to obtain a new business requirement list. Repeat the above process until a business requirement list confirmed by the user is obtained, and then execute step S222.

[0246] Understandably, after displaying the business requirement list output by the LLM to the user, step S222 is executed in response to the user's confirmation operation.

[0247] Among them, in response to the user's modification operation, the core layer 113 of the smart contract coding tool 110 modifies the business requirement list output by the LLM based on the modification operation to form a modified business requirement list, and re-enters the modified business requirement list and the business requirement information into the LLM to obtain a new business requirement list.

[0248] Step S222: Use the business requirement list as the input of the LLM, and call the LLM to generate a contract instance for the target business scenario.

[0249] In a possible implementation, to further improve the accuracy of the generated smart contract and enhance the interactivity with the user at the same time, after obtaining the contract instance of the target business scenario output by the LLM, the smart contract coding tool 110 displays the contract instance of the target business scenario output by the LLM to the user through the display layer 111 of the smart contract coding tool 110. In response to the user's modification operation, the core layer 113 of the smart contract coding tool 110 modifies the contract instance output by the LLM, and re-enters the modified contract instance and the business requirement list into the LLM to obtain a new contract instance. Repeat the above process until a contract instance confirmed by the user is obtained, and then execute step S223.

[0250] Specifically, after the core layer 113 generates a contract instance, it returns the contract instance to the presentation layer 111 through the proxy layer 112. The presentation layer 111 displays the contract instance in the interface view and, in response to an input operation based on the interface view, passes the input operation to the core layer 113 through the proxy layer 112, and the core layer 113 continues to process based on the input operation.

[0251] Among them, the input operation includes a confirmation operation and a modification operation. It can be understood that when the input operation is a confirmation operation, the core layer 113 performs quality verification on the contract instance based on the business requirement list, corrects the contract instance based on the quality verification result to obtain an intelligent contract, and returns the intelligent contract to the presentation layer 111 through the proxy layer 112. When the input operation is a modification operation, the core layer 113 modifies the contract instance based on the modification operation to form a new contract instance, and returns the new contract instance to the presentation layer 111 through the proxy layer 112.

[0252] Among them, when there is no contract template matching the business requirement information in the contract template library and the input operation is a modification operation, the core layer 113 forms new business requirement information based on the modification operation, calls the LLM through the call interface of the LLM, uses the new business requirement information as the input of the LLM, and obtains a new contract instance returned by the LLM.

[0253] Among them, when there is a contract template matching the business requirement information in the contract template library and the input operation is a modification operation, the core layer 113 selects a new component instance based on the modification operation, fills the new component instance into the contract template matching the business requirement information to form a new contract instance.

[0254] It can be understood that when presenting the contract instance of the target business scenario output by the LLM to the user and in response to the user's confirmation operation, step S223 is executed.

[0255] In another possible implementation, the core layer 113 of the intelligent contract coding tool 110 uses the business requirement list as the input of the LLM, calls the LLM to generate a contract, obtains a contract template of the target business scenario output by the LLM, determines the component instances selected by the user, and fills the component instances selected by the user into the contract template to obtain a contract instance of the target business scenario.

[0256] Among them, the component instances selected by the user can be determined according to the above steps S5402 - S5404, and the embodiments of the present application will not elaborate here.

[0257] Among them, when the core layer 113 of the smart contract coding tool 110 uses the business requirement list as the input of the LLM, calls the LLM to generate a contract, and obtains the contract template of the target business scenario output by the LLM, in order to further improve the accuracy of the generated smart contract and at the same time improve the interactivity with the user, when the contract template of the target business scenario output by the LLM is obtained, the contract template of the target business scenario output by the LLM is displayed to the user through the display layer 111 of the smart contract coding tool 110. In response to the user's modification operation, the contract template output by the LLM is modified through the core layer 113 of the smart contract coding tool 110, and the modified contract template and the business requirement list are re-input into the LLM to obtain a new contract template. The above processing process is repeated until the contract template confirmed by the user is obtained. Then, the component instances selected by the user are determined, and the component instances selected by the user are filled into the contract template to obtain the contract instance of the target business scenario.

[0258] Understandably, the smart contract coding tool 110 displays the contract template of the target business scenario output by the LLM to the user. In response to the user's confirmation operation, the core layer 113 of the smart contract coding tool 110 determines the component instances selected by the user, and fills the component instances selected by the user into the contract template to obtain the contract instance of the target business scenario.

[0259] Step S223, call the LLM to perform quality verification on the contract instance of the target business scenario to generate the smart contract under the target business scenario.

[0260] In a possible implementation, the quality verification includes security vulnerability detection and logic vulnerability detection.

[0261] Among them, the security vulnerability detection is used to detect whether there are vulnerabilities in the contract instance, and in the case where there are vulnerabilities in the contract instance, locate the vulnerability positions in the contract instance, and form security modification suggestions for the contract instance based on the detected vulnerabilities to generate security vulnerability detection results; the logic vulnerability detection is used to detect whether the contract instance meets the requirements, and in the case where the contract instance does not meet the requirements, determine the missing requirements and the logic modification suggestions of the contract instance to generate logic vulnerability detection results.

[0262] Among them, the security vulnerability detection result is used to indicate whether there are vulnerabilities in the contract instance, and in the case where there are vulnerabilities in the contract instance, the vulnerability positions in the contract instance and the security modification suggestions for the contract instance.

[0263] Among them, the logic vulnerability detection result is used to indicate whether the contract instance meets the requirements, and in the case where the contract instance does not meet the requirements, the missing requirements of the contract instance and the logic modification suggestions for the contract instance.

[0264] In a possible implementation, the LLM performs a quality check on the contract instance of the target business scenario, modifies the contract instance according to the quality check result, and determines the modified contract instance as the smart contract under the target business scenario. The quality check result includes the security vulnerability detection result and the logic vulnerability detection result.

[0265] In another possible implementation, the core layer 113 of the smart contract coding tool 110 calls the LLM to perform a quality check on the contract instance of the target business scenario, obtains the quality check result output by the LLM, and displays the quality check result to the user through the display layer 111 of the smart contract coding tool 110. In response to the repair confirmation operation input by the user, the core layer 113 of the smart contract coding tool 110 inputs the quality check result and the contract instance into the LLM, and the LLM modifies the contract instance based on the quality check result to obtain the smart contract under the target business scenario output by the LLM.

[0266] Among them, when the LLM modifies the contract instance based on the quality check result, the large language model outputs the modified contract instance, and the smart contract coding tool 110 displays the modified contract instance to the user. In response to the contract confirmation operation of the user, the smart contract coding tool 110 determines the modified contract instance as the smart contract under the target business scenario.

[0267] Among them, when the LLM modifies the contract instance based on the quality check result, the large language model outputs the modified contract instance, and the smart contract coding tool 110 displays the modified contract instance to the user. In response to the contract modification operation of the user, the modification information of the modified contract instance is determined, and the modification information of the modified contract instance and the modified contract instance are re-input into the LLM. The LLM re-modifies the modified contract instance according to the modification information to form a new modified contract instance, and so on, until in response to the contract confirmation operation of the user, the modified contract instance is determined as the smart contract under the target business scenario.

[0268] In another possible implementation, the core layer 113 of the smart contract coding tool 110 calls the LLM to perform a quality check on the contract instance of the target business scenario, obtains the quality check result output by the LLM, and displays the quality check result to the user through the display layer 111 of the smart contract coding tool 110, so that the user can correct the contract instance of the target business scenario based on the quality check result. The smart contract coding tool 110 obtains the corrected contract instance input by the user and determines the corrected contract instance as the smart contract under the target business scenario.

[0269] In a possible implementation, when the above step S210 is divided into multiple processing stages, in order to further ensure the accuracy of the LLM output result and guide the LLM to execute each processing stage, the smart contract coding tool 110 divides step S210 into multiple processing stages. For each processing stage, the smart contract coding tool 110 generates prompt information corresponding to the processing stage, uses the prompt information of each processing stage as the input of the LLM, and guides the LLM to execute the processing stage according to the prompt information of the processing stage. Among them, the prompt information includes at least one of role prompt, background input, task instruction, and paradigm prompt.

[0270] Exemplarily, taking the processing stage as step S221 as an example, as Figure 12 shown, Figure 12 is a schematic diagram of the business requirement list generation process provided by an embodiment of the present application. The core layer 113 of the smart contract coding tool 110 obtains the data content input by the user, fills in the pre-constructed requirement question list with the data content input by the user to form a filled requirement question list, uses the filled requirement question list as business requirement information, uses the business requirement information as background input, uses "Please act as a smart contract requirement analyst, responsible for professionally helping users analyze and refine requirements and generate a smart contract business requirement list" as a role prompt, uses "Please sort out, analyze, and refine the requirements according to the above business requirement information, and generate a business requirement list with a unified format by referring to the following reference business requirement list sample" as a task instruction, and uses the business requirement list corresponding to the contract template in the contract template library that matches the business requirement scenario as a paradigm prompt to form as Figure 13 shown in the prompt information, uses the prompt information as shown in Figure 13 as the input of the LLM to obtain the business requirement list output by the LLM, displays the business requirement list output by the LLM through the display layer 111 of the smart contract coding tool 110, and in response to the user's confirmation operation, the core layer 113 of the smart contract coding tool 110 determines the output business requirement list as the business requirement list for the target business scenario.

[0271] Exemplarily, taking the processing stage as step S222 as an example, as Figure 14 shown, Figure 14It is a schematic flowchart of the contract template generation provided by the embodiments of the present application. The core layer 113 of the smart contract coding tool 110 takes the business requirement list as the background input, "Please act as a senior smart contract developer and be responsible for professionally writing smart contract code" as the role prompt, the contract template in the contract template library that matches the target business scenario as the paradigm prompt, and "Please write smart contract code that meets the requirements according to the above requirement list, following the following code example, and add comments at key steps [and other code style requirements]" as the task instruction, and forms a prompt message as shown in Figure 15 The core layer 113 of the smart contract coding tool 110 takes this prompt message as the input of the LLM, obtains the contract template output by the LLM, and displays the contract template output by the LLM through the display layer 111 of the smart contract coding tool 110. In response to the confirmation operation input by the user, the core layer 113 of the smart contract coding tool 110 obtains the component information input by the user, determines the selected component instance through the component decision model provided by the code resource layer 114, and fills the contract template confirmed by the user based on the selected component instance to obtain the contract example of the target business scenario.

[0272] It can be understood that in response to the modification operation input by the user, the smart contract coding tool 110 and the core layer 113 modify the contract template according to the above step S222, output a new contract template until the contract template confirmed by the user is obtained, obtain the component information input by the user, determine the selected component instance through the component decision model provided by the code resource layer 114, and fill the contract template confirmed by the user based on the selected component instance to obtain the contract example of the target business scenario.

[0273] Exemplarily, taking the processing stage as step S223 as an example, as shown in Figure 16 shown. Figure 16 It is a schematic flowchart of the quality verification process of the contract instance provided by the embodiments of the present application. The core layer 113 of the smart contract coding tool 110 generates the prompt message of this stage according to the contract instance, the business requirement list, and the security vulnerability examples in the contract template library, calls the LLM, inputs the prompt message of this stage into the LLM, guides the LLM to perform security vulnerability detection and logic vulnerability detection, obtains the security vulnerability detection result and the logic vulnerability detection result, the LLM analyzes the security vulnerability detection result and the logic vulnerability detection result, marks the code segments with vulnerabilities in the contract instance, gives the reasons for the vulnerabilities and the corresponding correction solutions, and outputs the vulnerability locations, reasons for generation, and correction solutions, and displays the vulnerability locations, reasons for generation, and correction solutions output by the LLM to the user through the display layer 111 of the smart contract coding tool 110, so that the user can correct the contract instance according to the correction solution to obtain the smart contract in the target business scenario.

[0274] It should be noted that Figure 13 and Figure 15 the prompt information shown is only for exemplary illustration. In actual applications, the number of processing stages and the prompt information templates for each processing stage can be adjusted according to the target business scenario of the smart contract. For example, steps S221 and S222 can be used as one processing stage.

[0275] In another possible implementation, to improve the generation efficiency of the smart contract, when generating the prompt information for each processing stage, the smart contract coding tool 110 can fill the prompt information template according to the requirement information of this processing stage to obtain the prompt information for this processing stage. Among them, the prompt information template includes role prompts, background inputs, task instructions, and paradigm prompts. It can be understood that when filling the prompt information template according to the requirement information of this processing stage, one or more of the role prompts, background inputs, task instructions, and paradigm prompts provided by the prompt information template are filled based on the requirement information of this processing stage to obtain the prompt information for this processing stage.

[0276] Among them, to further improve the generation efficiency of the smart contract, the prompt information template for each processing stage can be pre-constructed and stored. When the smart contract coding tool 110 generates the smart contract, it obtains the prompt information template for each processing stage and fills one or more of the role prompts, background inputs, task instructions, and paradigm prompts provided by the prompt information template for this processing stage according to the requirement information of each processing stage to obtain the prompt information for each processing stage.

[0277] Exemplarily, taking the processing stage as step S221 as an example, the smart contract coding tool 110 obtains the prompt information template for this processing stage. The prompt information template for this processing stage is as shown in Figure 17 Figure (a). It is necessary to fill the background input and paradigm prompts in the prompt information template, obtain the contract template for this processing stage. The smart contract coding tool 110 uses the business requirement information as the background input and the business requirement list corresponding to the contract template matching the business requirement scenario in the contract template library as the paradigm prompt to fill the prompt information template as shown in Figure 17 Figure (a) to form the prompt information as shown in Figure 17 Figure (b).

[0278] In another possible implementation, considering that when the tasks executed in the processing stage are relatively complex, it is difficult for the LLM to output an output result that meets the user's needs by executing the tasks corresponding to the processing stage once. It is necessary to repeatedly correct the output result of the LLM. Moreover, when the LLM is executing, it may miss steps, reducing the accuracy of the output result, increasing the processing time of the LLM, and reducing the generation efficiency of the smart contract. Based on this, to improve the accuracy of the output result of the LLM and enhance the generation efficiency of the smart contract, for each processing stage, the processing stage is divided into multiple sub-processing stages through the chain of thought, and an evaluation prompt is added to each processing stage to evaluate the output result of the large language model in this processing stage. In this way, the processing stage is divided into multiple sub-processing stages through the chain of thought, and by guiding the LLM to execute the sub-processing stages one by one, the processing difficulty of each sub-processing stage is reduced, the accuracy of the output result of the LLM is ensured, and step omission is avoided; and the accuracy of the output result of the LLM is further improved through the evaluation prompt, the number of corrections to the output result of the LLM is reduced, thereby enhancing the generation efficiency of the smart contract.

[0279] Among them, when constructing the prompt information template, the processing stage indicated by the prompt information template is divided into multiple sub-processing stages through the chain of thought, the execution logic between the sub-processing stages is indicated, and an evaluation prompt is set. When generating the prompt information for this processing stage based on the prompt information template, it is filled in according to the prompt information template to form prompt information including the prompt information of each sub-processing stage in this processing stage and the execution logic between the sub-processing stages. The prompt information for this processing stage is input into the LLM. Through the prompt information of each sub-processing stage in the prompt information and the execution logic between the sub-processing stages, the LLM is guided to execute the sub-processing stages one by one to obtain an output result, and the large language model is guided to evaluate the output result, and the output result that passes the evaluation is used as the final output result and returned to the smart contract encoding tool 110.

[0280] Exemplarily, taking the processing stage as step S221 as an example, the prompt information for this processing stage is as Figure 18 shown. The prompt information for this processing stage includes two sub-processing stages: the business requirement list generation sub-processing stage and the self-evaluation sub-processing stage.

[0281] Among them, the role prompt in the sub - processing stage of generating the business requirement list is "Please act as an intelligent contract requirement analyst, responsible for professionally helping users analyze and refine requirements and generate a business requirement list for intelligent contracts", the background input is business requirement information, the task instruction is "Please organize, analyze, and refine the requirements based on the above - mentioned business requirement information, and generate a business requirement list with a unified format by following the following reference business requirement list example", the paradigm prompt is the business requirement list corresponding to the contract template in the contract template library that matches the business requirement scenario. In the self - assessment sub - processing stage, the task instruction is "Please determine whether all the business requirement information is included in the business requirement list. If it is included, output 'included'; if not, please regenerate the business requirement list."

[0282] Exemplarily, taking the processing stage as step S222 as an example, the prompt information in the processing stage is as Figure 19 shown. The prompt information for this processing stage includes three sub - processing stages, which are, in sequence: the code idea understanding sub - processing stage, the contract code generation sub - processing stage, and the self - assessment sub - processing stage.

[0283] Among them, the prompt information for the code idea understanding sub - processing stage includes a role prompt, a background input, and a task instruction. The role prompt is "Please act as a senior intelligent contract developer, responsible for professionally writing intelligent contract code", the background input is the "business requirement list", and the task instruction is "Please design intelligent contract code based on the above - mentioned requirement list and explain the design idea in detail and understandably."

[0284] The prompt information for the contract code generation sub - processing stage includes a task instruction and a paradigm prompt. Among them, the task instruction for the contract code generation sub - processing stage is "Please write a contract template that meets the requirements by following the following contract template example based on the design idea, and require adding comments at key steps [and other code style requirements]", and the paradigm prompt is the contract template in the contract template library that matches the target business scenario.

[0285] The prompt information for the self - assessment sub - processing stage includes a task instruction, which is "Please determine whether the generated contract template has met all the requirements in the business requirement list. If not, please regenerate the contract template."

[0286] Exemplarily, taking the processing stage as step S223 as an example, the prompt information in the processing stage is as Figure 20 shown. The prompt information for this processing stage includes six sub - processing stages, which are, in sequence: the code logic parsing sub - processing stage, the data flow analysis sub - processing stage, the security vulnerability detection sub - processing stage, the security vulnerability detection and assessment sub - processing stage, the logic vulnerability detection sub - processing stage, and the logic vulnerability detection and assessment sub - processing stage.

[0287] Among them, the prompt information in the code logic parsing sub - processing stage includes a task instruction and a background input. The task instruction is "Please understand the following contract instance code and explain the functions and logic implemented by this code", and the background input is the contract instance of the target business scenario.

[0288] The prompt information in the data flow analysis sub - processing stage includes a task instruction, and this task instruction is "Please analyze the data flow and control flow of the above code".

[0289] The prompt information in the security vulnerability detection and evaluation sub - processing stage includes a role prompt, a task instruction, and a paradigm prompt. Among them, the role prompt is "Please act as an intelligent contract vulnerability detection tool, responsible for professionally detecting whether there are security risks in the source code", the task instruction is "Please judge whether the above contract instance code is correct. If it is correct, output correct. If it is incorrect, please give a modification plan in the format of existing problems|problem analysis|modification plan. The following are the characteristics of common intelligent contract security vulnerabilities", and the paradigm prompt is the security vulnerability instance stored in the code resource layer 114.

[0290] The prompt information in the security vulnerability detection and evaluation sub - processing stage includes a task instruction, and this task instruction is "Please judge whether there are security vulnerabilities in the above contract instance code other than the paradigm prompt. If there are no vulnerabilities, output correct. If there are vulnerabilities, please give code modification suggestions in the format of existing problems|problem analysis|modification method".

[0291] The prompt information in the logical vulnerability detection sub - processing stage includes a role prompt, a background input, and a task instruction. Among them, the role prompt is "Please act as an intelligent contract code reviewer, responsible for professionally checking whether the contract instance code meets the requirements", the background input is the business requirement list, and the task instruction is "Please further judge whether the above contract instance code meets the requirements indicated by the business requirement list according to the above business requirement list. If it meets, output meets. If it does not meet, please give a modification plan in the format of existing problems|problem analysis|modification method".

[0292] The prompt information in the logical vulnerability detection and evaluation sub - processing stage includes a task instruction, and this task instruction is "Please judge whether the above contract instance code omits some requirements other than the business requirement list. If there is no omission, output meets. If there is an omission, please give code modification suggestions in the format of existing problems|problem analysis|modification method".

[0293] It should be noted that Figure 18 、 Figure 19 and Figure 20The displayed prompt information, the number of sub - processing stages included in the prompt information, and the execution logic between each sub - processing stage are only for illustrative purposes. According to the actual application scenario, the number of sub - processing stages and the execution logic in each prompt information, as well as the field information in the prompt information of each processing stage, can be adjusted.

[0294] In a possible implementation manner, during the quality verification of the contract instance for the target business scenario, considering that the contract instance generated based on the contract template reused in the contract template has fewer security vulnerabilities and missing requirements. To improve the generation efficiency of the smart contract, after obtaining the contract instance, the smart contract coding tool 110 calls the LLM and performs quality verification on the contract instance of the target business scenario according to the Figure 16 provided quality verification processing flow to generate a smart contract for the target business scenario.

[0295] In another possible implementation manner, during the quality verification of the contract instance for the target business scenario by the smart contract coding tool 110, considering that the contract instance obtained based on the contract template generated by the LLM may have more security vulnerabilities and missing requirements, and there may also be problems of mis - detection of security vulnerabilities and missing requirements, which will reduce the accuracy of the finally generated smart contract. Based on this, to improve the accuracy of the smart contract and increase the interactivity with the user, after the LLM outputs the quality verification result, the quality verification result of the contract instance output by the LLM is displayed to the user. After obtaining the quality verification result confirmed by the user, the contract instance is modified based on the quality verification result confirmed by the user to obtain a smart contract for the target business scenario.

[0296] Specifically, as Figure 21 shown, Figure 21 is a schematic diagram of the contract instance correction process provided by an embodiment of the present application. The shown contract instance correction process includes steps S2231 - S2235:

[0297] Step S2231, call the LLM to perform quality verification on the contract instance of the target business scenario to obtain the quality verification result of the contract instance returned by the LLM.

[0298] Step S2232, display the quality verification result of the contract instance output by the LLM to the user.

[0299] Step S2233, in response to the result confirmation operation input by the user, obtain the quality verification result confirmed by the user.

[0300] Step S2234: Use the quality verification result confirmed by the user as the input of the LLM, call the LLM to correct the code, and obtain the code modification suggestions for the contract instance returned by the LLM, as well as the locations and causes of vulnerabilities in the contract instance.

[0301] Step S2235: Obtain the smart contract in the target business scenario based on the code modification suggestions, the locations of vulnerabilities in the contract instance, and the causes of vulnerabilities.

[0302] In a possible implementation, the core layer 113 of the smart contract coding tool 110 can call the LLM, use the code modification suggestions as the input of the LLM, guide the LLM to correct the contract instance, and obtain the smart contract in the target business scenario.

[0303] In another possible implementation, the display layer 111 of the smart contract coding tool 110 displays the code modification suggestions, the locations of vulnerabilities in the contract instance, and the causes of vulnerabilities to the user. In response to the code modification operation input by the user, the core layer 113 of the smart contract coding tool 110 modifies the contract instance, and determines the modified contract instance as the smart contract in the target business scenario.

[0304] In another possible implementation, the core layer 113 of the smart contract coding tool 110 calls the LLM, uses the code modification suggestions as the input of the LLM, guides the LLM to correct the contract instance, and obtains the corrected contract instance. The display layer 111 of the smart contract coding tool 110 displays the corrected contract instance, the code modification suggestions, the locations of vulnerabilities in the contract instance, and the causes of vulnerabilities to the user. The core layer 113 of the smart contract coding tool 110 determines the corrected contract instance as the smart contract in the target business scenario in response to the user's confirmation operation. The core layer 113 of the smart contract coding tool 110 determines the modification information of the code modification suggestions in response to the user's modification operation, re-enters the modification information of the code modification suggestions, the code modification suggestions, and the contract instance into the LLM, and obtains a new corrected contract instance, and repeats this process until the corrected contract instance is determined as the smart contract in the target business scenario in response to the user's confirmation operation.

[0305] In a possible implementation, to enrich the contract templates in the contract template library, when the contract template library does not include a contract template that matches the business requirement information, after the core layer 113 of the smart contract coding tool 110 obtains the smart contract in the target business scenario, it associates the business requirement list generated based on the large language model with the contract template and writes them into the contract template library in the code resource layer 114. In this way, by increasing the number and types of contract templates in the contract template library, more reusable contract templates are provided, thereby reducing the difficulty of writing smart contracts and improving the writing efficiency of smart contracts.

[0306] In a possible implementation, to improve the flexibility and practicality of the smart contract generation method, when the contract template library does not include a contract template that matches the business requirement information, the core layer of the smart contract coding tool 110 responds to the contract template input operation, obtains the input contract template input externally, fills the component instances selected by the user into the input contract template to obtain a contract instance for the target business scenario, and calls the LLM to perform a quality check on the contract instance for the target business scenario to generate a smart contract for the target business scenario.

[0307] It can be understood that when filling the component instances selected by the user into the input contract template to obtain a contract instance for the target business scenario, to improve the accuracy of the smart contract and increase the interactivity with the user at the same time, after the LLM outputs the quality check result, the core layer of the smart contract coding tool 110 executes the Figure 21 contract instance correction process provided above to correct the contract instance and obtain a smart contract for the target business scenario.

[0308] The above mainly introduces the solution provided in this application by taking the smart contract coding tool 110 as an example. It can be understood that in order to implement the above functions, the smart contract coding tool 110 includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should easily realize that, combining the units and algorithm operations of each example described in the embodiments disclosed in this article, this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0309] This application can divide the functional modules of the above intelligent contract coding tool 110 according to the above method examples. For example, each functional module can be corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It can be understood that the naming and grouping of the devices and modules in the embodiments of this application are illustrative, only a logical functional grouping, and there can be other grouping methods in actual implementation.

[0310] For example, the intelligent contract coding tool 110 can also be named the intelligent contract generation device 22. As Figure 22 shown, the intelligent contract generation device 22 can include functional modules different from Figure 3 the functional layers shown.

[0311] Figure 22 FIG. is a schematic structural diagram of the intelligent contract generation device provided by the embodiments of this application. The shown intelligent contract generation device 22 includes:

[0312] An acquisition module 2101, configured to acquire business requirement information of a target business scenario.

[0313] A judgment module 2102, configured to judge whether there is a contract template in the contract template library that matches the business requirement information;

[0314] A contract generation module 2103, configured to, when there is no contract template in the contract template library that matches the business requirement information, call an LLM to generate an intelligent contract for the target business scenario based on the business requirement information; wherein, the contract template library includes contract templates of pre-configured business scenarios; the LLM is used to perform requirement parsing based on the business requirement information, perform code generation based on the requirement parsing result, and perform quality verification on the generated contract instance to form an intelligent contract for the target business scenario.

[0315] Among them, the acquisition module 2101, the judgment module 2102, and the contract generation module 2103 can all be implemented by software or by hardware. Exemplarily, next, taking the acquisition module 2101 as an example, the implementation manner of the acquisition module 2101 will be introduced. Similarly, the implementation manners of the judgment module 2102 and the contract generation module 2103 can refer to the implementation manner of the acquisition module 2101.

[0316] As an example of a software functional unit, the acquisition module 2101 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above computing instance may be one or more. For example, the acquisition module 2101 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers for running the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers for running the code may be distributed in the same availability zone (AZ) or in different AZs. Each AZ includes one data center or multiple geographically proximate data centers. Usually, one region may include multiple AZs.

[0317] Similarly, the multiple hosts / virtual machines / containers for running the code may be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, one VPC is set within one region. For cross-region communication between two VPCs within the same region and between VPCs in different regions, a communication gateway needs to be set in each VPC, and the interconnection between VPCs is achieved through the communication gateway.

[0318] As an example of a hardware functional unit, the acquisition module 2101 may include at least one computing device, such as a server, etc. Alternatively, the acquisition module 2101 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). Among them, the above PLD may be implemented by a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0319] The multiple computing devices included in the obtaining module 2101 may be distributed in the same region or in different regions. The multiple computing devices included in the obtaining module 2101 may be distributed in the same availability zone (AZ) or in different AZs. Similarly, the multiple computing devices included in the obtaining module 2101 may be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Among them, the multiple computing devices may be any combination of computing devices such as servers, application-specific integrated circuits (ASICs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), and generic array logic (GALs).

[0320] It should be noted that the naming and grouping of the modules in the embodiments of the present application are illustrative, merely a logical function grouping, and there may be other grouping methods in actual implementation. The intelligent contract generation device 22 can be divided into an obtaining module 2101, a judgment module 2102, and a contract generation module 2103 not only according to its execution functions, but also can be divided into a code resource management module 221, a business requirement analysis module 222, a code customization generation module 223, and a contract quality verification module 224 according to its execution functions. Specifically, an example of this other division can be referred to in the following Figure 23 corresponding embodiments.

[0321] It should be noted that in other embodiments, the obtaining module 2101 can be used to execute any step in the intelligent contract generation method, the judgment module 2102 can be used to execute any step in the intelligent contract generation method, and the contract generation module 2103 can be used to execute any step in the intelligent contract generation method. The steps to be implemented by the obtaining module 2101, the judgment module 2102, and the contract generation module 2103 can be specified as needed. By implementing different steps in the intelligent contract generation method through the obtaining module 2101, the judgment module 2102, and the contract generation module 2103 respectively, all functions of the intelligent contract generation device 22 are realized.

[0322] The embodiments of the present application also provide a computing device cluster for executing the above intelligent contract generation method.

[0323] In one example, the computing device cluster may include an intelligent contract generation device 22 as shown in Figure 21 The intelligent contract generation device 21 includes an obtaining module 2101, a judgment module 2102, and a contract generation module 2103.

[0324] In another example, the computing device cluster includes at least one computing device, and the computing device may include as shown in Figure 22The intelligent contract generation device 21 shown, and this intelligent contract generation device 21 includes an acquisition module 2101, a judgment module 2102, and a contract generation module 2103. In a possible implementation, the computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In another possible implementation, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.

[0325] In another example, another intelligent contract generation device 22 as shown is provided in the computer device cluster. An LLM call interface is provided in this intelligent contract generation device 22. Through the call interface, the LLM is called, and intelligent contract generation is performed according to the above intelligent contract generation method. In a possible implementation, as Figure 23 shown, a code resource management module 221, a business requirement analysis module 222, a code customization generation module 223, and a contract quality verification module 224 are provided in the intelligent contract generation device 22. Figure 23 shown, a code resource management module 221, a business requirement analysis module 222, a code customization generation module 223, and a contract quality verification module 224 are provided in the intelligent contract generation device 22.

[0326] Among them, the code resource management module 221 is used to provide data support to the business requirement analysis module 222, the code customization generation module 223, and the contract quality verification module 224, such as business requirement lists for different business scenarios, contract templates for each business requirement list, component instances called by each contract template, description information of each component instance, prompt information templates, component decision models, and security vulnerability examples, etc.

[0327] As Figure 23 shown, the code resource management module 221 includes a contract template and component instance management functional unit, a contract template and component instance query functional unit, and a component decision model management functional unit. Among them, the template and component management functional unit is used to add, delete, and adjust the contract templates, component instances, and other data stored in the code resource layer 114 in response to the add, delete, and adjustment operations input by the user. The template and component query functional unit is used to quickly search for contract templates, component instances, and other data in the code resource layer 114. The component decision model management functional unit is used to provide a component decision model, make decisions through the component decision model, and recommend component instances to the user.

[0328] Among them, the business requirement analysis module 222 is used to provide a list of requirement questions to the user, fill in the list of requirement questions in response to the user's input operation to form a filled list of requirement questions, obtain business requirement information from the filled list of requirement questions, and provide a business requirement list to the code customization generation module 223 based on the business requirement information.

[0329] As Figure 23As shown in the figure, the business requirement analysis module 222 includes a key requirement extraction functional unit and a requirement list generation functional unit. Among them, the key requirement extraction functional unit is used to provide a list of requirement questions to the user, respond to the user's input operation, fill in the list of requirement questions, form a filled list of requirement questions, and obtain business requirement information from the filled list of requirement questions. The requirement list generation functional unit is used to use the business requirement information as the input of the LLM, and call the LLM to generate a business requirement list for the target business scenario.

[0330] Among them, the code customization generation module 223 is used to generate a contract template based on the business requirement list generated by the business requirement analysis module 222, determine the component instances selected by the user, and fill the component instances selected by the user into the generated contract template to obtain a contract instance.

[0331] As Figure 23 shown in the figure, the code customization generation module 223 includes a requirement list parsing functional unit, a contract template automatic generation functional unit, and a contract template improvement functional unit. Among them, the requirement list parsing functional unit is used to convert the business requirement list into a description form recognizable by the LLM. The contract template automatic generation functional unit is used to obtain the prompt information template for this processing stage, obtain the contract template matching the target business scenario from the code resource management module 221, fill the prompt information template for this processing stage based on the converted business requirement list and the contract template matching the target business scenario, form the prompt information for this processing stage, call the LLM, and use the prompt information for this processing stage as the input of the LLM to generate a contract template. The contract template improvement functional unit is used to display a code editing page to the user, determine the component instances selected by the user based on the code editing page, and fill the component instances selected by the user into the generated contract template to obtain a contract instance.

[0332] Among them, the contract quality verification module 224 is used to call the LLM to perform quality verification on the contract instance of the target business scenario and generate a smart contract for the target business scenario.

[0333] As Figure 23As shown in the figure, the contract quality verification module 224 includes a security vulnerability detection functional unit, a logical vulnerability detection functional unit, and a code correction suggestion generation functional unit. Among them, the security vulnerability detection functional unit is used to detect security vulnerabilities in the contract instance through the LLM to form a security vulnerability detection result. The logical vulnerability detection functional unit is used to detect whether the contract instance meets the requirements through the LLM to form a logical vulnerability detection result. The code correction suggestion generation functional unit is used to use the security vulnerability detection result and the logical vulnerability detection result as the input of the LLM, call the LLM for code correction, generate code modification suggestions for the contract instance, as well as the location and cause of the vulnerabilities in the contract instance; according to the code modification suggestions, the location and cause of the vulnerabilities in the contract instance, obtain the smart contract in the target business scenario.

[0334] Among them, the code resource management module 221, the business requirement analysis module 222, the code customization generation module 223, and the contract quality verification module 224 can be software functional modules including the above-mentioned code in the computing instance, or hardware functional modules including at least one computing device.

[0335] In another example, the computer device cluster includes at least one computing device, such as Figure 24 As shown in the figure, the computing device 24 includes: a bus 232, a processor 234, a memory 236, and a communication interface 238. The processor 234, the memory 236, and the communication interface 238 communicate with each other through the bus 232. The computing device 23 can be a server or a terminal device. It should be understood that the number of the processor 234 and the memory 236 in the computing device 23 is not limited in this application.

[0336] The bus 232 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, Figure 24 only one line is shown in the figure, but it does not mean that there is only one bus or one type of bus. The bus 232 can include a path for transmitting information between various components of the computing device 23 (for example, the memory 236, the processor 234, the communication interface 238).

[0337] The processor 234 may include any one or more of processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0338] The memory 236 may include a volatile memory, such as a random access memory (RAM). The processor 234 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0339] The executable program code is stored in the memory 236, and the processor 234 executes the executable program code to respectively implement the functions of the foregoing acquisition module, judgment module, first contract generation module, and second contract generation module, thereby implementing the intelligent contract generation method. That is, instructions for executing the intelligent contract generation method are stored on the memory 236.

[0340] The communication interface 238 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement the communication between the computing device 24 and other devices or a communication network.

[0341] The intelligent contract generation method disclosed in the foregoing method embodiment may be applied to the processor 234 or implemented by the processor 234. The processor 234 may be an integrated circuit chip with signal processing capabilities.

[0342] In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 234 or the instructions in the form of software. The above-mentioned processor 234 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete electron tubes or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 236, and the processor 234 reads the information in the memory 236 and combines its hardware to complete the steps of the above method.

[0343] In a possible implementation manner, the processor 234 can also be used to execute the operation method of the pipeline. For the specific implementation, reference can be made to the embodiments provided in the above operation method of the pipeline, and the embodiments of the present application will not be elaborated herein.

[0344] In the embodiments of the present application, the chip system can be composed of chips or can also include chips and other discrete devices.

[0345] The embodiments of the present application further provide a computer-readable storage medium. All or part of the processes in the above method embodiments can be completed by a computer program instructing relevant hardware. This program can be stored in the above computer-readable storage medium. When this program is executed, it can include the processes of the above method embodiments. The computer-readable storage medium can be the terminal in any of the foregoing embodiments, such as an internal storage unit including a data transmission end and / or a data reception end, for example, the hard disk or memory of the terminal. The above computer-readable storage medium can also be an external storage device of the above terminal, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the above terminal. Further, the above computer-readable storage medium can also include both the internal storage unit of the above terminal and the external storage device. The above computer-readable storage medium is used to store the above computer program and other programs and data required by the above terminal. The above computer-readable storage medium can also be used to temporarily store the data that has been output or will be output.

[0346] It should be understood that in the technical solution of the present application, the collection, storage, use, processing, transmission, provision, and disclosure of the user's personal information and other processing all comply with relevant laws and regulations and do not violate public order and good customs. For example, in the technical solution of the present application, the processing of the user's personal information is carried out under the authorization of the user. This is explained here once, and will not be repeated below.

[0347] It should be noted that the terms "first" and "second" in the specification, claims, and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units that are not listed, or optionally further includes other steps or units inherent to these processes, methods, products, or devices.

[0348] It should be understood that in this application, "at least one (item)" means one or more, "a plurality" means two or more, "at least two (items)" means two or three or more, and "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can represent: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally represents an "or" relationship between the front and rear associated objects. "At least one (item) of the following" or its similar expression refers to any combination of these items, including any combination of single item (item) or plural items (items). For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0349] It should be understood that in the embodiments of this application, "B corresponding to A" means that B is associated with A. For example, B can be determined according to A. It should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information. In addition, the "connection" that appears in the embodiments of this application refers to various connection methods such as direct connection or indirect connection to achieve communication between devices, and this application does not make any limitation on this.

[0350] Unless otherwise specified, the "transmission" (transmit / transmission) that appears in the embodiments of this application refers to two-way transmission, including the actions of sending and / or receiving. Specifically, the "transmission" in the embodiments of this application includes the sending of data, the receiving of data, or the sending and receiving of data. Or rather, the data transmission here includes uplink and / or downlink data transmission. Data can include channels and / or signals. Uplink data transmission is the transmission of uplink channels and / or uplink signals, and downlink data transmission is the transmission of downlink channels and / or downlink signals. The "network" and "system" that appear in the embodiments of this application express the same concept, and an all-optical network is an all-optical system.

[0351] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the grouping of the above functional modules is used as an example for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

[0352] In several embodiments provided in this application, it should be understood that the disclosed communication devices and methods can be implemented in other ways. For example, the communication device embodiments described above are merely illustrative. For example, the grouping of modules or units is only a logical function grouping. In actual implementation, there may be other grouping methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling, direct coupling, or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of devices or units can be in electrical, mechanical, or other forms.

[0353] The units described as separate components may or may not be physically separated. The components displayed as units may be one physical unit or multiple physical units, that is, they can be located in one place, or they can also be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0354] In addition, in each embodiment of this application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0355] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to enable a device, such as a single-chip microcomputer, a chip, etc., or a processor to execute all or part of the steps of the methods of the various embodiments of this application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical discs that store program codes.

[0356] The above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application, and all should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims

1. A method for generating a smart contract, characterized in that, Including: Obtaining business requirement information of a target business scenario; The business requirement information is used to indicate the requirements for generating a smart contract in the target business scenario; Judging whether there is a contract template in the contract template library that matches the business requirement information; In the case that there is no contract template in the contract template library that matches the business requirement information, based on the business requirement information, calling a large language model (LLM) to generate a smart contract in the target business scenario; the contract template library includes contract templates for pre-configured business scenarios; The LLM is used to perform requirement parsing based on the business requirement information, perform code generation based on the requirement parsing result, and perform quality verification on the generated contract instance to form a smart contract in the target business scenario.

2. The method according to claim 1, characterized in that, The calling the large language model (LLM) to generate a smart contract in the target business scenario based on the business requirement information includes the following processing stages: Taking the business requirement information as the input of the LLM, and calling the LLM to generate a business requirement list for the target business scenario; Taking the business requirement list as the input of the LLM, and calling the LLM to generate a contract instance for the target business scenario; Calling the LLM to perform quality verification on the contract instance for the target business scenario to generate a smart contract in the target business scenario.

3. The method according to claim 1 or 2, characterized in that, The calling the large language model (LLM) to generate a smart contract in the target business scenario includes multiple processing stages; each of the processing stages corresponds to a prompt message; the prompt message includes at least one of a role prompt, a background input, a task instruction, and a paradigm prompt.

4. The method according to claim 3, characterized in that, The prompt message corresponding to each processing stage is obtained according to a prompt message template and the requirement information of the processing stage; the prompt message template includes a role prompt, a background input, a task instruction, and a paradigm prompt.

5. The method according to claim 4, characterized in that, The prompt message template further includes at least one of a thought chain and an evaluation prompt; The thought chain is used to indicate the sub-processing stages included in the LLM processing stage and the execution logic between the sub-processing stages; The evaluation prompt is used to indicate that the LLM evaluates the matching degree of the output result of the LLM.

6. The method according to claim 5, characterized in that, In the case that the processing stage is taking the business requirement information as the input of the LLM and calling the LLM to generate a business requirement list for the target business scenario, the role prompt is a requirements analyst; The background input is the business requirement information; The task instruction is to perform requirement analysis based on the business requirement information to form a business requirement list; The paradigm prompt is a sample of a business requirement list that matches the target business scenario in the contract template library; the contract template library includes contract templates for pre-configured business scenarios and the corresponding business requirement lists for each contract template.

7. The method according to claim 5, characterized in that, The taking the business requirement list as the input of the LLM and calling the LLM to generate a contract instance for the target business scenario includes: Taking the business requirement list as the input of the LLM and calling the LLM to generate a contract template for the target business scenario; Fill the component instances selected by the user into the contract template to obtain the contract instance of the target business scenario.

8. The method according to claim 7, characterized in that, In the case where the business requirement list is used as the input of the LLM in the processing stage to call the LLM to generate the contract template of the target business scenario, the role prompt is a developer; The background input is the business requirement list of the target business scenario; The task instruction is to design the smart contract code according to the business requirement list of the target business scenario to form a design idea, and write the contract code according to the design idea to form a contract template; The paradigm is a contract template example matching the target business scenario; The contract template example is obtained from the contract template library.

9. The method according to claim 7, characterized in that, The filling the component instances selected by the user into the contract template to obtain the contract instance of the target business scenario includes: Output the code editing page view; Obtain the component information input by the user based on the code editing page view; Based on the component information and a preset component decision model, obtain candidate component instances matching the component information from the contract component library; the contract component library includes multiple pre-configured component instances; In response to the component selection operation input by the user based on the candidate component instances, determine the component instances selected by the user; Fill the component instances selected by the user into the contract template to obtain the contract instance of the target business scenario.

10. The method according to claim 7, characterized in that The filling the component instances selected by the user into the contract template to obtain the contract instance of the target business scenario includes: Output the code editing page view; In the code editing page view, display the candidate component instances matching the target business scenario in the contract component library; the contract component library includes multiple pre-configured component instances; In response to the component selection operation input by the user based on the candidate component instances, determine the component instances selected by the user; Fill the component instances selected by the user into the contract template to obtain the contract instance of the target business scenario.

11. The method according to claim 5, characterized in that In the case where the processing stage is to call the LLM to perform quality verification on the contract instance of the target business scenario and generate the smart contract under the target business scenario, the background input is the business requirement list and the contract instance of the target business scenario; The task instruction is to detect whether the contract instance is correct and whether the contract instance meets the business requirement list; The paradigm prompt is a preset security vulnerability example in the contract template library.

12. The method according to claim 11, characterized in that The processing stage includes a first sub-processing stage and a second sub-processing stage; the evaluation prompt includes the evaluation prompt of the first sub-processing stage and the evaluation prompt of the second sub-processing stage; The first sub-processing stage is used to instruct the LLM to detect whether the contract instance of the target business scenario is correct, and to determine the vulnerabilities existing in the contract instance in the case where the contract code is incorrect; The second sub - processing stage is used to instruct the LLM to detect whether the contract instance meets the business requirement list based on the business requirement list, and to determine the missing requirements of the contract instance in the case where the contract instance does not meet the business requirement list; The evaluation prompt of the first sub - processing stage is to determine whether there are vulnerabilities in the contract instance other than the security vulnerability examples; The evaluation prompt of the second sub - processing stage is to determine whether there are missing requirements in the contract instance other than the business requirement list.

13. The method according to any one of claims 2 to 12, characterized in that Taking the business requirement information as the input of the LLM and calling the LLM to generate the business requirement list for the target business scenario includes: Repeatedly execute the following process until the business requirement list confirmed by the user is obtained: Display the business requirement list output by the LLM to the user; In response to the user's modification operation, modify the business requirement list output by the LLM, re - input the modified business requirement list and the business requirement information into the LLM to obtain a new business requirement list.

14. The method according to any one of claims 2 to 12, characterized in that Taking the business requirement list as the input of the LLM and calling the LLM to generate the contract instance for the target business scenario includes: Repeatedly execute the following process until a contract template confirmed by the user is obtained, and then fill the component instances selected by the user into the contract template to obtain the contract instance for the target business scenario: Display the contract template output by the LLM to the user; In response to the user's modification operation, modify the contract template output by the LLM, re - input the modified contract template and the business requirement list into the LLM to obtain a new contract template.

15. The method according to claim 14, characterized in that After calling the LLM to perform quality verification on the contract instance for the target business scenario and generating the smart contract for the target business scenario, the method further includes: Associate the business requirement list for the target business scenario and the corresponding contract template and write them into the contract template library.

16. The method according to any one of claims 2 to 12, characterized in that Calling the LLM to perform quality verification on the contract instance for the target business scenario and generating the smart contract for the target business scenario includes: Display the quality verification result of the contract instance output by the LLM to the user; the quality verification result indicates whether there are vulnerabilities in the contract instance and whether there are missing requirements; In response to the result confirmation operation input by the user, obtain the quality verification result confirmed by the user; Taking the quality verification result confirmed by the user as the input of the LLM, calling the LLM to perform code correction, generating code modification suggestions for the contract instance, as well as the positions and causes of the vulnerabilities in the contract instance; Based on the code modification suggestions, the positions and causes of the vulnerabilities in the contract instance, obtain the smart contract for the target business scenario.

17. The method according to claim 1, characterized in that When the contract template library includes a contract template that matches the service requirement information, fill the component instances selected by the user into the contract template to obtain a contract instance for the target business scenario. Invoke the LLM to perform quality verification on the contract instance for the target business scenario, and generate a smart contract for the target business scenario.

18. The method according to claim 1, characterized in that The service requirement information for the target business scenario is obtained based on a service requirement question list; the service requirement question list includes multiple requirement items to be written, and each requirement item is used to describe the requirement information of the smart contract to be generated.

19. The method according to claim 1, characterized in that By detecting whether the service requirement list corresponding to the contract template included in the contract template library includes the requirements indicated by the service requirement information, determine whether the contract template library includes a contract template that matches the service requirement information.

20. The method according to any one of claims 1 to 19, characterized in that The method is executed by a smart contract coding tool; the smart contract coding tool includes a display layer, a proxy layer, a core layer, a code resource layer, and a storage layer. The display layer is used to provide interface interaction for the smart contract coding tool. The proxy layer is used to reverse proxy the service functions of the smart contract coding tool; the service functions include at least one of code resource management, service requirement analysis, code generation, and contract quality verification. The core layer is used to provide the service functions of the smart contract coding tool. The code resource layer is used to store the code resources of the smart contract coding tool; the code resources include contract templates and component instances. The storage layer is used to provide the storage function of the smart contract coding tool and store data other than the code resources of the smart contract coding tool.

21. The method according to claim 20, characterized in that The code resource layer is provided with a contract template library and a contract component library. The contract template library includes contract templates for multiple business scenarios and the service requirement lists corresponding to each contract template. The contract component library includes component instances for calling the contract templates in the contract template library.

22. The method according to claim 21, characterized in that Divide the contract component library into at least one component sub-layer according to the component type of the component instances. Each component sub-layer corresponds to a component type, and each component sub-layer stores component instances of the corresponding component type; the component types include at least one of general operation components, algorithm tool components, basic operation components, and data structure components.

23. An intelligent contract generation device, characterized in that The device includes: An acquisition module, used for the service requirement information of the target business scenario; the service requirement information is used to indicate the requirements for generating a smart contract for the target business scenario. A judgment module, used to judge whether the contract template library includes a contract template that matches the service requirement information. A contract generation module, configured to, when the contract template library does not include a contract template matching the service requirement information, call a large language model (LLM) to generate an intelligent contract for the target business scenario based on the service requirement information; the contract template library includes contract templates for pre-configured business scenarios; the LLM is configured to perform requirement parsing based on the service requirement information, generate code based on the requirement parsing result, and perform quality verification on the generated contract instance to form the intelligent contract for the target business scenario.

24. A computing device cluster, characterized in that Comprising at least one computing device, each computing device including a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 22.

25. A computer-readable storage medium, characterized in that Comprising computer program instructions, when the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 22.

Citation Information

Cited By

  • Code generation method and device based on large model

    CN120929061A

  • A large model-based code generation method and device

    CN120929061B

  • Smart contract configuration using unstructured data

    US12547777B2

  • Smart contract configuration using unstructured data

    US20260017413A1