mlsanityData to 14 Oct 2026

Towards Secure and Explainable Smart Contract Generation with Security-Aware Group Relative Policy Optimization

arXiv 2509.09942 ↗First posted 12 Sep 2025cs.CR cs.AI cs.SEcited by 1

On the map: LLM reasoning → Reasoning for agents, planning and code

Abstract (arXiv)

Smart contracts automate the management of high-value assets, where vulnerabilities can lead to catastrophic financial losses. This challenge is amplified in Large Language Models (LLMs) by two interconnected failures: they operate as unauditable "black boxes" lacking a transparent reasoning process, and consequently, 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 model. We then apply Long Chain-of-Thought Supervised Fine-Tuning (L-CoT SFT) on 7,998 expert-validated reasoning-and-code 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 by optimizing a weighted reward signal for compilation success, security compliance, and format correctness. Evaluated against 17 baselines on a benchmark of 756 real-world functions, SmartCoder-R1 establishes a new state of the art, 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%).

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 33 of its 61 references that are in the map. First posted on arXiv 12 Sep 2025.

Builds on

33 of 61 references.

Closest ancestors · 3

Same direction, newest first

  1. 2025Fin-R1: A Large Language Model for Financial Reasoning through Reinforcement Learning20 Mar
  2. 2024Qwen2.5-Coder Technical Report18 Sep
  3. 2024Rethinking the Bounds of LLM Reasoning: Are Multi-Agent Discussions the Key?28 Feb

Other references · 30

  1. 2025Qwen3 Technical Reportcited by 8,820
  2. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  3. 2024HybridFlow: A Flexible and Efficient RLHF Frameworkcited by 2,057
  4. 2024LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Modelscited by 1,464
  5. 2025Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learningcited by 1,444
  6. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  7. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
  8. 2025SWE-RL: Advancing LLM Reasoning via Reinforcement Learning on Open Software Evolutioncited by 263
  9. 2025GUI-R1 : A Generalist R1-Style Vision-Language Action Model For GUI Agentscited by 244
  10. 2025UI-R1: Enhancing Efficient Action Prediction of GUI Agents by Reinforcement Learningcited by 168
  11. 2025OctoThinker: Mid-training Incentivizes Reinforcement Learning Scalingcited by 113
  12. 2025Visionary-R1: Mitigating Shortcuts in Visual Reasoning with Reinforcement Learningcited by 87
18 more
  1. 2025SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learningcited by 68
  2. 2023GPTScan: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysiscited by 65
  3. 2018Securify: Practical Security Analysis of Smart Contractscited by 61
  4. 2025MetaSpatial: Reinforcing 3D Spatial Reasoning in VLMs for the Metaversecited by 51
  5. 2023Large Language Model-Powered Smart Contract Vulnerability Detection: New Perspectivescited by 48
  6. 2023When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?cited by 42
  7. 2024Combining Fine-Tuning and LLM-based Agents for Intuitive Smart Contract Auditing with Justificationscited by 41
  8. 2023Do you still need a manual smart contract audit?cited by 35
  9. 2025ReCode: Reinforcing Code Generation with Reasoning-Process Rewardscited by 25
  10. 2021Smart Contract Vulnerability Detection: From Pure Neural Network to Interpretable Graph Feature and Expert Pattern Fusioncited by 24
  11. 2023Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decodingcited by 14
  12. 2024Identifying Smart Contract Security Issues in Code Snippets from Stack Overflowcited by 8
  13. 2024Smart-LLaMA: Two-Stage Post-Training of Large Language Models for Smart Contract Vulnerability Detection and Explanationcited by 8
  14. 2025CodeBoost: Boosting Code LLMs by Squeezing Knowledge from Code Snippets with RLcited by 7
  15. 2017Blockchain-based Smart Contracts: A Systematic Mapping Studycited by 5
  16. 2019SmartEmbed: A Tool for Clone and Bug Detection in Smart Contracts through Structural Code Embeddingcited by 4
  17. 2025CodeBC: A More Secure Large Language Model for Smart Contract Code Generation in Blockchaincited by 2
  18. 2025SAEL: Leveraging Large Language Models with Adaptive Mixture-of-Experts for Smart Contract Vulnerability Detectioncited by 2

Built on by

Cited by year

Citing papers per year: 2025: 1.

1 paper.

Similar, not cited

Close in wording, no citation either way

  1. 2025Beyond Code Similarity: Benchmarking the Plausibility, Efficiency, and Complexity of LLM-Generated Smart Contracts
  2. 2025Curriculum-Guided Reinforcement Learning for Synthesizing Gas-Efficient Financial Derivatives Contracts
  3. 2026Beyond Detection: Agentic Attack Synthesis and Simulation for Smart Contracts
  4. 2026Repository-Level Solidity Code Generation with Large Language Models: From Prompting to Fine-Tuning
  5. 2026EvoPoC: Automated Exploit Synthesis for DeFi Smart Contracts via Hierarchical Knowledge Graphs ↗
  6. 2025Securing Smart Contract Languages with a Unified Agentic Framework for Vulnerability Repair in Solidity and Move
  7. 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model
  8. 2024FTSmartAudit: A Knowledge Distillation-Enhanced Framework for Automated Smart Contract Auditing Using Fine-Tuned LLMs