Blockchain-based digital asset registration smart contract generation method
By constructing syntactic dependency trees and calculating risk factors, smart contract code is generated, which solves the problem of insufficient logical consistency in digital asset registration contracts and improves the security and accuracy of the contracts.
Patent Information
- Application Number
- CN202611380459.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies cannot effectively address the insufficient consistency constraints between the semantics of business rules in smart contracts for digital asset registration and the code logic on the blockchain, leading to security vulnerabilities.
By collecting text data for word segmentation and part-of-speech tagging, constructing a syntactic dependency tree, extracting core business verbs and their dependency relationship chains, calculating risk factors and priority strength, and generating smart contract code to ensure logical consistency.
It achieves consistency constraints between the business rules of digital asset registration smart contracts and the code logic on the blockchain, reducing security risks and improving the accuracy and security of contract generation.
Smart Images

Figure CN123180107A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart contract generation technology, specifically to a method for generating smart contracts for digital asset registration based on blockchain. Background Technology
[0002] Blockchain technology is the core underlying technology for digital asset governance. Using smart contracts as the core automated execution carrier of the blockchain, the entire process of digital asset registration, access control, state updates, circulation constraints, and audit traceability can be automated on-chain, reducing trust costs and security risks in digital asset operations. Currently, methods such as template splicing, rule configuration, domain-specific language descriptions, and automatic generation of large models are commonly used to automate the generation of smart contracts for digital asset registration. However, the semantic expression of business rules and the generation logic of on-chain smart contract code cannot be completely matched, resulting in insufficient consistency constraints and making smart contract security vulnerabilities highly susceptible to occur.
[0003] Specifically, the business rules for digital assets are mostly described using natural language, simplified configuration rules, or domain-specific languages. These semantic expressions are somewhat ambiguous and lack strict logical dependencies, allowing for ambiguity to be avoided through human contextual understanding. However, the execution logic of on-chain smart contracts requires absolute precision, unambiguity, and strong logical dependencies. Existing technologies cannot fully identify the state dependencies and execution conditions within business rules, leading to discrepancies between business semantics and on-chain code execution logic. Combined with the automatic execution and immutability of smart contracts, these discrepancies can cause logical vulnerabilities such as low-priority rules overriding high-priority rules and unauthorized access, seriously threatening the security of digital asset registration and circulation. Summary of the Invention
[0004] This application provides a blockchain-based method for generating smart contracts for digital asset registration, aiming to address the problem of insufficient consistency constraints between the business rule semantics of digital asset registration smart contracts and the code logic on the blockchain, which leads to security vulnerabilities in digital asset registration smart contracts. The specific technical solution adopted is as follows: One embodiment of this application provides a method for generating a blockchain-based smart contract for digital asset registration, the method comprising the following steps: Collect text data of digital asset registration, perform word segmentation and part-of-speech tagging, obtain the syntactic dependency tree of each sentence in the text data and the business cluster composed of verbs in the text data through syntactic analysis and verb clustering, and associate each verb with the object of the sentence in which it belongs, and the verb corresponds to the business behavior; Based on the syntactic dependency tree of the statements containing verbs within the same business cluster, the core business verbs and all dependency chains attached to the core business verbs are extracted. The prediction score of the core business verbs is calculated. Based on the prediction scores of all keywords in the dependency chains, the risk factors of the core business verbs and the average risk factors of the dependency chains are calculated respectively. Based on the average risk factor and depth of all dependency chains of all core business verbs in the text data, as well as the risk factor of the core business verbs, the priority strength of the statements in the text data is calculated. Based on the priority strength and syntactic dependency tree of all statements in the text data, fill in the preset basic template of the digital asset registration smart contract and generate smart contract code.
[0005] Furthermore, the syntactic dependency tree of the statement is constructed by combining the word segmentation results corresponding to the statement with the word sequence with part-of-speech tags.
[0006] Furthermore, the method for determining the service cluster is as follows: Based on the word segmentation and part-of-speech tagging results of each sentence in the text data, a syntactic dependency tree is constructed, the verb-object association combination relationship of the text data is extracted, a verb-object co-occurrence matrix is constructed, the cosine similarity between different verbs is calculated, a verb similarity matrix is constructed, and the verbs are clustered according to the verb similarity matrix to obtain business clusters.
[0007] Furthermore, the method for calculating the prediction score of the core business verbs is as follows: The sentence is split into sub-words and lexical mapping encoding is performed. Feature prediction is performed on each core business verb in the syntactic dependency tree to obtain the prediction score of the core business verb in the syntactic dependency tree. The core business verb is the keyword.
[0008] Furthermore, the method for calculating the risk factor of the core business verb is as follows: The sum of the predicted score of the keyword and the preset smoothing constant is used as the true value of the logarithmic function with the natural constant as the base, and the negative of the logarithmic value is recorded as the risk factor of the keyword.
[0009] Furthermore, the average risk factor of the dependency chain is calculated as the average of the risk factors of all keywords in the dependency chain.
[0010] Furthermore, the method for calculating the priority intensity of statements in the text data is as follows: For any core business verb in the text data, the ratio of the sum of the average risk factors of all dependency chains dependent on the core business verb to the sum of the average risk factors of all dependency chains dependent on the core business verb is denoted as the risk factor ratio of the core business verb. Based on the depth of the dependency chains of the core business verb and the risk factor ratio, the constraint strength of the core business verb is calculated. The sum of the constraint strengths of all core business verbs within a statement in the text data is recorded as the priority strength of the statement in the text data.
[0011] Furthermore, the method for calculating the constraint strength of the core business verbs is as follows: The sum of the depth of the dependency chain of the core business verb and the number 1 is used as the argument of the logarithmic function with the natural constant as the base. The product of the value of the logarithmic function and the risk factor ratio of the core business verb is denoted as the constraint strength of the core business verb.
[0012] Furthermore, the specific methods for filling in the preset basic template of the digital asset registration smart contract based on the priority strength and syntactic dependency tree of all statements in the text data, and generating smart contract code, include: Based on the syntactic dependency tree of the statement, four types of nodes are extracted: action, object, constraint, and result. The extracted nodes are arranged in order and denoted as the pseudocode of the statement. According to the priority intensity of the statements in the text data from largest to smallest, the pseudocodes of all statements in the text data are concatenated in sequence to obtain the concatenated pseudocode of the text data. The concatenated pseudocode of the text data is filled into the preset basic template of the digital asset registration smart contract to generate the smart contract code.
[0013] Furthermore, when logical conflicts exist during the pseudocode concatenation process, the logic with the highest priority shall prevail.
[0014] The beneficial effects of this application are: This application first performs business classification processing on the preprocessed text data of digital asset registration, identifying business behaviors within the same business cluster that are semantically and functionally similar. It then extracts core business verbs and dependency chains from the statements corresponding to the syntactic dependency tree, obtaining the core actions expressed by the statements, quantifying the risk level and intensity of different constraint rules, and obtaining the prediction scores of the core business verbs. Subsequently, it conducts priority analysis on multiple types of constraint rules for similar business behaviors within the same business cluster, evaluating the impact of constraints on on-chain execution security, and obtaining the priority strength of statements in the text data. Finally, based on the priority strength of all statements in the text data and the syntactic dependency tree, it constrains the priority of contract logic to prevent the omission or bypassing of highly demanding core rules, fills in the preset basic template of the digital asset registration smart contract, generates smart contract code, and solves the problem of insufficient consistency constraints between the semantics of the business rules of the digital asset registration smart contract and the code logic on the blockchain, which leads to security vulnerabilities in the digital asset registration smart contract. Attached Figure Description
[0015] Figure 1 This is a schematic diagram of a blockchain-based digital asset registration smart contract generation method provided in one embodiment of this application. Detailed Implementation
[0016] Please see Figure 1 The diagram illustrates a flowchart of a blockchain-based digital asset registration smart contract generation method according to an embodiment of this application. The method includes the following steps: Step S001: Collect text data of digital asset registration, perform word segmentation and part-of-speech tagging, obtain the syntactic dependency tree of each sentence in the text data and the business cluster composed of verbs in the text data through syntactic analysis and verb clustering, and associate each verb with the object of the sentence in which it is located, and the verb corresponds to the business behavior.
[0017] In order to generate a smart contract for digital asset registration, text data for digital asset registration is collected.
[0018] Specifically, optical character recognition technology is used to extract text information from images corresponding to unstructured business documents such as paper scans and portable document format files, and obtain text data; text data is then directly retrieved from electronic documents through a document parsing interface.
[0019] The text data is preprocessed to obtain the word segmentation results and part-of-speech tagging sequence for each sentence in the text data. The preprocessing includes text cleaning, word segmentation, stop word filtering, and part-of-speech tagging. During text cleaning, regular expressions are used to filter invalid noise data such as hypertext markup language tags, redundant spaces, line breaks, headers and footers, and to unify the full-width and half-width text format, date and amount writing standards. During word segmentation, Chinese word segmentation tools are used to split continuous long texts into independent smallest semantic units. Stop word filtering and part-of-speech tagging can remove high-frequency function words without actual business semantics, and the remaining effective words are tagged with noun, verb, and other grammatical attributes.
[0020] With the rapid development of the digital economy, the confirmation of ownership and management of digital assets places higher demands on business credibility and data security. Smart contract technology can effectively reduce trust costs and security risks in digital economy scenarios. However, current automatic smart contract generation technology still has significant shortcomings. The semantic logic of business rules and the code execution logic of on-chain smart contracts cannot be fully matched, resulting in inherent semantic and logical discrepancies. This makes smart contracts generated based on business needs prone to security vulnerabilities. Therefore, it is necessary to further improve the consistency of the mapping between the semantics of business rules and the constraint logic of on-chain code to reduce smart contract security risks from the source.
[0021] Business rule constraints and on-chain execution logic of smart contracts are both control rules based on various business behaviors. Only by accurately identifying differentiated business behaviors can we achieve a precise mapping between business semantics and on-chain code logic, ensuring the accuracy and consistency of smart contract generation. Therefore, to solve the above problems, it is first necessary to perform business classification processing on the preprocessed text data of digital asset registration, with each category of text corresponding to a unique standardized business behavior.
[0022] The core logic of digital asset registration business rules is to execute corresponding operations on designated business objects and generate fixed business results. The execution logic on the smart contract blockchain also relies on function calls, state transitions, and access control to constrain business behavior; therefore, the two naturally have a semantic mapping relationship. Core business behaviors include operations such as transfer, circulation, ownership transfer, authorization, freezing, cancellation, and destruction. If different textual descriptions of business behaviors ultimately lead to the same state change and business result for the same business object, they can be identified as the same type of standardized business behavior. Core business objects include digital assets, accounts, operating permissions, and asset ownership. When the same business behavior acts on different business objects, it will create differentiated state control and access control logic. Therefore, accurate classification requires combining the dual characteristics of business behavior and the object it acts upon.
[0023] Dependency parsing is used to process the word segmentation results and part-of-speech tagging word sequences corresponding to each sentence in the text data, constructing a syntactic dependency tree to accurately extract the verb-object association combination relationship in the text data. Based on the verb-object association combination relationship, a verb-object co-occurrence matrix is constructed, where each row of the verb-object co-occurrence matrix corresponds to the same verb, and each column corresponds to the same object. The row vector of the verb-object co-occurrence matrix represents the co-occurrence of a verb with each object. The cosine similarity between different verbs is calculated to construct a verb similarity matrix. Using a spectral clustering algorithm, based on the verb similarity matrix, business behaviors with similar semantics and functions are grouped into the same category to obtain business clusters.
[0024] Among them, the spectral clustering algorithm is a well-known technique and will not be described in detail.
[0025] Since a single business text may encompass multiple different business behaviors, the above process utilizes a reverse propagation mapping mechanism from verbs to text to achieve multi-label business classification within a single text. Understandably, based on the clustering results, a matching dictionary can be established between business verbs and their corresponding business clusters. Dependency parsing of a single business text allows for the extraction of all core business verbs. By matching the business categories corresponding to each verb using the matching dictionary, all category labels can be integrated to form an aggregated result, yielding a multi-dimensional standardized set of business behavior labels corresponding to a single text. This provides data support for the subsequent accurate mapping of business semantics to smart contract code.
[0026] At this point, the business cluster has been obtained.
[0027] Step S002: Based on the syntactic dependency tree of the statements containing verbs within the same business cluster, extract the core business verbs and all dependency chains attached to the core business verbs, calculate the prediction score of the core business verbs, and calculate the risk factor of the core business verbs and the average risk factor of the dependency chains based on the prediction scores of all keywords in the dependency chains. Based on the average risk factor and depth of all dependency chains attached to all core business verbs in the text data, as well as the risk factor of the core business verbs, calculate the priority strength of the statements in the text data.
[0028] The registration of digital assets is typically governed by multiple business constraints, state restrictions, and permission rules. These constraints vary significantly in terms of security control strength, risk impact scope, and state irreversibility. Smart contracts possess on-chain characteristics of automatic execution, immutability, and persistent state storage, meaning execution errors cannot be rolled back. If the control strength of various constraints cannot be accurately distinguished during the code generation phase, issues such as low-priority rules overriding high-risk constraints and ordinary logic bypassing high-risk restrictions can easily arise, leading to security vulnerabilities such as unauthorized access, state bypassing, illegal asset transfer, and loss of control over the business lifecycle. Therefore, it is necessary to conduct priority analysis on multiple constraint rules for similar business behaviors, combined with an analysis of the impact of constraints on on-chain execution security, to ensure that high-risk, strongly restricted, and highly irreversible business rules have priority execution permissions during smart contract generation.
[0029] Constraint priority is primarily determined through two dimensions. First, constraint density: the number of constraints characterizes the degree of coupling between business behavior and various states, permissions, and compliance conditions. More abundant constraints mean more verification dimensions for business execution, more complex on-chain execution paths, and higher requirements for state and permission consistency; correspondingly, the constraint priority needs to be increased accordingly. Second, state transition risk: blockchain smart contracts are essentially state-driven models, and the state transition risks for various operations differ significantly. Irreversible state transitions, once triggered, cannot be reversed, exhibiting extremely low fault tolerance and stronger security sensitivity; therefore, the corresponding constraint priority is higher.
[0030] For the same business cluster, the constraint strength identification is completed by using a syntactically analyzed and fine-tuned BERT model.
[0031] First, based on the syntactic dependency tree, all keywords and core business verbs, as well as all dependency chains attached to each core business verb, are extracted. Start and end markers are added at the beginning and end of each statement according to the grammatical rules of the BERT model. Sub-word segmentation and vocabulary mapping are completed using the BERT segmenter. The sequence of segmented sentences is then input into the BERT model, which has been fine-tuned using a digital asset security audit corpus. Feature prediction is performed on each core business verb within the syntactic dependency tree, and the predicted scores for the keywords are output.
[0032] The keywords are core words selected from the syntactic structure, carrying business semantics, actions, constraints, and objects. They form the skeleton of the entire sentence's business logic, eliminating auxiliary words such as particles, conjunctions, and modal particles that have no actual business meaning. The core business verbs are the lexical verbs in the statement corresponding to the syntactic dependency tree, representing the core actions the statement expresses. It is understood that core business verbs are always keywords, but only some words among the keywords are core business verbs. The prediction score is the probability value of the corresponding core business verb belonging to a risk-free state transition. The prediction score can quantify the risk level and intensity of different constraint rules, improve sensitivity to business operations, and provide accurate basis for constraint priority division and smart contract security logic generation.
[0033] Among them, the BERT model is a well-known pre-trained language model, and will not be described in detail.
[0034] The sum of the predicted scores of keywords and a preset smoothing constant is used as the argument of a logarithmic function with the natural constant as the base. The negative of the logarithm is recorded as the risk factor of the keyword. The mean of the risk factors of all keywords in the same dependency chain is recorded as the average risk factor of the dependency chain. For any core business verb in the text data, the ratio of the sum of the average risk factors of all dependency chains dependent on the core business verb to the sum of the average risk factors of all dependency chains dependent on the core business verb is recorded as the risk factor ratio of the core business verb. The sum of the depth of the dependency chain of the core business verb and the number 1 is used as the argument of a logarithmic function with the natural constant as the base. The product of the logarithmic function value and the risk factor ratio of the core business verb is recorded as the constraint strength of the core business verb. The sum of the constraint strengths of all core business verbs in the text data is recorded as the priority strength of the text data.
[0035] The smoothing constant is used to prevent computational crashes caused by excessively small prediction scores. In this embodiment, the smoothing constant is set to a value of [value missing]. .
[0036] In calculating priority strength, the purpose of using a logarithmic function to calculate constraint strength is to reflect the marginal growth effect of constraint complexity, ensuring that the risk increase resulting from constraint depth is not linear. Priority strength measures the complexity of constraints by the depth and number of dependency chains of the core business verbs in the statement.
[0037] At this point, the priority intensity of each statement in the text data has been obtained.
[0038] Step S003: Based on the priority strength and syntactic dependency tree of all statements in the text data, fill in the preset basic template of the digital asset registration smart contract and generate smart contract code.
[0039] Contract texts for digital asset registration generally suffer from semantic ambiguity and weak logical coherence. For the same business behavior, the risk levels of constraint rules in different statements vary. Overlapping rule scopes and inconsistent control levels easily lead to logical conflicts in generated smart contracts, resulting in security vulnerabilities such as permission violations and illegal assignment of state variables. Therefore, it is necessary to set constraint priorities for contract logic to prevent critical rules with high requirements from being overlooked or bypassed.
[0040] The generation order of smart contract code is determined based on the priority intensity of statements in the text data.
[0041] Based on the syntactic dependency tree of the statement, four types of nodes are extracted: action, object, constraint, and result. The extracted nodes are arranged in order and denoted as the pseudocode of the statement. According to the priority intensity of the statements in the text data from largest to smallest, the pseudocodes of all statements in the text data are concatenated in sequence to obtain the concatenated pseudocode of the text data. The concatenated pseudocode of the text data is filled into the preset basic template of the digital asset registration smart contract to generate the smart contract code.
[0042] The specific extraction rules for nodes are as follows: extract the core predicate in the syntax tree as an action node; extract the object governed by the core predicate as an object node; extract the adverbial, attributive, and conditional clause components that modify the action as constraint nodes; and extract the state complement triggered by the action as a result node.
[0043] It is important to note that during the concatenation process, if logical conflicts exist, the logic with the highest priority will prevail. The specific process of ordered concatenation and conflict handling in pseudocode is as follows: 1. Read the pseudocode of the statements in the text data in descending order of priority. Convert each pseudocode into a basic code structure sequence with conditional judgments and branching instructions, according to a preset execution framework: "If the constraint node is satisfied, then execute the action node for the object node and return the result node." Then, parse this structure sequence with accompanying formal syntax into abstract syntax tree nodes. Each pseudocode is parsed and converted into an abstract syntax tree node. The abstract syntax tree node is a structured representation of the pseudocode, that is, converting the pseudocode of the statement into a machine-processable structured logic tree.
[0044] 2. Extract the operation functions and state variables corresponding to all nodes, and establish a mapping relationship between state variables and modification actions.
[0045] 3. Compare the nodes of each abstract syntax tree. If multiple nodes perform modification operations on the same state variable, it is determined that there is a logical conflict.
[0046] 4. When logical conflicts exist, if the rule with the highest priority contains a state write operation, while executing the state write feature node corresponding to the high-priority rule, the duplicate write nodes for the same state variable are pruned and removed from the wrapped low-priority rules. This is done by using mutually exclusive decision branches to intercept low-priority duplicate write instructions, ensuring that high-level constraints control variables and preventing secondary overwriting pollution from low-level operations, thus completing conflict handling and logical merging.
[0047] 5. Embed the integrated pseudocode into the preset basic template of the digital asset registration smart contract to generate compliant and secure smart contract code.
[0048] The process of generating smart contracts using blockchain technology is a well-known technology and will not be elaborated further.
[0049] This completes the generation of the smart contract for digital asset registration.
Claims
1. A method for generating smart contracts for digital asset registration based on blockchain, characterized in that, The method includes the following steps: Collect text data of digital asset registration, perform word segmentation and part-of-speech tagging, obtain the syntactic dependency tree of each sentence in the text data and the business cluster composed of verbs in the text data through syntactic analysis and verb clustering, and associate each verb with the object of the sentence in which it belongs, and the verb corresponds to the business behavior; Based on the syntactic dependency tree of the statements containing verbs within the same business cluster, the core business verbs and all dependency chains attached to the core business verbs are extracted. The prediction score of the core business verbs is calculated. Based on the prediction scores of all keywords in the dependency chains, the risk factors of the core business verbs and the average risk factors of the dependency chains are calculated respectively. Based on the average risk factor and depth of all dependency chains of all core business verbs in the text data, as well as the risk factor of the core business verbs, the priority strength of the statements in the text data is calculated. Based on the priority strength and syntactic dependency tree of all statements in the text data, fill in the preset basic template of the digital asset registration smart contract and generate smart contract code.
2. The method for generating a blockchain-based digital asset registration smart contract according to claim 1, characterized in that, The syntactic dependency tree of the statement is constructed by combining the word segmentation results corresponding to the statement with the word sequence with part-of-speech tags.
3. The method for generating a blockchain-based digital asset registration smart contract according to claim 1, characterized in that, The method for determining the service cluster is as follows: Based on the word segmentation and part-of-speech tagging results of each sentence in the text data, a syntactic dependency tree is constructed, the verb-object association combination relationship of the text data is extracted, a verb-object co-occurrence matrix is constructed, the cosine similarity between different verbs is calculated, a verb similarity matrix is constructed, and the verbs are clustered according to the verb similarity matrix to obtain business clusters.
4. The method for generating a blockchain-based digital asset registration smart contract according to claim 1, characterized in that, The method for calculating the prediction score of the core business verbs is as follows: The sentence is split into sub-words and lexical mapping encoding is performed. Feature prediction is performed on each core business verb in the syntactic dependency tree to obtain the prediction score of the core business verb in the syntactic dependency tree. The core business verb is the keyword.
5. The method for generating a blockchain-based digital asset registration smart contract according to claim 4, characterized in that, The method for calculating the risk factor of the core business verbs is as follows: The sum of the predicted score of the keyword and the preset smoothing constant is used as the true value of the logarithmic function with the natural constant as the base, and the negative of the logarithmic value is recorded as the risk factor of the keyword.
6. The method for generating a blockchain-based digital asset registration smart contract according to claim 1, characterized in that, The average risk factor of the dependency chain is calculated as the average of the risk factors of all keywords in the dependency chain.
7. The method for generating a blockchain-based digital asset registration smart contract according to claim 1, characterized in that, The method for calculating the priority intensity of statements in the text data is as follows: For any core business verb in the text data, the ratio of the sum of the average risk factors of all dependency chains dependent on the core business verb to the sum of the average risk factors of all dependency chains dependent on the core business verb is denoted as the risk factor ratio of the core business verb. Based on the depth of the dependency chains of the core business verb and the risk factor ratio, the constraint strength of the core business verb is calculated. The sum of the constraint strengths of all core business verbs within a statement in the text data is recorded as the priority strength of the statement in the text data.
8. The method for generating a blockchain-based digital asset registration smart contract according to claim 7, characterized in that, The method for calculating the constraint strength of the core business verbs is as follows: The sum of the depth of the dependency chain of the core business verb and the number 1 is used as the argument of the logarithmic function with the natural constant as the base. The product of the value of the logarithmic function and the risk factor ratio of the core business verb is denoted as the constraint strength of the core business verb.
9. The method for generating a blockchain-based digital asset registration smart contract according to claim 1, characterized in that, The method for generating smart contract code by filling in the preset basic template of the digital asset registration smart contract based on the priority strength and syntactic dependency tree of all statements in the text data includes: Based on the syntactic dependency tree of the statement, four types of nodes are extracted: action, object, constraint, and result. The extracted nodes are arranged in order and denoted as the pseudocode of the statement. According to the priority intensity of the statements in the text data from largest to smallest, the pseudocodes of all statements in the text data are concatenated in sequence to obtain the concatenated pseudocode of the text data. The concatenated pseudocode of the text data is filled into the preset basic template of the digital asset registration smart contract to generate the smart contract code.
10. The method for generating a blockchain-based digital asset registration smart contract according to claim 9, characterized in that, When logical conflicts exist during pseudocode concatenation, the logic with the highest priority shall prevail.
