arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.23009cs.SE
收藏

SolAgent: 一种专门用于Solidity代码生成的多智能体框架

SolAgent: A Specialized Multi-Agent Framework for Solidity Code Generation

Shanghai Jiao Tong University(上海交通大学);The State Key Laboratory of Blockchain and Data Security, Zhejiang University(浙江大学区块链与数据安全全国重点实验室)

Wei Chen, Zhiyuan Peng, Xin Yin, Chao Ni, Chenhao Ying, Bang Xie, Yuan Luo

AI总结:

SolAgent通过双循环机制和文件系统能力,在智能合约生成中实现高正确性和安全性,Pass@1率达64.39%,减少安全漏洞39.77%。

摘要:

智能合约是去中心化网络的骨干,但确保其功能正确性和安全性仍然是一个关键挑战。尽管大型语言模型(LLMs)在代码生成方面显示出潜力,但它们在智能合约的严格要求下经常产生易出错或有漏洞的代码。为此,我们提出了SolAgent,一种新颖的工具增强型多智能体框架,模仿专家的工作流程。SolAgent集成了一个双循环精炼机制:内循环使用Forge编译器确保功能正确性,外循环利用Slither静态分析器消除安全漏洞。此外,该代理配备了文件系统能力以解决复杂的项目依赖关系。在SolEval+基准测试上,该基准测试是一套源自高质量真实项目严格测试集,实验表明SolAgent实现了高达64.39%的Pass@1率,显著优于最先进的LLMs(约25%)、AI IDEs(如GitHub Copilot)和现有智能体框架。此外,与人工编写的基础线相比,它将安全漏洞减少了高达39.77%。最后,我们证明了SolAgent生成的高质量轨迹可用于提炼更小的开源模型,使安全智能合约生成更加普及。我们发布了数据和代码在https://github.com/openpaperz/SolAgent。

英文摘要:

Smart contracts are the backbone of the decentralized web, yet ensuring their functional correctness and security remains a critical challenge. While Large Language Models (LLMs) have shown promise in code generation, they often struggle with the rigorous requirements of smart contracts, frequently producing code that is buggy or vulnerable. To address this, we propose SolAgent, a novel tool-augmented multi-agent framework that mimics the workflow of human experts. SolAgent integrates a \textbf{dual-loop refinement mechanism}: an inner loop using the \textit{Forge} compiler to ensure functional correctness, and an outer loop leveraging the \textit{Slither} static analyzer to eliminate security vulnerabilities. Additionally, the agent is equipped with file system capabilities to resolve complex project dependencies. Experiments on the SolEval+ Benchmark, a rigorous suite derived from high-quality real-world projects, demonstrate that SolAgent achieves a Pass@1 rate of up to \textbf{64.39\%}, significantly outperforming state-of-the-art LLMs ($\sim$25\%), AI IDEs (e.g., GitHub Copilot), and existing agent frameworks. Moreover, it reduces security vulnerabilities by up to \textbf{39.77\%} compared to human-written baselines. Finally, we demonstrate that the high-quality trajectories generated by SolAgent can be used to distill smaller, open-source models, democratizing access to secure smart contract generation. We release our data and code at https://github.com/openpaperz/SolAgent.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑