SCGen-Agent: Automated Generation of Smart Contract Based on Multi-agent Collaboration
Abstract
To address the issues of inefficiency and high debugging costs in smart contract development, this paper proposes a multi-agent collaborative solution based on large language models (LLMs). In this approach, agents collaborate to accomplish tasks such as smart contract generation, auditing, and repair. First, an efficient fine-tuning method is employed to optimize the code generation model. Second, retrieval-augmented generation technology is utilized to provide vulnerability context knowledge for code repair. Finally, a feedback-driven multi-agent collaboration framework is designed to enhance code generation quality through agent-to-agent feedback. During the code repair phase, semantic prompts derived from control flow graphs guide the LLM in contract repair. Experimental results demonstrate that the multi-agent architecture significantly enhances the capabilities of smart contract generation and auditing. By leveraging knowledge of vulnerabilities and external tools, the approach improves the LLM's understanding of smart contract structures. Compared to a single LLM approach, the generated code shows significant improvements in CodeBLEU scores, compilation pass rates, and vulnerability rates.
Community
0 commentsNo discussion yet
Be the first to share a question or observation.