[go: up one dir, main page]

CN119440486A - Smart contract generation and execution method, device, equipment and medium - Google Patents

Smart contract generation and execution method, device, equipment and medium Download PDF

Info

Publication number
CN119440486A
CN119440486A CN202411512352.5A CN202411512352A CN119440486A CN 119440486 A CN119440486 A CN 119440486A CN 202411512352 A CN202411512352 A CN 202411512352A CN 119440486 A CN119440486 A CN 119440486A
Authority
CN
China
Prior art keywords
contract
execution
data
natural language
transaction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411512352.5A
Other languages
Chinese (zh)
Inventor
郭宏泰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202411512352.5A priority Critical patent/CN119440486A/en
Publication of CN119440486A publication Critical patent/CN119440486A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/10Requirements analysis; Specification techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

本发明涉及人工智能技术领域和金融科技领域,公开了一种智能合约生成和执行方法,通过收集智能合约参与方的交易行为数据和交易需求数据,基于所收集的数据构建自然语言理解模型,获取合约要求并生成合约的自然语言描述,将生成的合约自然语言描述解析并转换为智能合约代码,对智能合约代码进行语法和逻辑验证,执行验证通过的智能合约代码,并将执行过程和执行结果记录在区块链的分布式账本中。本发明通过自动化生成智能合约,降低了对参与方编程能力的要求,解决了现有技术中智能合约编写效率低下且容易出现错误的问题。通过引入语法和逻辑验证步骤,确保智能合约在执行前的准确性,避免了因合约逻辑错误导致的潜在风险。

The present invention relates to the fields of artificial intelligence technology and financial technology, and discloses a method for generating and executing a smart contract. By collecting transaction behavior data and transaction demand data of smart contract participants, a natural language understanding model is constructed based on the collected data, contract requirements are obtained and a natural language description of the contract is generated, the generated natural language description of the contract is parsed and converted into a smart contract code, the smart contract code is subjected to syntax and logic verification, the verified smart contract code is executed, and the execution process and execution results are recorded in the distributed ledger of the blockchain. The present invention reduces the requirements for the programming ability of the participants by automatically generating smart contracts, and solves the problem of low efficiency and easy error in smart contract writing in the prior art. By introducing syntax and logic verification steps, the accuracy of the smart contract before execution is ensured, and potential risks caused by contract logic errors are avoided.

Description

Intelligent contract generation and execution method, device, equipment and medium
Technical Field
The present invention relates to the field of artificial intelligence technology and financial technology, and in particular, to an intelligent contract generating and executing method, apparatus, device, and storage medium.
Background
With the rapid development of blockchain technology, the financial field gradually adopts blockchains as data storage and transaction platforms. The decentralization feature of the blockchain can ensure the security and transparency of transactions while providing a distributed ledger record that is not tamperable. This makes blockchains an important tool for securing financial transactions. Moreover, the advent of smart contracts has further driven the application of automated transactions. The intelligent contract can automatically execute specific financial transactions on the blockchain by compiling preset conditions, so that manual intervention in intermediate links is reduced, and transaction efficiency is improved.
However, current smart contracts are mostly written in a programming language, typically manually written by a developer. This approach requires not only a high level of knowledge of the blockchain programming language (e.g., solidity, etc.), but also a profound understanding of the financial transaction logic. The lack of programming skills by the participants of most financial institutions complicates and consumes time in the generation and application of contracts.
In the prior art, the generation process of smart contracts is typically not capable of dynamically generating contract descriptions automatically based on transaction data and requirements. The participants need to manually write or modify the contract code, which increases the risk of errors, especially when complex financial transactions are processed. Such an approach results in inefficient contract generation, which is difficult to accommodate in high frequency and complex financial transaction scenarios.
Disclosure of Invention
The invention mainly aims to provide an intelligent contract generation and execution method, device, equipment and storage medium, and aims to solve the technical problems that in the prior art, the generation process of an intelligent contract depends on manual code writing, automatic support is lacked, the contract generation efficiency is low, and grammar and logic errors are easy to occur.
In order to achieve the above object, the present invention provides an intelligent contract generation and execution method, including:
collecting transaction behavior data and transaction demand data of intelligent contract participants;
Constructing a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
acquiring contract requirements, and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
Resolving and converting the natural language description of the contract into intelligent contract codes;
performing grammar and logic verification on the intelligent contract codes in a distributed node network of a blockchain;
executing the smart contract code when grammar and logic verification pass;
And recording the execution process and the execution result of the intelligent contract code in a distributed account book of a blockchain.
Further, in order to achieve the above object, the present invention provides an intelligent contract generating and executing apparatus, comprising:
the data collection module is used for collecting transaction behavior data and transaction demand data of the intelligent contract participants;
the model building module is used for building a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
the contract generation module is used for acquiring contract requirements and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
The code generation module is used for analyzing and converting the natural language description of the contract into intelligent contract codes;
the code verification module is used for carrying out grammar and logic verification on the intelligent contract code in the distributed node network of the blockchain;
a contract execution module for executing the intelligent contract code when the grammar and logic verification pass;
And the recording and storing module is used for recording the execution process and the execution result of the intelligent contract code in the distributed account book of the blockchain.
Further, to achieve the above object, the present invention also provides a computer device including a memory, a processor, and a smart contract generation and execution program stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the smart contract generation and execution method as described above.
Further, in order to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a smart contract generation and execution program which, when executed by a processor, implements the steps of the smart contract generation and execution method as described above.
The invention has the beneficial effects that the invention relates to the technical field of artificial intelligence and the field of financial science and technology, and discloses an intelligent contract generation and execution method, wherein the transaction behavior data and the transaction demand data of an intelligent contract participant are collected, a natural language understanding model is constructed based on the collected data, the contract requirements are acquired, the natural language description of the contract is generated, the generated natural language description of the contract is analyzed and converted into an intelligent contract code, grammar and logic verification are carried out on the intelligent contract code, the intelligent contract code with the verification passed is executed, and the execution process and the execution result are recorded in a distributed account book of a blockchain. According to the invention, the intelligent contract is automatically generated, so that the requirement on the programming capability of the participants is reduced, and the problems that the intelligent contract writing efficiency is low and errors are easy to occur in the prior art are solved. By introducing grammar and logic verification steps, the accuracy of the intelligent contract before execution is ensured, and potential risks caused by contract logic errors are avoided. Meanwhile, the contract executing process and the contract result are recorded in the distributed account book of the blockchain, so that the transparency of transaction and the safety of data are improved, the data is effectively prevented from being tampered, and the generation efficiency and the execution reliability of the intelligent contract are remarkably improved.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a schematic diagram of an application environment for a method for generating and executing a smart contract according to an embodiment of the invention;
FIG. 2 is a flow chart of an embodiment of a smart contract generation and execution method of the present invention;
FIG. 3 is a schematic diagram of functional blocks of a preferred embodiment of the smart contract generation and execution apparatus of the present invention;
FIG. 4 is a schematic diagram of a computer device according to an embodiment of the invention;
fig. 5 is a schematic diagram of another structure of a computer device according to an embodiment of the invention.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The intelligent contract generation and execution method provided by the embodiment of the invention can be applied to an application environment as shown in fig. 1, wherein a user side communicates with a server side through a network. The server side can collect transaction behavior data and transaction demand data of intelligent contract participants through the user side, construct a natural language understanding model based on the collected data, acquire contract requirements and generate natural language description of contracts, analyze and convert the generated contract natural language description into intelligent contract codes, conduct grammar and logic verification on the intelligent contract codes, execute the intelligent contract codes passing verification, and record execution processes and execution results in a distributed account book of a blockchain. According to the invention, the intelligent contract is automatically generated, so that the requirement on the programming capability of the participants is reduced, and the problems that the intelligent contract writing efficiency is low and errors are easy to occur in the prior art are solved. By introducing grammar and logic verification steps, the accuracy of the intelligent contract before execution is ensured, and potential risks caused by contract logic errors are avoided. Meanwhile, the contract executing process and the contract result are recorded in the distributed account book of the blockchain, so that the transparency of transaction and the safety of data are improved, the data is effectively prevented from being tampered, and the generation efficiency and the execution reliability of the intelligent contract are remarkably improved. The user terminal may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The server may be implemented by a stand-alone server or a server cluster formed by a plurality of servers. The present invention will be described in detail with reference to specific examples.
Referring to fig. 2, fig. 2 is a flowchart illustrating an embodiment of a method for generating and executing an intelligent contract according to the present invention. It should be noted that although a logical order is depicted in the flowchart, in some cases the steps depicted or described may be performed in a different order than presented herein.
As shown in fig. 2, the intelligent contract generating and executing method provided by the invention comprises the following steps:
S10, collecting transaction behavior data and transaction demand data of intelligent contract participants;
In this embodiment, the transaction behavior data refers to a specific behavior record of the smart contract participant in the past transaction, including but not limited to transaction time, transaction amount, transaction type, related asset, account, or information of both transaction parties. Through the data, the trading habits, risk preferences and trading modes of the participants can be judged, and a basis is provided for generating intelligent contracts meeting the requirements of the participants.
Transaction performance data may be collected through channels such as historical transaction records on interfacing financial institutions, transaction platforms, blockchains, and the like. The collection process can be automatically extracted from banking systems, exchanges, blockchain nodes and the like through an API interface, and can also be retrieved through a recording system inside a platform.
The collected transaction data may exist in various forms (e.g., JSON, XML, etc.), and should be formatted during the data collection process for subsequent data analysis and contract generation. The data from different sources is managed in a unified way by standardized data formats, such as structured transaction records.
The collected data may contain noise and repeated recordings, requiring data cleansing operations to ensure the integrity and accuracy of the transaction data. For example, the system may remove duplicate transaction records, fill in missing data fields, and correct for erroneous data.
Transaction demand data refers to the specific demands of the intelligent contract participants on future transactions. This includes requirements for terms of the contract such as funds transfer, execution conditions, asset delivery, transaction time node, etc. These demand data are the core information sources that generate personalized smart contracts.
Transaction demand data is typically provided by the participants, and the system may collect input from the participants through user interface interactions. The participants may provide their transaction requirements by filling out forms or selecting predefined templates. The demand data may also come from business documents (e.g., contracts, orders, etc.) of the participants or from existing demand systems.
To simplify the participant's demand input, the system may design a user-friendly interactive interface providing selectable demand options and drop-down menus to assist the user in defining transaction parameters. The automated recommendation system can automatically fill part of the demand items according to historical transaction behaviors of the participants, and complexity of user input is reduced.
The system will verify the inputted transaction demand data to ensure its integrity and logic. For example, the range of funds amounts, the validity of transaction time, etc., may be verified by logic checks during the input stage to avoid the occurrence of non-compliance terms during subsequent generation of contracts.
An example illustrates that in the financial domain, a bank provides automated block chain-based offer generation services to its enterprise customers. The bank automatically acquires past transaction behavior data of the clients through integrating an internal transaction system thereof, wherein the past transaction behavior data comprise the time, the amount, the transaction party and other detailed information of each transaction. In addition, banks allow customers to submit their future financial transaction needs, such as the amount of loan contracts, interest rates, repayment times, etc., via an interactive platform. Based on these collected data, the system automatically generates intelligent contract terms and verifies the logic thereof, ensuring the validity and contractual nature of the contract.
By automatically collecting transaction behavior data and transaction demand data of intelligent contract participants, the complexity of manual input and processing is avoided, and the efficiency and accuracy of data collection are improved. Through data cleaning and standardization processing, the integrity and consistency of the collected transaction behavior data are ensured, and a reliable data basis is provided for subsequent contract generation.
S20, constructing a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
In this embodiment, the natural language understanding model can understand and process natural language input based on transaction behavior data and transaction demand data of the participants, and generate intelligent contract terms conforming to a financial service scenario according to demands of the participants. The natural language understanding model learns language structures, semantics and business logic in the financial field through a deep learning algorithm, and ensures that generated contract clauses accord with industry standards.
Transaction behavior data (e.g., transaction history, transaction amount, account information) and transaction demand data (e.g., specific contract terms, execution conditions, transaction time, etc.) will be used as input data to a model that is trained to understand the needs of the participants.
The model-generated output is a natural language description of the contract, which may be executable contract terms, clearly expressing the responsibilities, obligations, and execution conditions of the contract parties.
Before the model is built, transaction behavior data and transaction demand data first need to be preprocessed. This includes data cleansing (removing noise data), data labeling (providing labels for training data), and format conversion (converting data into a format recognizable by the model). For example, the historical transaction record is formatted into standard financial transaction fields and annotated with transaction types and key parameters.
The contract demand data entered by the user is converted into a standard language structure, making it suitable for model training.
Existing pre-trained natural language processing models (e.g., BERT, GPT) can be used, which have been trained on a large corpus with good natural language understanding capabilities. On this basis, fine-tuning (fine-tuning) is performed on the data of the financial domain, making the model more suitable for generating financial contract terms.
And inputting the marked transaction behavior data and transaction demand data into a natural language understanding model for training. By means of supervised learning, the model is able to learn how to translate transaction demand data into natural language descriptions of contract terms. In the training process, the accuracy of the model can be evaluated by adopting a cross-validation technology in machine learning, and the learning rate, parameters and training round number of the model are adjusted so as to achieve the optimal model performance.
Fine-tuning refers to retraining data for a particular domain based on the use of pre-trained natural language models (e.g., BERT, GPT) to enable the model to understand domain-specific terms and language styles. For the financial field, the fine tuning process is critical because financial contracts have their specific language structure and legal requirements.
A labeling dataset for model fine tuning is created from actual contracts and transaction records of the financial industry. These data sets should cover the usual terms, terms of financial contracts, and various scenarios of transactions. The data sets are classified into different contract terms through the labeling of financial experts, so that the high quality of the training set is ensured.
Model fine tuning is achieved by adjusting parameters of a pre-trained model that will learn specific language features of the financial domain. This process may be accelerated using a GPU or TPU, reducing training time, and adjusting the convergence speed of the model through a dynamic learning rate.
The natural language understanding model generates a natural language description of the contract by analyzing transaction behavior data and transaction demand data of the participants. These descriptions cover the terms of the contract, execution conditions, and responsibilities of the parties, among other information. The description ensures that the semantics of the contract are accurate and the terms are clear, facilitating the understanding and execution of the contract by the parties.
The model, after obtaining the trading demand of the participant, converts the demand into corresponding contract terms. These terms are based on standard legal language, ensuring that they have legal effectiveness in contract execution. The model generates natural language description of contracts layer by layer through a multi-layer neural network, and ensures the correctness of grammar and logic.
The generated contract description may be automatically saved as an editable text format (e.g., TXT, DOCX, etc.), or converted directly into executable smart contract code. These descriptions may be further reviewed and modified manually to ensure that they meet specific business needs.
In the financial scenario, a bank generates a loan contract for a customer using a natural language understanding model based on customer transaction behavior data and demand data. The model automatically generates loan contract terms meeting the demands of customers by analyzing past loan records, repayment habits and input demands (such as loan amount, repayment period number and the like) of customers. For example, a 30 ten thousand yuan loan is required by a customer, the interest rate is 4%, the repayment period is 5 years, and the contract terms generated by the model clearly list the loan amount, repayment plan and corresponding interest rate terms.
By constructing a natural language understanding model based on the transaction behavior data and the transaction demand data of the participants, the contract natural language description meeting the demands of the participants can be automatically generated, and the time and complexity of contract writing are greatly reduced. Meanwhile, by fine tuning the natural language model, contracts with strong legal effectiveness and clear clauses in the financial field can be generated, and the accuracy and the executable performance of the contracts are ensured.
S30, acquiring contract requirements, and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
in this embodiment, contract requirements refer to specific requirements placed by the parties on the terms of the intelligent contract, including execution conditions, transaction amounts, asset types, delivery methods, time nodes, and so forth. These requirements constitute the core input for generating contract content, ensuring that the generated contract meets the business needs of the parties.
The participants can input contract requirements through the interactive interface, and the system guides the participants to fill in necessary information through preset input fields or templates, so that input errors are reduced.
When the system receives the contract requirement, preliminary data verification is carried out to ensure that all necessary fields are filled in, and the format and the content of the data accord with the basic requirement of the contract clause.
The system allows participants to select predefined contract templates or create contracts from scratch by providing a user-friendly interface. Input fields are provided on the interface and the participant can fill in specific contract requirements such as amounts, assets, execution conditions, time ranges, etc.
If the participant is unfamiliar with the contract terms, an existing contract template may be selected and the system directs the participant to fill out or adjust the personalized term content based on the template.
After the system obtains the user input, formatting processing, such as unifying currency units, is automatically performed to ensure data consistency and contract standardization.
Based on a pre-trained Natural Language Processing (NLP) model, the system is able to understand the contract requirements of the participants and generate a description of the contract terms in natural language. The model translates the user-entered transaction requirements into appropriate legal terms by learning the grammar and logical structure of the contract language.
The contract requirements provided by the participants are input into a model that analyzes the requirements and generates legal compliance contract terms based on existing contract templates or generation rules.
The content output by the natural language understanding model is a natural language description of the contract, including terms of responsibility, obligations, asset flows, etc. of the parties, ensuring that these terms can be properly interpreted and executed when the contract is executed.
The model generates a corresponding natural language description based on input content (e.g., funds, execution conditions, time, etc.) required by the contract. For example, if the requirement input by the party is "pay 50 ten thousand yuan, the term is 3 months", the model generates the contract terms that the party A should pay 50 ten thousand yuan for the Renminbi of the party B within 10 days after the contract is signed, and the party B should complete the delivery within 3 months after receiving the money. "
The natural language understanding model automatically generates complete contract terms that match the input requirements by feature extraction of the requirements entered by the user. The generation process utilizes the deep learning model to understand the financial contract terms, so that the legal language of the contract is ensured to be accurate and strict.
The system-generated contract terms can be automatically saved as editable text formats (e.g., DOCX, PDF) for review and signing by the parties.
After the contract terms are generated, the system performs a logical check to ensure that no conflicts exist between terms. Especially when multiple execution conditions and time nodes are involved, the model automatically detects whether the context of the clause is reasonable.
After the contract clauses are generated, the system also performs consistency check to ensure that the descriptions of all clauses meet the requirements of the participants and that no contradiction occurs between different clauses.
The system integrates automated verification tools that use a rule-based engine to check whether the generated contract terms meet business logic, such as the rationality of terms of payment terms, delivery conditions, funds transfer, and the like.
If a logical error or a clause conflict is found during the verification process, the system will feed back to the user in real time and make a modification suggestion. For example, if the delivery time conflicts with the payment time, the system may prompt the parties to modify these time terms to ensure that the contract is performed successfully.
An example illustrates that in the financial field, an investment company needs to generate a customized asset management contract for its customers. The company inputs the customer's asset management needs, including the asset category being managed, the amount distribution, the management deadline, and the reporting objectives, through the system interface. The natural language understanding model generates an asset management contract containing a natural language description of all key terms based on these requirements. Contracts describe details of the company's management responsibilities for the different asset classes, revenue distribution rules, and rewards objectives.
The contract requirements of the participants are automatically acquired, and the corresponding contract natural language description is generated by using the natural language understanding model, so that the difficulty and the error rate of manually writing the contract are greatly reduced. The system can ensure that the generated contract terms meet the specific requirements of the participants and ensure the strictness and consistency of the contract terms through automated logic verification. Meanwhile, the participants can easily input contract requirements through the interactive interface, so that the efficiency and accuracy of intelligent contract generation are obviously improved.
S40, analyzing and converting the natural language description of the contract into an intelligent contract code;
in this embodiment, parsing of the natural language description refers to converting contract terms generated by the natural language understanding model into a structured data form (e.g., variables, conditions, etc.). These structured data can be mapped into the code logic of the smart contract, ensuring that the semantics of the contract terms can be executed by the computer.
The system analyzes the generated contract clauses through a natural language processing tool, and extracts key elements related in the contract, such as execution conditions, payment amount, participants and the like. The parsed result will be converted into normalized fields for use in generating code.
Intelligent contract transcoding refers to converting parsed contract structured data into intelligent contract code. The code is a programming language capable of executing on a blockchain platform, such as Solidity or other smart contract language.
The system selects the applicable intelligent contract code template according to the analysis result, and fills related variables and logic (such as payment amount and execution conditions). Templates contain basic contract architecture such as functions and trigger conditions. The system dynamically associates contract terms with the logic of the code template and automatically generates a complete intelligent contract code.
The generated smart contract code is code that is automatically generated and contains contract term execution logic. The code is to be used to deploy and execute the smart contract on the blockchain.
The system gathers the filled templates to generate executable contract code files. The file can be directly uploaded to the blockchain platform for compiling and deployment, so that the file can be automatically executed when the condition is met.
Through the steps, the system can automatically convert the contract description of the natural language into the intelligent contract code, thereby avoiding the complexity and potential errors of manually writing the code and simplifying the contract generation process.
S50, carrying out grammar and logic verification on the intelligent contract codes in a distributed node network of a blockchain;
In this embodiment, the distributed node network of the blockchain refers to a network formed by a plurality of decentralised nodes, and each node can independently verify the content, logic and execution result of the intelligent contract. The decentralization feature of the blockchain network ensures transparency and reliability of the contract validation process, avoiding single point failure problems.
In a distributed network, nodes verify deployment, execution, and status updates of smart contracts through consensus mechanisms (e.g., poW, poS, etc.). Each node independently executes verification operation to ensure the legitimacy of the contract code. The blockchain node runs a verification tool of the intelligent contract code, such as a compiler of Solidity codes, to ensure that the codes can be normally parsed and meet the execution requirements of the blockchain.
Syntax verification refers to checking whether the smart contract code complies with the syntax rules of the programming language, ensuring that the code can be properly compiled and deployed in the blockchain network. Grammar validation can prevent contracts from being unable to execute due to misspellings, format errors, or unclaimed variables.
Syntax checking is performed using a blockchain platform specific compiler, such as compiler solc of Solidity. Before deployment, the contract codes are compiled by a compiler firstly, so that the grammar of the codes is ensured to be free of errors. If grammar errors are found, the system returns error information to prompt the developer to modify. The compiler will detect syntax errors such as undefined variables, bracket matching problems, function call errors, etc.
Logic verification refers to checking whether logic in an intelligent contract is reasonable or not, whether the logic meets an expected execution flow or not, and logic loopholes or potential attack risks are avoided. For example, checking whether the condition judgment, the loop structure, and the status update in the contract meet the set business logic.
The system may analyze the logic of the contract code through a static analysis tool or formal verification tool. For example, intelligent contract analysis tools such as Slither or MythX are used to detect logical vulnerabilities in intelligent contract code (e.g., reentry attacks, integer overflows, conditional forensics, etc.).
Logic verification also includes checking of business logic, such as checking if payment is properly triggered, if contract status updates are legitimate, etc. The system simulates the execution of the smart contract to ensure that the contract performs as expected under different conditions.
The distributed nodes of the blockchain participate in the validation process of the contract together through a consensus mechanism. Each node independently runs the contract code, and agrees with other nodes through the verification result, and the consensus process ensures the credibility of the contract code and execution.
In a blockchain network, each node independently verifies the syntax and logic of the smart contract. If a node finds that the syntax or logic of a contract is problematic, the node may refuse the deployment or execution of the contract. The consensus mechanism ensures that all nodes in the network agree on a common validation contract. The verification result is broadcast in the blockchain network, other nodes synchronize the verification result, and the verified intelligent contract state is updated to the blockchain, so that the state consistency of all the nodes is ensured.
The verification tool feeds back the grammar and logic check result of the contract, if the verification is passed, the contract will enter the execution stage, if the verification is not passed, the system will return error information to prompt the developer to modify the code.
The system generates verification reports including grammar errors, logic problems, etc. through the output results of the compiler and the logic verification tool. The contract developer may make debugging and modification based on the detailed information in the report. After the verification is passed, the contract enters a deployment flow on the blockchain to prepare for execution.
By means of grammar and logic verification of the intelligent contract codes in the distributed node network of the blockchain, the intelligent contract codes are ensured to accord with the programming language specifications before deployment, and contract deployment failure caused by grammar errors is avoided. Meanwhile, the logic verification identifies potential logic loopholes or safety problems by analyzing the execution flow of the contracts, and ensures the safety and reliability of the execution process of the contracts.
S60, executing the intelligent contract code when grammar and logic verification pass;
In this embodiment, when the smart contract code passes the compiler's grammar verification and the security and rationality checks of the logic verification tool, it means that the contract already has conditions executing on the blockchain network.
Execution preparation includes deployment of contracts, initialization, and configuration of the execution environment. At this point, the blockchain system allocates resources for the smart contract and prepares the operating environment to start the contract.
The system confirms that the contract is validated through a consensus mechanism of the block link point network and enters a stage of deployment execution. The contract will be deployed to some smart contract account on the blockchain awaiting automatic execution when execution conditions are met.
Smart contracts typically set certain execution conditions such as time, transaction completion, funds reaching a certain threshold, etc. When these conditions are met, execution logic of the smart contract code will be triggered, initiating the corresponding operations, such as funds transfer, asset delivery, etc.
An event listener is arranged in the intelligent contract, and when the triggering condition in the contract is met, the system automatically calls related functions in the contract. For example, when a payment is completed, a "payment success" event in the smart contract is triggered and the system automatically executes the corresponding operating logic.
The contract execution functions are core functional parts in the contract code, including transfer of funds, delivery of assets, updating of status, and the like. Each smart contract contains a plurality of functions that, when executed, perform corresponding operations according to the terms of the contract.
When the execution condition of the contract is satisfied, the system automatically calls the corresponding function in the contract. For example, in a lending contract, when a repayment condition is satisfied, the contract automatically calls repayLoan () function to perform a repayment process. During execution of the contract, the system updates the associated state variables and performs operations according to the terms of the contract.
During execution of the contract, state variables in the contract are updated based on the results of the execution. For example, in a payment contract, the payment status is updated from "unpaid" to "paid" and information such as time, amount, etc. is recorded.
The state variables of the contract are stored in a distributed ledger of the blockchain. When execution of the contract is completed, all participating nodes synchronously update the state of the contract, ensuring that all nodes in the network keep consistent with the state of the contract.
After execution of the contract is completed, the system notifies the associated parties to the contract of the execution via a blockchain event mechanism. The results of the feedback typically include whether the operation was successful, the amount of execution, the status of the asset delivery, etc.
The system pushes the execution result of the contract to all relevant nodes and participants through an event broadcasting mechanism of the blockchain. For example, after a payment contract is completed, the system may broadcast a message that the payment was successful and all relevant participants (e.g., funds recipients) will be notified.
An example illustrates that in the financial domain, an investment company generates an asset management contract for a customer. The contract specifies that after a customer deposits 100 ten thousand yuan, the system will automatically trigger the asset management service and transfer funds to the designated account. The contract is deployed to the blockchain after being verified by syntax and logic.
Triggering execution conditions, namely automatically detecting that conditions are met by contracts when the amount of money deposited by a client reaches 100 ten thousand yuan, calling STARTASSETMANAGEMENT () functions and starting asset management service.
The function performs the steps of transferring funds from the customer account to the asset management account and updating the contract status on the blockchain, marking that asset management has begun.
And (3) feeding back results, namely informing clients and asset management parties of the completion of the funds transfer by the system through a block chain event broadcasting mechanism, and formally starting the asset management.
After syntax and logic verification, the contract code can be executed safely and reliably in the blockchain network. Ensuring that the smart contract is only executed after all verifications are passed reduces the risk of code errors or vulnerabilities. In the contract execution process, all operations are automatically triggered according to preset conditions, so that manual intervention is avoided, transparency and non-tamper property of an execution result are ensured, and the automation level and the execution efficiency of the intelligent contract are improved.
S70, recording the execution process and the execution result of the intelligent contract code in a distributed account book of a blockchain.
In this embodiment, all operational steps and state changes are recorded during execution of the smart contract. This includes each function call of the contract, transfer of funds, delivery of assets, update of status, and so on. Recording these processes helps to ensure transparency and traceability of contract execution.
The distributed account book of the blockchain records the contract executing process in each node, so that each node is ensured to store the same executing record, and tampering or loss is prevented.
At each stage of execution of the smart contract, the system captures the operations in the execution and generates a log. These logs include hash values of transactions, time stamps of operations, status of execution, etc. Each operation log is broadcast to the distributed node network of the blockchain, so that each node is ensured to be synchronously stored.
These records will be stored in the blockchain's blocks, as part of the blockchain ledger, and kept permanently, ensuring that queries and verifications can be made in the future.
The execution result record refers to the end result after the execution of the contract is completed, such as whether the transaction was successful, whether funds were transferred, whether the asset delivery was completed, etc. The result records ensure that the status of each contract execution can be unequivocally represented.
After the contract is executed, the system writes the result of execution (such as "transaction successful", "funds transferred", "assets delivered", etc.) as a result log into the distributed ledger. These results include critical information such as the status of success or failure, the transaction details involved, time stamps, etc.
The blockchain node broadcasts the result information to all participating distributed nodes, ensures that all nodes save the same execution result, and updates the respective ledger records.
Each record (including contract execution and results) is provided with a unique time stamp that marks the point in time at which the operation occurred. The time stamp ensures a clear time sequence for each transaction and operation and provides a reliable traceback mechanism.
The system automatically generates a corresponding timestamp for the execution step and the final result for each contract. The time stamp is generated by using a time mechanism built in the block chain, so that the time stamp is guaranteed to be tamper-proof, and all nodes agree on the time stamp through a consensus mechanism.
All records of the contract execution process and results are synchronized through the distributed storage mechanism of the blockchain, and all nodes each store a copy. The distributed storage mode ensures the security and reliability of the record and prevents single-point faults and data loss.
The system will broadcast detailed records and results of contract execution to each node in the network through the blockchain consensus mechanism. Each node stores the execution log and results in a block, forming a permanent record on the chain. The distributed ledgers for each node remain consistent and do not allow for individual modification of records.
The execution process and result of the contract can be queried at any time in the distributed ledger of the blockchain. Due to the non-tamperable nature of the blockchain, anyone can verify that the execution of the contract meets the contract terms and ensure the authenticity of the results.
Through a blockchain browser or API interface, the contract participants may query execution records of the contract, verify whether funds are transferred as specified by the contract, whether asset delivery is completed successfully, and so on. The query result is based on public records on the blockchain, and transparency and tamper resistance are guaranteed.
By recording the execution process and execution result of the intelligent contract in the distributed ledger of the blockchain, transparency and traceability of contract execution are ensured. Each execution step and each result have an explicit timestamp and operation log, so that the record is tamper-proof and safe. The distributed storage mechanism ensures high availability and reliability of data, and records can be restored through other nodes even if one node fails. The credibility and the execution efficiency of the intelligent contract in sensitive fields such as finance and the like are improved.
The invention relates to the technical field of artificial intelligence and the field of financial science and technology, and discloses an intelligent contract generation and execution method, which comprises the steps of collecting transaction behavior data and transaction demand data of intelligent contract participants, constructing a natural language understanding model based on the collected data, acquiring contract requirements and generating natural language description of the contract, analyzing and converting the generated natural language description of the contract into an intelligent contract code, carrying out grammar and logic verification on the intelligent contract code, executing the intelligent contract code which passes the verification, and recording the execution process and the execution result in a distributed account book of a blockchain. According to the invention, the intelligent contract is automatically generated, so that the requirement on the programming capability of the participants is reduced, and the problems that the intelligent contract writing efficiency is low and errors are easy to occur in the prior art are solved. By introducing grammar and logic verification steps, the accuracy of the intelligent contract before execution is ensured, and potential risks caused by contract logic errors are avoided. Meanwhile, the contract executing process and the contract result are recorded in the distributed account book of the blockchain, so that the transparency of transaction and the safety of data are improved, the data is effectively prevented from being tampered, and the generation efficiency and the execution reliability of the intelligent contract are remarkably improved.
In one embodiment, the step S10 includes:
s101, extracting transaction behavior data from a transaction platform of an intelligent contract participant;
S102, acquiring transaction demand data from a document library of an intelligent contract participant;
S103, performing data cleaning operation on the transaction behavior data and the transaction demand data;
S104, converting the transaction behavior data and the transaction demand data after the data cleaning operation into a unified data format.
In this embodiment, the transaction behavior data refers to all behavior records of the smart contract participants in past transactions, including detailed information of transaction time, amount, transaction type, transaction opponents, and the like. These data reflect the historical transaction patterns, behavioral habits, and preferences of the participants, providing data support for generating intelligent contracts.
The system automatically extracts transaction data by API integration with the transaction platform of the intelligent contract participants. Such data may be obtained from sources such as banking systems, blockchain transaction platforms, e-commerce platforms, and the like.
The system periodically extracts transaction data from the platforms in batches, so that the integrity of the transaction records is ensured. The latest transaction data can be obtained in a time window mode, so that the real-time property of the data is ensured.
Transaction demand data refers to the demands of participants on future transactions, such as expected transaction terms, funds transfer, contract conditions, etc. The document library may contain documents of business demand files, historical contracts, invoices, orders, etc. of the participants, the demand information stored in these documents being critical to the generation of the intelligent contracts.
The system extracts key information from the participant's document library through automated document processing tools such as OCR (optical character recognition) technology or Natural Language Processing (NLP) models. The parsed transaction demand data will be stored in a structured manner for subsequent use.
The system is integrated with a document management system (such as an enterprise document management system, cloud storage and the like) of a participant, and new demand data is periodically scanned and extracted, so that the latest business demands can be considered when contracts are generated.
And cleaning the extracted transaction behavior data and transaction demand data, removing repeated, wrong and invalid data, and ensuring the accuracy and consistency of the data. Data cleansing is a key step in data processing, ensuring that subsequent smart contracts generate high quality data sources.
The system first removes duplicate transaction records and invalid demand documents. For example, multiple identical transaction entries may be kept only once, and transaction records in error format may be marked and excluded. The system also checks the integrity and accuracy of the data according to predefined rules to ensure that the data meets the requirements of contract generation.
And correcting or filling partial missing or incomplete data. For example, if the date of a transaction is missing, the system may automatically populate this field via historical data or default values. All data correction is automatically carried out according to the business rule, so that manual intervention is avoided.
The unified data format refers to converting the cleaned transaction behavior data and transaction demand data into a system standard format, so that subsequent processing and contract generation are facilitated. By unifying the formats, it can be ensured that the system can consistently parse and use data from different sources.
The system uses data conversion tools to convert transaction and demand data of different sources, different formats (e.g., JSON, XML, CSV formats, etc.) into a unified standard data structure. For example, the system may convert all transaction data into a structured JSON format, ensuring consistency of all fields (e.g., time, amount, transaction type, etc.).
Fields in the transaction data (e.g., the "amount" field may come from different platforms, have different units or formats) are standardized. The system defines a unified field name and format to ensure that data from different sources can be seamlessly joined in the subsequent contract generation process.
According to the embodiment, the transaction behavior data and the demand data are extracted from the transaction platform and the document library of the intelligent contract participants, the system can automatically acquire the detailed transaction history and the demand of the participants, manual intervention is reduced, and the data integrity is improved. The data cleaning operation ensures the accuracy and consistency of the data and avoids the influence of error data on contract generation. Through unified data format conversion, the system can ensure standardized processing of data, and high-quality data support is provided for subsequent intelligent contract generation.
In one embodiment, the step S20 includes:
S201, marking the transaction behavior data and the transaction demand data, and generating a tag data set for training a model;
s202, determining a basic natural language model, and setting the learning rate and training round number of the basic natural language model;
S203, training the basic natural language model by using the tag data set according to the learning rate and the training round number so as to adjust parameters of the basic natural language model;
s204, when training is completed, the natural language understanding model is obtained.
In this embodiment, the data labeling refers to classifying and labeling the collected transaction behavior data and transaction demand data, and generating a tag data set for training a natural language understanding model. The purpose of the labeling is to enable the model to identify and understand key features in the data, such as contract elements of transaction amounts, transaction conditions, participants, etc.
The system first pre-processes transaction behavior data and transaction demand data, and classifies key information (such as transaction time, amount, transaction type and the like) and demand data (such as contract terms, execution conditions and the like) of each transaction.
The system combines a machine learning model and a manual mode to carry out data annotation. Manual labeling may be used for more complex contract elements, while automatic labeling marks common contract fields based on predefined rules or models. After the labeling is completed, the system generates a label dataset for training the natural language model.
The underlying natural language model refers to a natural language processing model for intelligent contract generation, typically based on a pre-trained deep learning model, such as BERT, GPT, etc. The model enables the understanding and generation of natural language conforming to the terms of intelligent contracts by fine tuning language data related to the financial field.
The learning rate determines the stride size of the model to adjust the parameters in each iteration, and the number of training rounds refers to the number of times the entire data set is entered into the model and the parameters are updated. The proper learning rate and training round number can help the model effectively adjust parameters in the learning process, and prevent over fitting or under fitting.
The system may choose to be based on pre-trained natural language models, such as BERT, GPT, etc. These models have been trained on a large corpus with a strong language understanding capability, enabling refined contract generation tasks.
The system selects the proper learning rate and training round number through experiments. The learning rate is usually optimized by a grid search method, a random search method and the like, and the training round number is dynamically adjusted according to the performance of the model. For example, a smaller learning rate helps the model learn complex contract term logic more stably.
Training the basic natural language model by using the marked transaction behavior data and the demand data set. The purpose of training is to enable more accurate generation of natural language descriptions of contracts by adjusting the parameters of the model. Through multiple training iterations, the weight and bias parameters of the model are continuously adjusted to improve the accuracy of the model in terms of the constraint.
The system will input the tag dataset into a pre-selected natural language model. During the training process, the model learns the structure and language mode of the contract terms according to the inputted transaction behavior data and the demand data. After each training round, the parameters of the model are adjusted according to the error feedback, so that the input data can be better understood. During each round of training, the system will use the validation set to evaluate the performance of the model and adjust the hyper-parameters (e.g., learning rate) of the training based on the results. To ensure the effectiveness of the model for the intelligent contract generation task, the system may also use evaluation metrics such as accuracy, recall, F1 score, etc.
The trained model can generate accurate natural language contract description according to the input transaction behavior data and the demand data. The model has the ability to understand and generate complex financial contract terms, enabling automated generation of compliant contract terms. After training, the system tests the model to ensure that the generated contract clauses are accurate. Through evaluation of the test set, the system verifies the behavior of the model in handling different types of contract requirements. After verification is passed, the model is used for automatically generating contract clauses meeting transaction requirements and can be applied to a real intelligent contract generation scene.
In the embodiment, the system can construct a natural language understanding model for intelligent contract generation by marking and training the transaction behavior data and the transaction demand data. The model can accurately generate contract clauses meeting the demands of participants by optimizing the learning rate and the training round number, and reduces the complexity and potential errors of manually writing contracts. The trained model has the capability of understanding and generating contract clauses, and the efficiency and accuracy of intelligent contract generation are greatly improved.
In one embodiment, the step S30 includes:
s301, displaying an interactive field for inputting contract requirements by an interactive interface so that an intelligent contract participant can input the contract requirements;
S302, receiving contract requirements comprising execution conditions and execution time;
S303, converting the contract requirements into natural language descriptions of contracts by using the natural language understanding model.
In this embodiment, the interactive input field refers to a series of input boxes or options provided by the system to the intelligent contract participants for filling in or selecting specific requirements associated with the contract. Through the interactive interface, the participant may enter his contract requirements, such as transaction amount, asset transfer conditions, execution time, etc.
The user-friendly input interface is simple and visual in design, ensures that a user can fill in the requirements easily, and reduces input errors. The interaction fields may include text boxes, date selectors, drop-down menus, etc., that assist the user in entering information efficiently.
The interface provided by the system contains a number of fields for the participants to enter or select key information for the contract. For example, the fields include transaction amount, asset type, delivery conditions, etc. The interactive interface is presented through the Web or mobile application and can be integrated through an API. The system can perform preliminary verification on the data input by the user, and ensure the integrity and format correctness of the data. For example, the transaction amount must be a number and the execution time must be a valid date.
The execution condition refers to a trigger condition of contract execution. For example, in a payment contract, the execution condition may be a fund check-out, and in an asset delivery contract, the execution condition may be agreement of both parties or completion of the delivery of the funds.
The execution time refers to a time node of contract execution and may be a fixed date or a dynamically triggered time range. The execution time is closely related to the execution conditions, ensuring that execution is approximately within the correct time frame.
In the interactive interface, the user may input or select an execution condition (e.g., "execute after receipt of money") and an execution time (e.g., "execute within 2024, 12 months, 31 days" or "execute within 10 days"). The system receives this information through a predefined template or free format.
After receiving the execution conditions and execution time, the system can check to ensure that the input conditions and time are reasonable and accord with logic. For example, it is ensured that the execution time is not earlier than the signing date of the contract, or that the triggering logic of the condition is consistent with the actual business scenario.
Through a natural language understanding model, the system is able to understand contract requirements entered by participants and translate those requirements into a natural language description of the contract. The model can generate clear contract clauses, ensure that the language expression of the clauses is accurate and accords with legal and business specifications.
The system first converts contract requirements such as execution conditions, execution time and the like input by a user into structured data. These data are then generated into a natural language description of the contract using a natural language understanding model. For example, the user inputs "deliver goods within 10 days after payment is completed" and the system automatically generates that "the first party should deliver goods to the second party within 10 days after payment is completed and the delivery location is the designated location of the second party. "
The natural language understanding model is finely tuned through transaction behavior data and historical contract data, and generated clauses are ensured to meet business requirements. The generated natural language contract clauses need to pass through the logical check and legal compliance check of the system to ensure that the generated clauses conform to the actual business scenario.
According to the embodiment, the contract requirements are collected through the interactive interface, the contract clauses are generated by using the natural language understanding model, and the system can greatly simplify the intelligent contract generation process. The natural language understanding model not only ensures that the generated contract description meets business logic and legal specifications, but also dynamically generates personalized contract terms according to the requirements input by the user. By setting the execution conditions and the execution time, the contract can be automatically executed when the conditions are met, and the automation level and the accuracy of contract execution are improved.
In one embodiment, the step S40 includes:
S401, parsing the natural language description of the contract into a structured representation of contract terms;
s402, determining an intelligent contract code template according to the structural representation;
S403, filling parameters in the structured representation into the intelligent contract code template to generate a complete intelligent contract code.
In this embodiment, parsing of the natural language description refers to parsing and semantic analysis of contract requirements (e.g., description in natural language form of payment terms, asset transfer, etc.) entered by the user and converting them into structured data representations that can be processed by the computer. For example, the payment amount, time conditions, etc. will be resolved into specific parameters and logic conditions.
The structured representation refers to converting the natural language terms of the contract into a unified, computer-processable data format, such as JSON, XML, or other format, facilitating automated processing of subsequent operations.
The system uses the NLP engine to parse the natural language description of the contract, extract the key information and convert it into structured data. The analyzed content includes terms of execution condition, amount, time, participant, etc.
The system ensures that each term in the natural language description can be mapped correctly to the execution logic of the contract through the semantic analysis model. For example, "deliver goods within 7 days after payment" will be mapped to a time condition in contract execution.
The intelligent contract code template refers to an infrastructure framework of the contract code and defines functions, condition judgment and event processing mechanisms used in the contract. The functions and logical frameworks in the template are generic and can accommodate different types of contract generation. The system automatically selects or generates an appropriate smart contract code template based on the parsed structured representation (e.g., payment condition, execution time). The template contains basic contract logic such as payment flows, asset transfer, conditional triggers, etc.
The system maintains a code template library containing common contract types such as payment contracts, loan contracts, asset transfer contracts, and the like. The system selects the appropriate templates by matching key fields in the structured data. For example, for a payment contract, the system may select a template that includes funds-transfer logic.
For complex or highly customized contracts, the system dynamically generates the appropriate code templates from the structured representation. The functions and conditions in the templates may be adjusted according to the specific needs of the user.
The system populates the corresponding variable locations in the smart contract code template with specific parameters (e.g., amount, time, participants, etc.) in the structured representation to generate a complete smart contract code. For example, the amount, time, and execution conditions will be variables in the code.
Smart contract code refers to code that contains all contract terms and execution logic that can be automatically executed on a blockchain platform (e.g., ethereum, hyperledger, etc.). The code contains the main logical structure of the contract, variable definitions and condition judgments. The code generation engine of the system automatically populates the parameters to corresponding locations in the template based on the structured data.
The system formats the generated smart contract code into programming languages (e.g., solidity, chaincode, etc.) supported by the blockchain platform, ensuring that the contract can be successfully executed in a distributed environment.
According to the embodiment, the natural language description is analyzed and converted into the intelligent contract code, so that the system automates the generation process of the intelligent contract, and the requirement on the programming capability of a user is reduced. The parsing and structuring process of the natural language description ensures that the generated contract code is accurate and executable. The intelligent contract code templates are automatically selected and dynamically generated, so that the system can flexibly cope with different types of contract demands, and the generation efficiency and adaptability of intelligent contracts are improved.
In one embodiment, the step S60 includes:
S601, checking whether the execution condition of the intelligent contract code is met when grammar and logic verification are passed;
s602, when the execution condition of the intelligent contract code is confirmed to be met, calling a function in the intelligent contract code, and executing corresponding contract operation;
S603, updating the state of the intelligent contract participant according to the executed contract operation;
s604, recording an execution result of the intelligent contract code;
S605, notifying the execution result to the intelligent contract participant through a blockchain event mechanism.
In this embodiment, after the smart contract code is generated, it must be checked by the syntax verification and logic verification tool of the compiler. The contract operation can be performed only when the syntax and business logic of the contract code have no errors.
The contract execution conditions are trigger points for contracts, such as "funds to account" in a payment contract, "asset delivery" in an asset contract, and so forth. Before execution of the contract, the system checks whether these conditions are met to ensure that execution of the contract is in compliance with expectations.
The validator built in the system periodically checks the execution condition of the contract. For example, in a payment contract, the system checks the payment status, whether funds are available, and allows the contract to continue execution if the conditions are met.
The system may acquire the condition data required for contract execution in real time through interface integration with external data sources (e.g., payment gateway, supply chain system, etc.). For example, if funds are involved in a contract for a statement, the system may query the bank system for a transaction record.
Each smart contract contains a number of predefined functions that implement the specific execution logic of the contract. Such as funds transfer, asset delivery, status change, etc. When the execution condition is satisfied, the system automatically calls the corresponding contract function to complete the contract operation.
When the system detects that the contract conditions have been met, the functions defined in the contract will be automatically invoked. For example, in a loan contract, when the repayment date arrives, the system may call a repayment function PAYINSTALLMENT (), and a repayment operation is performed.
Through the event monitoring mechanism of the block chain, the system can monitor the occurrence of events in real time, and when the triggering condition is met, the contract function is automatically called for operation. Such as a audit event or asset delivery event.
During execution of the intelligent contract, the status of the participants (such as account balance, transaction status, property ownership, etc.) is updated according to the execution result of the contract. For example, in a payment contract, the balance of the payer decreases after execution and the balance of the payee increases.
The state variables in the smart contracts will be automatically updated based on the results of the execution of the functions. For example, in a funds transfer contract, the balance status of the payer is updated from balance=1000 to balance=900. The system automatically updates and saves the state to the blockchain's distributed ledger.
After each contract operation is completed, the system triggers state update according to an event mechanism to ensure the state synchronization of all nodes. For example, in an asset delivery contract, the status of the buyer and seller's asset may be updated immediately after delivery is completed.
After each contract is executed, the system records the execution result of the contract and stores information such as operation, participators, fund flow direction and the like in the execution process. These records will be stored in a distributed ledger of the blockchain, ensuring that the execution results are traceable and non-tamper-evident.
When the contract is executed, the system generates a series of logs including the function executed, the operation time, the result state, etc. These logs are stored in the blockchain transaction records as part of the contract execution history.
The system broadcasts the execution result to all nodes in the blockchain network, ensuring that all participating nodes synchronously save the result. For example, the result of the "payment complete" execution is written to the blockchain, and all nodes save this information.
Blockchain platforms typically have built-in event notification mechanisms for notifying relevant parties of the results after execution of a contract. The participants may obtain the execution status of the contract in real time through an event mechanism.
After the execution of the contract is completed, the system sends the execution result of the contract to all relevant parties through an event notification mechanism. For example, the payee may receive a notification of "successful receipt" after the funds are paid out. The system will broadcast the execution result to all the parties associated with the contract via the broadcast mechanism of the blockchain.
The participant can also query the execution result of the contract through the API of the blockchain or the intelligent contract interface, so that the transparent and public operation result is ensured. For example, the buyer and seller may query the results of the transaction and the asset delivery through the blockchain.
The embodiment ensures that the intelligent contract can be executed only when the conditions are met through strict execution condition checking, and avoids errors or accidents in contract execution. The system automatically calls the contract function and updates the state, so that manual intervention is reduced, and the execution efficiency and accuracy are improved. Through the event mechanism of the block chain, the system can inform the participant of the execution result in real time, ensure the transparency and traceability of the contract and improve the credibility and safety of the contract.
In one embodiment, the step S70 includes:
S701, encrypting data and operation records generated in the execution process of the intelligent contract code by using an asymmetric encryption module to generate an encryption record in the execution process;
s702, encrypting an execution result generated after the execution of the intelligent contract code is completed, and generating an encrypted record of the execution result;
s703, attaching corresponding time stamps to the encryption record of the execution process and the encryption record of the execution result;
S704, writing the encrypted record of the execution process, the encrypted record of the execution result and the corresponding timestamp into a distributed account book of a blockchain.
In this embodiment, asymmetric encryption uses a pair of public and private keys, the public key being used to encrypt data and the private key being used to decrypt data. The encryption mode ensures that the data in the execution process can be decrypted and checked only by an authorized party, and ensures the safety of the data.
The encrypted record of the execution process refers to a log record formed by encrypting generated data (such as function call, operation time, fund circulation and the like) during the execution of the intelligent contract. These encrypted records will be used to save details of the performed operation.
The system integrates an asymmetric encryption module for encrypting data generated during execution. After each operation record is generated, the system encrypts the operation record by using a preset public key, so that only legal users with private keys can decrypt the operation record. Each contract operation (e.g., funds transfer, status update) is logged, and the log content is encrypted with a public key. The generated encrypted record contains detailed information such as time, content, etc. of the operation.
At the conclusion of execution of the smart contract, final execution results are generated, such as whether the funds transfer was successful, the status of the asset delivery, etc. To protect these results, the system encrypts them, preventing unauthorized users from getting contract execution details. The encrypted record of the execution results contains the final state of execution and related details such as funds flow, transaction completion, etc. After encryption, the results can only be viewed by the authorized party.
When the execution of the smart contract ends, the system generates an execution result and encrypts with the public key. For example, the system generates a result of "payment success" or "payment failure" after the payment contract is ended, and encrypts this information to store in the ledger. The system encrypts key information (such as transaction state and amount) in the execution result to ensure that the sensitive information can only be read by legal users.
Each execution and record of results of execution is given a time stamp, marking the specific time at which the operation occurred. This ensures that the chronological order of each operation and execution result is clearly visible and provides a reliable traceback mechanism.
The system utilizes the time mechanism of the blockchain platform to automatically generate a timestamp for each record. The time stamp will be based on the common time of the blockchain nodes to ensure that all nodes synchronize the time at which the operation occurs.
The system automatically appends the current time stamp when the encrypted records are generated, so that each encrypted record is provided with an explicit time stamp for subsequent verification and traceability.
The distributed ledger of the blockchain holds all operations and results during execution of the contract. By writing these encrypted execution records and results, all blockchain nodes synchronize these data, ensuring ledger consistency and non-tamper ability.
The system writes the encrypted execution records and execution results, as well as their timestamps, into the ledger via the blockchain transaction mechanism. Each node receives the records and saves them in a local distributed ledger.
All nodes confirm and synchronize the encrypted records through a block chain consensus mechanism, so that consistency of the records stored in the account book is ensured, and any single node cannot tamper with the execution records or results.
In the embodiment, the asymmetric encryption module is used for encrypting the execution process and result of the intelligent contract, so that the security and privacy protection of contract execution data are ensured by the system. The encrypted record can only be decrypted and checked by an authorized party, so that data leakage is prevented. The time stamping mechanism provides an accurate time stamp for each encrypted record, so that the contract execution process has high transparency and traceability. Through the storage mechanism of the distributed account book, all nodes synchronously store the encryption records, so that the consistency and the non-tamper property of data are ensured, and the safety and the credibility of the system are enhanced.
In an embodiment, there is provided an intelligent contract generating and executing apparatus that corresponds one-to-one to the intelligent contract generating and executing method in the above embodiment. Referring to fig. 3, fig. 3 is a schematic diagram illustrating functional modules of a smart contract generation and execution apparatus according to a preferred embodiment of the present invention. A data collection module 10, a model construction module 20, a contract generation module 30, a code generation module 40, a code verification module 50, a contract execution module 60, and a record and storage module 70. The functional modules are described in detail as follows:
A data collection module 10 for collecting transaction behavior data and transaction demand data of the intelligent contract participants;
A model construction module 20 for constructing a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
A contract generation module 30 for obtaining contract requirements, generating a natural language description of the contract according to the contract requirements using the natural language understanding model;
A code generation module 40 for parsing and converting the natural language description of the contract into an intelligent contract code;
A code verification module 50 for performing syntax and logic verification on the intelligent contract code in a distributed node network of a blockchain;
a contract execution module 60 for executing the smart contract code when the grammar and logic verification pass;
a recording and storing module 70, configured to record the execution process and the execution result of the smart contract code in a distributed ledger of a blockchain.
In one embodiment, the data collection module 10 is specifically configured to:
extracting transaction behavior data from a transaction platform of an intelligent contract participant;
Acquiring transaction demand data from a document library of an intelligent contract participant;
performing data cleaning operation on the transaction behavior data and the transaction demand data;
And converting the transaction behavior data and the transaction demand data after the data cleaning operation into a unified data format.
In one embodiment, the model building module 20 is specifically configured to:
Labeling the transaction behavior data and the transaction demand data to generate a label data set for training a model;
Determining a basic natural language model, and setting the learning rate and training round number of the basic natural language model;
Training the basic natural language model by using the tag data set according to the learning rate and the training round number so as to adjust parameters of the basic natural language model;
and when training is completed, the natural language understanding model is obtained.
In one embodiment, the contract generation module 30 is specifically configured to:
displaying, by the interactive interface, an interactive field for entering contract requirements for the intelligent contract participants to enter the contract requirements;
Receiving a contract requirement comprising an execution condition and an execution time;
the contract requirements are converted to natural language descriptions of the contracts using the natural language understanding model.
In one embodiment, the code generation module 40 is specifically configured to:
Parsing the natural language description of the contract into a structured representation of contract terms;
determining an intelligent contract code template from the structured representation;
And filling parameters in the structured representation into the intelligent contract code template to generate a complete intelligent contract code.
In one embodiment, the contract execution module 60 is specifically configured to:
checking whether the execution condition of the intelligent contract code is satisfied when the grammar and logic verification are passed;
When the execution condition of the intelligent contract code is confirmed to be satisfied, calling a function in the intelligent contract code, and executing corresponding contract operation;
Updating the state of the intelligent contract participant according to the executed contract operation;
Recording an execution result of the intelligent contract code;
and notifying the execution result to the intelligent contract participant through a block chain event mechanism.
In one embodiment, the recording and storage module 70 is specifically configured to:
encrypting data and operation records generated in the execution process of the intelligent contract code by using an asymmetric encryption module to generate an encryption record in the execution process;
encrypting an execution result generated after the execution of the intelligent contract code is completed to generate an encryption record of the execution result;
attaching corresponding time stamps to the encryption record of the execution process and the encryption record of the execution result;
and writing the encrypted record of the execution process and the encrypted record of the execution result into a distributed account book of a blockchain according to the corresponding time stamp.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes non-volatile and/or volatile storage media and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external user terminal through network connection. The computer program, when executed by a processor, performs a function or step on the server side of a smart contract generation and execution method.
In one embodiment, a computer device is provided, which may be a user terminal, and the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is for communicating with an external server via a network connection. The computer program, when executed by the processor, performs a function or step on the user side of an intelligent contract generation and execution method
In one embodiment, a computer device is provided that includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
collecting transaction behavior data and transaction demand data of intelligent contract participants;
Constructing a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
acquiring contract requirements, and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
Resolving and converting the natural language description of the contract into intelligent contract codes;
performing grammar and logic verification on the intelligent contract codes in a distributed node network of a blockchain;
executing the smart contract code when grammar and logic verification pass;
And recording the execution process and the execution result of the intelligent contract code in a distributed account book of a blockchain.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
collecting transaction behavior data and transaction demand data of intelligent contract participants;
Constructing a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
acquiring contract requirements, and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
Resolving and converting the natural language description of the contract into intelligent contract codes;
performing grammar and logic verification on the intelligent contract codes in a distributed node network of a blockchain;
executing the smart contract code when grammar and logic verification pass;
And recording the execution process and the execution result of the intelligent contract code in a distributed account book of a blockchain.
It should be noted that, the functions or steps that can be implemented by the computer readable storage medium or the computer device may correspond to the descriptions of the server side and the client side in the foregoing method embodiments, and are not described herein for avoiding repetition.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SYNCHLINK) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
It should be noted that, if a software tool or component other than the company appears in the embodiment of the present application, the embodiment is merely presented by way of example, and does not represent actual use. The foregoing embodiments are merely illustrative of the technical solutions of the present application, and not restrictive, and although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that modifications may still be made to the technical solutions described in the foregoing embodiments or equivalent substitutions of some technical features thereof, and that such modifications or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method of intelligent contract generation and execution, comprising the steps of:
collecting transaction behavior data and transaction demand data of intelligent contract participants;
Constructing a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
acquiring contract requirements, and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
Resolving and converting the natural language description of the contract into intelligent contract codes;
performing grammar and logic verification on the intelligent contract codes in a distributed node network of a blockchain;
executing the smart contract code when grammar and logic verification pass;
And recording the execution process and the execution result of the intelligent contract code in a distributed account book of a blockchain.
2. The smart contract generation and execution method of claim 1, wherein collecting transaction behavioral data and transaction demand data of smart contract participants includes:
extracting transaction behavior data from a transaction platform of an intelligent contract participant;
Acquiring transaction demand data from a document library of an intelligent contract participant;
performing data cleaning operation on the transaction behavior data and the transaction demand data;
And converting the transaction behavior data and the transaction demand data after the data cleaning operation into a unified data format.
3. The smart contract generation and execution method of claim 1, wherein constructing a natural language understanding model for contract generation based on the transaction behavior data and transaction demand data includes:
Labeling the transaction behavior data and the transaction demand data to generate a label data set for training a model;
Determining a basic natural language model, and setting the learning rate and training round number of the basic natural language model;
Training the basic natural language model by using the tag data set according to the learning rate and the training round number so as to adjust parameters of the basic natural language model;
and when training is completed, the natural language understanding model is obtained.
4. The intelligent contract generation and execution method as set forth in claim 1, wherein obtaining contract requirements, generating natural language descriptions of contracts from the contract requirements using the natural language understanding model, includes:
displaying, by the interactive interface, an interactive field for entering contract requirements for the intelligent contract participants to enter the contract requirements;
Receiving a contract requirement comprising an execution condition and an execution time;
the contract requirements are converted to natural language descriptions of the contracts using the natural language understanding model.
5. The smart contract generation and execution method of claim 1, wherein parsing and converting the natural language description of the contract into smart contract code includes:
Parsing the natural language description of the contract into a structured representation of contract terms;
determining an intelligent contract code template from the structured representation;
And filling parameters in the structured representation into the intelligent contract code template to generate a complete intelligent contract code.
6. The smart contract generation and execution method of claim 1, wherein executing the smart contract code when syntax and logic verification passes comprises:
checking whether the execution condition of the intelligent contract code is satisfied when the grammar and logic verification are passed;
When the execution condition of the intelligent contract code is confirmed to be satisfied, calling a function in the intelligent contract code, and executing corresponding contract operation;
Updating the state of the intelligent contract participant according to the executed contract operation;
Recording an execution result of the intelligent contract code;
and notifying the execution result to the intelligent contract participant through a block chain event mechanism.
7. The smart contract generation and execution method of claim 1, wherein recording execution of the smart contract code and execution results in a distributed ledger of a blockchain, comprising:
encrypting data and operation records generated in the execution process of the intelligent contract code by using an asymmetric encryption module to generate an encryption record in the execution process;
encrypting an execution result generated after the execution of the intelligent contract code is completed to generate an encryption record of the execution result;
attaching corresponding time stamps to the encryption record of the execution process and the encryption record of the execution result;
and writing the encrypted record of the execution process and the encrypted record of the execution result into a distributed account book of a blockchain according to the corresponding time stamp.
8. An intelligent contract generation and execution apparatus, characterized in that the intelligent contract generation and execution apparatus includes:
the data collection module is used for collecting transaction behavior data and transaction demand data of the intelligent contract participants;
the model building module is used for building a natural language understanding model for contract generation based on the transaction behavior data and the transaction demand data;
the contract generation module is used for acquiring contract requirements and generating natural language description of the contract according to the contract requirements by using the natural language understanding model;
The code generation module is used for analyzing and converting the natural language description of the contract into intelligent contract codes;
the code verification module is used for carrying out grammar and logic verification on the intelligent contract code in the distributed node network of the blockchain;
a contract execution module for executing the intelligent contract code when the grammar and logic verification pass;
And the recording and storing module is used for recording the execution process and the execution result of the intelligent contract code in the distributed account book of the blockchain.
9. A computer device comprising a memory, a processor, and a smart contract generation and execution program stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the smart contract generation and execution method of any of claims 1-7.
10. A computer readable storage medium, characterized in that the storage medium has stored thereon a smart contract generation and execution program, which when executed by a processor, implements the steps of the smart contract generation and execution method of any of claims 1-7.
CN202411512352.5A 2024-10-28 2024-10-28 Smart contract generation and execution method, device, equipment and medium Pending CN119440486A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411512352.5A CN119440486A (en) 2024-10-28 2024-10-28 Smart contract generation and execution method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411512352.5A CN119440486A (en) 2024-10-28 2024-10-28 Smart contract generation and execution method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN119440486A true CN119440486A (en) 2025-02-14

Family

ID=94525232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411512352.5A Pending CN119440486A (en) 2024-10-28 2024-10-28 Smart contract generation and execution method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN119440486A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120257333A (en) * 2025-06-04 2025-07-04 浙江微特电子信息有限公司 Contract management method and system based on blockchain

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120257333A (en) * 2025-06-04 2025-07-04 浙江微特电子信息有限公司 Contract management method and system based on blockchain
CN120257333B (en) * 2025-06-04 2025-08-29 浙江微特电子信息有限公司 Contract management method and system based on block chain

Similar Documents

Publication Publication Date Title
CN110263024B (en) Data processing method, terminal device and computer storage medium
CN116882994A (en) Method and system for providing authenticated, auditable and immutable input for intelligent contracts
US20210065304A1 (en) Contract automation with blockchain based interaction and recording
EP4181010A1 (en) Data reuse computing architecture
CN112150299B (en) Annuity data processing method, annuity data processing device, medium and electronic equipment
CN119440486A (en) Smart contract generation and execution method, device, equipment and medium
US20250141733A1 (en) Automatically updating communication maps used to detect and remediate validation failures for network operations
US11055200B2 (en) Systems and methods for validating domain specific models
US20250307123A1 (en) Data pipeline validation
US20110093309A1 (en) System and method for predictive categorization of risk
Anish et al. Identifying architecturally significant functional requirements
CN118429076A (en) Method, device, electronic equipment and medium for investigating due diligence
US20120143777A1 (en) Using documentation plans for soa governance
US11909858B1 (en) System and method for generating and performing a smart contract
CN117493156A (en) Payment system testing method and device, electronic equipment and readable storage medium
Rubei et al. LLM-Based Recommender Systems for Violation Resolutions in Continuous Architectural Conformance
CN112381509A (en) Management system for major special topic of national science and technology for creating major new drug
Devos et al. Efficient reuse of domain-specific test knowledge: An industrial case in the smart card domain
Nandi et al. SOP-Bench: Complex Industrial SOPs for Evaluating LLM Agents
Momberg et al. Adopting SupTech for Anti-Money Laundering: A Diagnostic Toolkit
US12354110B2 (en) User-friendly smart contract authoring on distributed ledger
Palanisamy AI-Based Test Case Generation from Jira Stories, Swagger, or Code
CN120763028A (en) Configuration file inspection method, device, equipment and medium based on AIGC
CN120724432A (en) A smart contract operation compliance detection method and system
CN118537126A (en) Transaction message generation method, device, equipment, medium and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination