{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,10,22]],"date-time":"2026-10-22T18:24:39Z","timestamp":1792693479190,"version":"4.5.0"},"reference-count":72,"publisher":"Association for Computing Machinery (ACM)","issue":"FSE","license":[{"start":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T00:00:00Z","timestamp":1782777600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/legalcode"}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Proc. ACM Softw. Eng."],"published-print":{"date-parts":[[2026,6,30]]},"abstract":"<jats:p>Smart contracts automate the management of high-value assets, where vulnerabilities can lead to catastrophic financial losses. In the task of automated smart contract generation using Large Language Models (LLMs), this challenge is amplified by two interconnected failures: first, they operate as unauditable \"black boxes\" by failing to produce a transparent reasoning process, and second, as a consequence, they generate code riddled with critical security vulnerabilities. To address both issues, we propose SmartCoder-R1 based on Qwen2.5-Coder-7B, a novel framework for secure and explainable smart contract generation. It begins with Continual Pre-training (CPT) to specialize the base model on the nuances of smart contract code. To construct the data for subsequent stages, we first prompt the DeepSeek model to generate reasoning-and-code samples from verified on-chain contracts, followed by a rigorous validation process where each sample is manually reviewed by security experts for compilability, functionality, security, and reasoning completeness. Based on this, we then apply Long Chain-of-Thought Supervised Fine-Tuning (L-CoT SFT) on 7,998 of these expert-validated samples to train the model to emulate human security analysis. Finally, to directly mitigate vulnerabilities, we employ Security-Aware Group Relative Policy Optimization (S-GRPO), a reinforcement learning phase that refines the generation policy using 1,691 samples by optimizing a weighted reward signal for compilation success, security compliance, and format correctness. Evaluated against 18 state-of-the-art baselines on a challenging benchmark of 756 real-world functions from 289 deployed contracts, SmartCoder-R1 establishes a new state of the art by achieving top performance across five key metrics: a ComPass of 87.70%, a VulRate of 8.60%, a SafeAval of 80.16%, a FuncRate of 53.84%, and a FullRate of 50.53%. This FullRate marks a 45.79% relative improvement over the strongest baseline, DeepSeek-R1. Crucially, its generated reasoning also excels in human evaluations, achieving high-quality ratings for Functionality (82.7%), Security (85.3%), and Clarity (90.7%).<\/jats:p>","DOI":"10.1145\/3808104","type":"journal-article","created":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T17:06:14Z","timestamp":1782839174000},"page":"2165-2188","source":"Crossref","is-referenced-by-count":3,"title":["SmartCoder-R1: Towards Secure and Explainable Smart Contract Generation with Security-Aware Group Relative Policy Optimization"],"prefix":"10.1145","volume":"3","author":[{"ORCID":"https:\/\/orcid.org\/0000-0003-3134-3746","authenticated-orcid":false,"given":"Lei","family":"Yu","sequence":"first","affiliation":[{"name":"Institute of Software at Chinese Academy of Sciences, Beijing, China"},{"name":"University of Chinese Academy of Sciences, Beijing, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0001-5475-3815","authenticated-orcid":false,"given":"Jingyuan","family":"Zhang","sequence":"additional","affiliation":[{"name":"Institute of Software at Chinese Academy of Sciences, Beijing, China"},{"name":"University of Chinese Academy of Sciences, Beijing, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0009-0005-5391-8821","authenticated-orcid":false,"given":"Xin","family":"Wang","sequence":"additional","affiliation":[{"name":"Institute of Software at Chinese Academy of Sciences, Beijing, China"},{"name":"University of Chinese Academy of Sciences, Beijing, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0001-8364-6525","authenticated-orcid":false,"given":"Li","family":"Yang","sequence":"additional","affiliation":[{"name":"Institute of Software at Chinese Academy of Sciences, Beijing, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-3830-8786","authenticated-orcid":false,"given":"Fengjun","family":"Zhang","sequence":"additional","affiliation":[{"name":"Institute of Software at Chinese Academy of Sciences, Beijing, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-6028-4186","authenticated-orcid":false,"given":"Jiajia","family":"Ma","sequence":"additional","affiliation":[{"name":"Institute of Software at Chinese Academy of Sciences, Beijing, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2026,6,30]]},"reference":[{"key":"e_1_2_1_1_1","doi-asserted-by":"publisher","DOI":"10.1145\/3717383.3717394"},{"key":"e_1_2_1_2_1","doi-asserted-by":"publisher","DOI":"10.5121\/csit.2017.71011"},{"key":"e_1_2_1_3_1","doi-asserted-by":"publisher","DOI":"10.1145\/3702973"},{"key":"e_1_2_1_4_1","doi-asserted-by":"publisher","DOI":"10.1145\/3650212.3680353"},{"key":"e_1_2_1_5_1","doi-asserted-by":"publisher","DOI":"10.1109\/ISSRE66568.2025.00038"},{"key":"e_1_2_1_6_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2306.12338"},{"key":"e_1_2_1_7_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-1-4842-3081-7"},{"key":"e_1_2_1_8_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2508.05170"},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1038\/s41586-025-09422-z"},{"key":"e_1_2_1_10_1","doi-asserted-by":"publisher","unstructured":"Daya Guo Qihao Zhu Dejian Yang Zhenda Xie Kai Dong Wentao Zhang Guanting Chen Xiao Bi Yu Wu Y.K. Li et al. 2024. DeepSeek-Coder: When the Large Language Model Meets Programming -The Rise of Code Intelligence. arXiv preprint arXiv:2401.14196 (Jan. 2024). arXiv:2401.14196 [cs.SE] doi:10.48550\/arXiv.2401.14196 10.48550\/arXiv.2401.14196","DOI":"10.48550\/arXiv.2401.14196"},{"key":"e_1_2_1_11_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.jnca.2020.102857"},{"key":"e_1_2_1_12_1","doi-asserted-by":"publisher","DOI":"10.1109\/TPS-ISA58951.2023.00044"},{"key":"e_1_2_1_13_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2503.06749"},{"key":"e_1_2_1_14_1","doi-asserted-by":"publisher","unstructured":"Binyuan Hui Jian Yang Zeyu Cui Jiaxi Yang Dayiheng Liu Lei Zhang Tianyu Liu Jiajun Zhang Bowen Yu Keming Lu et al. 2024. Qwen2.5-Coder Technical Report. arXiv preprint arXiv:2409.12186 (Sept. 2024). arXiv:2409.12186 [cs.CL] doi:10.48550\/arXiv.2409.12186 10.48550\/arXiv.2409.12186","DOI":"10.48550\/arXiv.2409.12186"},{"key":"e_1_2_1_15_1","volume-title":"Second Conference on Language Modeling. https:\/\/openreview.net\/forum?id=u9JXu4L17I","author":"Jiang Pengcheng","year":"2025","unstructured":"Pengcheng Jiang, Jiacheng Lin, Lang Cao, Runchu Tian, SeongKu Kang, Zifeng Wang, Jimeng Sun, and Jiawei Han. 2025. DeepRetrieval: Hacking Real Search Engines and Retrievers with Large Language Models via Reinforcement Learning. In Second Conference on Language Modeling. https:\/\/openreview.net\/forum?id=u9JXu4L17I"},{"key":"e_1_2_1_16_1","volume-title":"Second Conference on Language Modeling. https:\/\/openreview.net\/forum?id=Rwhi91ideu","author":"Jin Bowen","year":"2025","unstructured":"Bowen Jin, Hansi Zeng, Zhenrui Yue, Jinsung Yoon, Sercan O Arik, Dong Wang, Hamed Zamani, and Jiawei Han. 2025. Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learning. In Second Conference on Language Modeling. https:\/\/openreview.net\/forum?id=Rwhi91ideu"},{"key":"e_1_2_1_17_1","doi-asserted-by":"publisher","DOI":"10.9734\/BJAST\/2015\/14975"},{"key":"e_1_2_1_18_1","doi-asserted-by":"publisher","unstructured":"Aixin Liu Bei Feng Bing Xue Bingxuan Wang Bochao Wu Chengda Lu Chenggang Zhao Chengqi Deng Chenyu Zhang Chong Ruan et al. 2024. DeepSeek-V3 Technical Report. arXiv:2412.19437 [cs.CL] doi:10.48550\/arXiv.2412.19437 10.48550\/arXiv.2412.19437","DOI":"10.48550\/arXiv.2412.19437"},{"key":"e_1_2_1_19_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2503.16252"},{"key":"e_1_2_1_20_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2106.09282"},{"key":"e_1_2_1_21_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.1711.05101"},{"key":"e_1_2_1_22_1","doi-asserted-by":"publisher","DOI":"10.1109\/ISSRE59848.2023.00026"},{"key":"e_1_2_1_23_1","doi-asserted-by":"publisher","DOI":"10.1609\/aaai.v40i21.38816"},{"key":"e_1_2_1_24_1","doi-asserted-by":"publisher","DOI":"10.1145\/2976749.2978309"},{"key":"e_1_2_1_25_1","volume-title":"Advances in Neural Information Processing Systems","author":"Ma Peixian","year":"2025","unstructured":"Peixian Ma, Xialie Zhuang, Chengjin Xu, Xuhui Jiang, Ran Chen, and Jian Guo. 2025. SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning. In Advances in Neural Information Processing Systems, D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen (Eds.), Vol. 38. Curran Associates, Inc., 174505-174537. https:\/\/proceedings.neurips.cc\/paper_files\/paper\/2025\/file\/ff00aae6ce2b5e519ca4cf769f0c4a47- Paper-Conference.pdf"},{"key":"e_1_2_1_26_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE55347.2025.00027"},{"key":"e_1_2_1_27_1","doi-asserted-by":"publisher","DOI":"10.4018\/JCIT"},{"key":"e_1_2_1_28_1","unstructured":"B Mueller. 2017. Mythril-Reversing and bug hunting framework for the Ethereum blockchain. https:\/\/pypi.org\/project\/ mythril\/0.8.2"},{"key":"e_1_2_1_29_1","doi-asserted-by":"publisher","unstructured":"Emanuele Antonio Napoli Fadi Barb\u00e0ra Valentina Gatteschi and Claudio Schifanella. 2024. Leveraging Large Language Models for Automatic Smart Contract Generation. In 2024 IEEE 48th Annual Computers Software and Applications Conference (COMPSAC). 701-710. doi:10.1109\/COMPSAC61105.2024.00100 10.1109\/COMPSAC61105.2024.00100","DOI":"10.1109\/COMPSAC61105.2024.00100"},{"key":"e_1_2_1_30_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2503.18470"},{"key":"e_1_2_1_31_1","volume-title":"Proceedings of the 40th annual meeting of the Association for Computational Linguistics. 311-318","author":"Papineni Kishore","year":"2002","unstructured":"Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. 2002. BLEU: a Method for Automatic Evaluation of Machine Translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics. 311-318. https:\/\/aclanthology.org\/P02-1040.pdf"},{"key":"e_1_2_1_32_1","doi-asserted-by":"publisher","DOI":"10.1109\/ACCESS"},{"key":"e_1_2_1_33_1","doi-asserted-by":"publisher","DOI":"10.1145\/3543507.3583367"},{"key":"e_1_2_1_34_1","unstructured":"Qwen. 2025. QwQ-32B. https:\/\/huggingface.co\/Qwen\/QwQ-32B."},{"key":"e_1_2_1_35_1","doi-asserted-by":"publisher","DOI":"10.1145\/3394486.3406703"},{"key":"e_1_2_1_36_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2009.10297"},{"key":"e_1_2_1_37_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2308.12950"},{"key":"e_1_2_1_38_1","doi-asserted-by":"publisher","DOI":"10.1109\/IJCNN60899.2024.10651109"},{"key":"e_1_2_1_39_1","doi-asserted-by":"publisher","DOI":"10.1145\/3689031.3696075"},{"key":"e_1_2_1_40_1","doi-asserted-by":"publisher","unstructured":"Andr\u00e9 Storhaug Jingyue Li and Tianyuan Hu. 2023. Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decoding. In 2023 IEEE 34th International Symposium on Software Reliability Engineering (ISSRE). 683-693. doi:10.1109\/ISSRE59848.2023.00035 10.1109\/ISSRE59848.2023.00035","DOI":"10.1109\/ISSRE59848.2023.00035"},{"key":"e_1_2_1_41_1","doi-asserted-by":"publisher","DOI":"10.1145\/3597503.3639117"},{"key":"e_1_2_1_42_1","volume-title":"Blockchain: Blueprint for a New Economy","author":"Swan Melanie","year":"2015","unstructured":"Melanie Swan. 2015. Blockchain: Blueprint for a New Economy. O'Reilly Media, Inc. 152 pages."},{"key":"e_1_2_1_43_1","doi-asserted-by":"publisher","DOI":"10.1109\/ISSRE66568.2025.00033"},{"key":"e_1_2_1_44_1","doi-asserted-by":"publisher","DOI":"10.1145\/3194113.3194115"},{"key":"e_1_2_1_45_1","doi-asserted-by":"publisher","DOI":"10.1145\/3243734.3243780"},{"key":"e_1_2_1_46_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2504.21043"},{"key":"e_1_2_1_47_1","doi-asserted-by":"publisher","DOI":"10.18653\/v1\/2024.acl-long.331"},{"key":"e_1_2_1_48_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2508.05242"},{"key":"e_1_2_1_49_1","volume-title":"OctoThinker: Mid-Training Incentivizes Reinforcement Learning Scaling. In 2nd AI for Math Workshop @ ICML","author":"Wang Zengzhi","year":"2025","unstructured":"Zengzhi Wang, Fan Zhou, Xuefeng Li, and Pengfei Liu. 2025. OctoThinker: Mid-Training Incentivizes Reinforcement Learning Scaling. In 2nd AI for Math Workshop @ ICML 2025. https:\/\/openreview.net\/forum?id=chCeUHjLzs"},{"key":"e_1_2_1_50_1","first-page":"24824","volume-title":"Oh (Eds.)","volume":"35","author":"Wei Jason","year":"2022","unstructured":"Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, brian ichter, Fei Xia, Ed Chi, Quoc V Le, and Denny Zhou. 2022. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. In Advances in Neural Information Processing Systems, S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh (Eds.), Vol. 35. Curran Associates, Inc., 24824-24837. https:\/\/proceedings.neurips.cc\/paper_files\/paper\/2022\/file\/9d5609613524ecf4f15af0f7b31abca4- Paper-Conference.pdf"},{"key":"e_1_2_1_51_1","volume-title":"Ethereum: A secure decentralised generalised transaction ledger. Ethereum project yellow paper 151","author":"Gavin Wood","year":"2014","unstructured":"Gavin Wood et al. 2014. Ethereum: A secure decentralised generalised transaction ledger. Ethereum project yellow paper 151, 2014 (2014), 1-32. https:\/\/ethereum.github.io\/yellowpaper\/paper.pdf"},{"key":"e_1_2_1_52_1","doi-asserted-by":"publisher","unstructured":"Hongjun Wu Zhuo Zhang Shangwen Wang Yan Lei Bo Lin Yihao Qin Haoyu Zhang and Xiaoguang Mao. 2021. Peculiar: Smart Contract Vulnerability Detection Based on Crucial Data Flow Graph and Pre-training Techniques. In 2021 IEEE 32nd International Symposium on Software Reliability Engineering (ISSRE). 378-389. doi:10.1109\/ISSRE52982. 2021.00047 10.1109\/ISSRE52982.2021.00047","DOI":"10.1109\/ISSRE52982"},{"key":"e_1_2_1_53_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2505.14677"},{"key":"e_1_2_1_54_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2502.14768"},{"key":"e_1_2_1_55_1","doi-asserted-by":"publisher","unstructured":"An Yang Anfeng Li Baosong Yang et al. 2025. Qwen3 Technical Report. arXiv:2505.09388 [cs.CL] doi:10.48550\/arXiv. 2505.09388 10.48550\/arXiv.2505.09388","DOI":"10.48550\/arXiv"},{"key":"e_1_2_1_56_1","doi-asserted-by":"publisher","unstructured":"An Yang Baosong Yang Beichen Zhang Binyuan Hui Bo Zheng Bowen Yu Chengyuan Li Dayiheng Liu Fei Huang Haoran Wei et al. 2024. Qwen2.5 Technical Report. arXiv:2412.15115 [cs.CL] doi:10.48550\/arXiv.2412.15115 10.48550\/arXiv.2412.15115","DOI":"10.48550\/arXiv.2412.15115"},{"key":"e_1_2_1_57_1","doi-asserted-by":"publisher","DOI":"10.1109\/IJCNN54540.2023.10191121"},{"key":"e_1_2_1_58_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2411.06221"},{"key":"e_1_2_1_59_1","doi-asserted-by":"publisher","unstructured":"Lei Yu Shiqi Cheng Zhirong Huang Jingyuan Zhang Chenjie Shen Junyi Lu Li Yang Fengjun Zhang and Jiajia Ma. 2025. SAEL: Leveraging Large Language Models with Adaptive Mixture-of-Experts for Smart Contract Vulnerability Detection. In 2025 IEEE International Conference on Software Maintenance and Evolution (ICSME). 61-72. doi:10.1109\/ ICSME64153.2025.00016 10.1109\/ICSME64153.2025.00016","DOI":"10.1109\/ICSME64153.2025.00016"},{"key":"e_1_2_1_60_1","doi-asserted-by":"publisher","DOI":"10.1145\/3728878"},{"key":"e_1_2_1_61_1","doi-asserted-by":"publisher","DOI":"10.1109\/ISSRE59848.2023.00030"},{"key":"e_1_2_1_62_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2603.18606"},{"key":"e_1_2_1_63_1","doi-asserted-by":"publisher","DOI":"10.1109\/IJCNN54540.2023.10191217"},{"key":"e_1_2_1_64_1","doi-asserted-by":"publisher","unstructured":"Hang Yuan Xizhi Hou Lei Yu Li Yang Jiayue Tang Jiadong Xu Yifei Liu Fengjun Zhang and Chun Zuo. 2025. Leveraging Mixture-of-Experts Framework for Smart Contract Vulnerability Repair with Large Language Model. In 2025 40th IEEE\/ACM International Conference on Automated Software Engineering (ASE). 1667-1679. doi:10.1109\/ ASE63991.2025.00140 10.1109\/ASE63991.2025.00140","DOI":"10.1109\/ASE63991.2025.00140"},{"key":"e_1_2_1_65_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2504.12234"},{"key":"e_1_2_1_66_1","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.2408.14354"},{"key":"e_1_2_1_67_1","first-page":"162403","volume-title":"Advances in Neural Information Processing Systems","volume":"38","author":"Zhang Jingyuan","year":"2025","unstructured":"Jingyuan Zhang, Xin Wang, Lei Yu, Zhirong Huang, Li Yang, and Fengjun Zhang. 2025. Restricted Global-Aware Graph Filters Bridging GNNs and Transformer for Node Classification. In Advances in Neural Information Processing Systems, Vol. 38. Curran Associates, Inc., 162403-162429. https:\/\/proceedings.neurips.cc\/paper_files\/paper\/2025\/file\/ edbcb7583fd8921dad78adecfe06a99b-Paper-Conference.pdf"},{"key":"e_1_2_1_68_1","doi-asserted-by":"publisher","DOI":"10.1609\/aaai.v40i19.38671"},{"key":"e_1_2_1_69_1","doi-asserted-by":"publisher","DOI":"10.1145\/3748727"},{"key":"e_1_2_1_70_1","doi-asserted-by":"publisher","DOI":"10.18653\/v1\/2024.acl-demos.38"},{"key":"e_1_2_1_71_1","doi-asserted-by":"publisher","DOI":"10.5555\/3491440.3491894"},{"key":"e_1_2_1_72_1","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2019.2942301"}],"container-title":["Proceedings of the ACM on Software Engineering"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3808104","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T18:35:11Z","timestamp":1782844511000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3808104"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2026,6,30]]},"references-count":72,"journal-issue":{"issue":"FSE","published-print":{"date-parts":[[2026,6,30]]}},"alternative-id":["10.1145\/3808104"],"URL":"https:\/\/doi.org\/10.1145\/3808104","relation":{},"ISSN":["2994-970X"],"issn-type":[{"value":"2994-970X","type":"electronic"}],"subject":[],"published":{"date-parts":[[2026,6,30]]}}}