Guiding LLM-based Smart Contract Generation with Finite State Machine
Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence. Main Track. Pages 5869-5877.
https://doi.org/10.24963/ijcai.2025/653
Keywords
- Machine Learning: ML: Applications
- Machine Learning: ML: Foundation models
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 generation. Compared to the best baseline, FSM-SCG improves the compilation success rate of generated smart contract code by at most 48%, and reduces the average vulnerability risk score by approximately 68%.
@inproceedings{ijcai2025p653,
title = {Guiding LLM-based Smart Contract Generation with Finite State Machine},
author = {Luo, Hao and Lin, Yuhao and Yan, Xiao and Hu, Xintong and Wang, Yuxiang and Zeng, Qiming and Wang, Hao and Jiang, Jiawei},
booktitle = {Proceedings of the Thirty-Fourth International Joint Conference on
Artificial Intelligence, {IJCAI-25}},
publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {James Kwok},
pages = {5869--5877},
year = {2025},
month = {8},
note = {Main Track},
doi = {10.24963/ijcai.2025/653},
url = {https://doi.org/10.24963/ijcai.2025/653},
}
TY - CPAPER TI - Guiding LLM-based Smart Contract Generation with Finite State Machine AU - Luo, Hao AU - Lin, Yuhao AU - Yan, Xiao AU - Hu, Xintong AU - Wang, Yuxiang AU - Zeng, Qiming AU - Wang, Hao AU - Jiang, Jiawei T2 - Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence, IJCAI-25 PB - International Joint Conferences on Artificial Intelligence Organization PY - 2025 SP - 5869 EP - 5877 DO - 10.24963/ijcai.2025/653 UR - https://doi.org/10.24963/ijcai.2025/653 ER -Copied
Machine-readable versions of this paper, for tools and AI agents: