Guiding LLM-based Smart Contract Generation with Finite State Machine
Hao Luo, Yuhao Lin, Xiao Yan, Xintong Hu, Yuxiang Wang, Qiming Zeng, Hao Wang, Jiawei Jiang

TL;DR
This paper introduces FSM-SCG, a framework that combines finite state machines with large language models to enhance the quality, security, and success rate of automatically generated smart contracts.
Contribution
The paper presents a novel FSM-guided LLM framework for smart contract generation, improving effectiveness and security over existing methods.
Findings
Increases compilation success rate by up to 48%.
Reduces vulnerability risk score by approximately 68%.
Significantly improves smart contract quality.
Abstract
Smart contract is a kind of self-executing code based on blockchain technology with a wide range of application scenarios, but the traditional generation method relies on manual coding and expert auditing, which has a high threshold and low efficiency. Although Large Language Models (LLMs) show great potential in programming tasks, they still face challenges in smart contract generation w.r.t. effectiveness and security. To solve these problems, we propose FSM-SCG, a smart contract generation framework based on finite state machine (FSM) and LLMs, which significantly improves the quality of the generated code by abstracting user requirements to generate FSM, guiding LLMs to generate smart contracts, and iteratively optimizing the code with the feedback of compilation and security checks. The experimental results show that FSM-SCG significantly improves the quality of smart contract…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
