Smart contract generation model based on code annotation and AST-LSTM tuning

preprint OA: closed CC-BY-4.0
📄 Open PDF Full text JSON View at publisher
Full text 12,152 characters · extracted from preprint-html · click to expand
Smart contract generation model based on code annotation and AST-LSTM tuning | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article Smart contract generation model based on code annotation and AST-LSTM tuning Chen Yong, Hu Defeng, Xu Chao, Chen Nannan, Fanfan Shen, Jianbo Liu This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-3995739/v1 This work is licensed under a CC BY 4.0 License Status: Posted Version 1 posted You are reading this latest preprint version Abstract With the wide application of smart contracts in many fields, the number, types, and complexity of smart contracts are showing a rapidly increasing trend. However , the development of smart contracts has its own unique programming language and security requirements, which are difficult for conventional software personnel to adapt to quickly, and how to realize the efficient development of smart contracts according to the application requirements is an important issue that needs to be solved for its further development. To this end, this paper proposes a smart contract generation method based on AST-LSTM characterization and code annotation tuning large language model, which adopts AST-LSTM model combining Abstract Syntax Tree (AST) and Tree-LSTM to vectorize the code as well as Sentence-Bert to vectorize the annotations and carry out a weighted analysis, and constructs a smart contract clustering analysis model to achieve accurate clustering of functionally similar smart contracts. Then the AST-LSTM+Transformer model is used to detect defects in the clustered code and correlate the related annotation information to construct a diverse Prompt feature prompt statement dataset. Finally, the LLaMA2-7B model is used as the basis for demand-specific smart contract generation with the help of Lora and P-Tuning v2 fine-tuning techniques. In this paper, with the help of BLEU, an auxiliary tool for bilingual translation quality assessment, and Mythril, VaaS, 1 and other code security detection tools, we conducted comparative experiments with existing methods. The results of the experiment show that the average value of BLEU of the code generated by this paper’s method is improved by about 25%, and the code security is improved by about 9%, which will greatly promote the rapid development and exploitation of smart contracts with high-security requirements. Smart contract generation AST Tree-LSTM Annotation Full Text Additional Declarations No competing interests reported. Cite Share Download PDF Status: Posted Version 1 posted You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-3995739","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":275633166,"identity":"850188be-6aa0-4805-ab22-2f8755f9ff82","order_by":0,"name":"Chen Yong","email":"","orcid":"","institution":"Nanjing Audit University","correspondingAuthor":false,"prefix":"","firstName":"Chen","middleName":"","lastName":"Yong","suffix":""},{"id":275633167,"identity":"98af2fa7-35a6-405e-90f1-8a81b074d5d1","order_by":1,"name":"Hu Defeng","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABCUlEQVRIie3RsUoDMRjA8S8E4vJJ1xwn+ARCjsKhqL1XyZH1cBHkJrlS6CS6erQPcY+QEvCW4nzSG1oEu3S4SR29DlUQ03Z0yB8C4YMfSQiAy/Uvo5O5TDl2DrKfGd9OmBLN9PTIu9PkG+0gGHr5ML0QldyTnIwy4R8OOcLLcvmKUB8LTSczhN6VjYS1ll185khGSTBAeAsKzdQ5grq2kkpqhTccqZ+QlhhSaAx9BB1nVhJnBhlH5pWLNYkK3XnfQRTpP7ZvQQ7ri5m4PYVtJ/UThWbKkWMS5GNhVG5Y92wslJ3MHj4+ZXobRWU5b1apubwvB4tqlfas5NcXiHbRzWY/4nK5XK4/+gK5plfDcOKroAAAAABJRU5ErkJggg==","orcid":"","institution":"Nanjing Audit University","correspondingAuthor":true,"prefix":"","firstName":"Hu","middleName":"","lastName":"Defeng","suffix":""},{"id":275633168,"identity":"dcb3f512-293a-484b-9f2f-b348c6a1793e","order_by":2,"name":"Xu Chao","email":"","orcid":"","institution":"Nanjing Audit University","correspondingAuthor":false,"prefix":"","firstName":"Xu","middleName":"","lastName":"Chao","suffix":""},{"id":275633169,"identity":"f601ae7f-ad9a-4e6a-a9e5-dcce126b8e97","order_by":3,"name":"Chen Nannan","email":"","orcid":"","institution":"Nanjing Audit University","correspondingAuthor":false,"prefix":"","firstName":"Chen","middleName":"","lastName":"Nannan","suffix":""},{"id":275633170,"identity":"7e3528c3-a693-4a00-a418-7cbad1bb1425","order_by":4,"name":"Fanfan Shen","email":"","orcid":"","institution":"Nanjing Audit University","correspondingAuthor":false,"prefix":"","firstName":"Fanfan","middleName":"","lastName":"Shen","suffix":""},{"id":275633171,"identity":"f589d795-ba21-4613-b006-b7c953b761ca","order_by":5,"name":"Jianbo Liu","email":"","orcid":"","institution":"Wuhan Shubo Technology, Wuhan Shubo Technology Co., LTD, Fenghuo Innovation Valley","correspondingAuthor":false,"prefix":"","firstName":"Jianbo","middleName":"","lastName":"Liu","suffix":""}],"badges":[],"createdAt":"2024-02-28 05:29:40","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-3995739/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-3995739/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":70748329,"identity":"db0fd29d-de5c-47b0-825f-c10737fd6b13","added_by":"auto","created_at":"2024-12-06 08:53:57","extension":"pdf","order_by":1,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":2381818,"visible":true,"origin":"","legend":"","description":"","filename":"npsSmartContractGenerationModel.pdf","url":"https://assets-eu.researchsquare.com/files/rs-3995739/v1_covered_567d076d-fb85-4982-8fc1-26d653f331aa.pdf"}],"financialInterests":"No competing interests reported.","formattedTitle":"Smart contract generation model based on code annotation and AST-LSTM tuning","fulltext":[],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":false,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":false,"hideJournal":true,"highlight":"","institution":"","isAcceptedByJournal":false,"isAuthorSuppliedPdf":true,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":true,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true},"keywords":"Smart contract generation, AST, Tree-LSTM, Annotation","lastPublishedDoi":"10.21203/rs.3.rs-3995739/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-3995739/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"With the wide application of smart contracts in many fields, the number, types, and complexity of smart contracts are showing a rapidly increasing trend. However , the development of smart contracts has its own unique programming language and security requirements, which are difficult for conventional software personnel to adapt to quickly, and how to realize the efficient development of smart contracts according to the application requirements is an important issue that needs to be solved for its further development. To this end, this paper proposes a smart contract generation method based on AST-LSTM characterization and code annotation tuning large language model, which adopts AST-LSTM model combining Abstract Syntax Tree (AST) and Tree-LSTM to vectorize the code as well as Sentence-Bert to vectorize the annotations and carry out a weighted analysis, and constructs a smart contract clustering analysis model to achieve accurate clustering of functionally similar smart contracts. Then the AST-LSTM+Transformer model is used to detect defects in the clustered code and correlate the related annotation information to construct a diverse Prompt feature prompt statement dataset. Finally, the LLaMA2-7B model is used as the basis for demand-specific smart contract generation with the help of Lora and P-Tuning v2 fine-tuning techniques. In this paper, with the help of BLEU, an auxiliary tool for bilingual translation quality assessment, and Mythril, VaaS, 1 and other code security detection tools, we conducted comparative experiments with existing methods. The results of the experiment show that the average value of BLEU of the code generated by this paper’s method is improved by about 25%, and the code security is improved by about 9%, which will greatly promote the rapid development and exploitation of smart contracts with high-security requirements.","manuscriptTitle":"Smart contract generation model based on code annotation and AST-LSTM tuning","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2024-03-04 04:24:42","doi":"10.21203/rs.3.rs-3995739/v1","editorialEvents":[{"type":"communityComments","content":0}],"status":"published","journal":{"display":true,"email":"[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"a3fefc0c-4c03-4282-9064-078d6159d9ba","owner":[],"postedDate":"March 4th, 2024","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[],"tags":[],"updatedAt":"2025-04-01T16:15:31+00:00","versionOfRecord":[],"versionCreatedAt":"2024-03-04 04:24:42","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-3995739","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-3995739","identity":"rs-3995739","version":["v1"]},"buildId":"qtupq5eGEP_6zYnWcrvyt","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}

Text is read by the "Ask this paper" AI Q&A widget below. Extraction quality varies by source — PMC NXML preserves structure cleanly, OA-HTML may include some navigation residue, and OA-PDF can have broken hyphenation. The publisher copy (via DOI) is the canonical version.

My notes (saved in your browser only)

Ask this paper AI returns verbatim quotes from the full text · source: preprint-html

Answers must be backed by verbatim quotes from this paper's full text. Hallucinated quotes are dropped automatically; if no verbatim passage answers the question, we say so. How this works

Citation neighborhood (no data yet)

We don't have any in-corpus citations linked to this paper yet. This is a recent paper (2024) — citers typically take a year or two to land, and the OpenAlex reference graph may still be filling in.

Source provenance

europepmc
last seen: 2026-05-20T01:45:00.602351+00:00
unpaywall
last seen: 2026-05-20T11:00:21.680559+00:00
License: CC-BY-4.0