In the rapidly evolving landscape of blockchain technology, smart contracts stand as pivotal instrument for automating and enforcing digital agreements. However, their creation often necessitates specialized programming skills, hindering broader adoption and accessibility. This paper proposes a pipeline that leverages the capabilities of Large Language Models (LLMs) to automate the generation of smart contracts. By harnessing the natural language understanding and generation capabilities of LLMs, our approach aims to make accessible smart contract development to people that are not familiar with this task. The proposed pipeline employs the CO-STAR methodology to optimize prompt creation for high-quality outputs. Moreover, in order to assess the correctness and reliability of the generated smart contracts, we leverage on Slither, one of the most cutting-edge vulnerability detection tools. Furthermore, we propose a benchmarking suite based on metrics such as compilability, vulnerabilities, and presence of comments, among the others, in order to evaluate the effectiveness of the pipeline in terms of consistency of generated smart contracts, LLM's temperature effect, and prompt selection. The results show that our pipeline is able to produce 98.1% of compilable smart contracts, the temperature value has negligible effect on the generated smart contracts, and the CO-STAR methodology produces valuable and consistent outputs with low-impact vulnerabilities.
Leveraging Large Language Models for Automatic Smart Contract Generation
Barbara F.;Gatteschi V.;Schifanella C.
2024-01-01
Abstract
In the rapidly evolving landscape of blockchain technology, smart contracts stand as pivotal instrument for automating and enforcing digital agreements. However, their creation often necessitates specialized programming skills, hindering broader adoption and accessibility. This paper proposes a pipeline that leverages the capabilities of Large Language Models (LLMs) to automate the generation of smart contracts. By harnessing the natural language understanding and generation capabilities of LLMs, our approach aims to make accessible smart contract development to people that are not familiar with this task. The proposed pipeline employs the CO-STAR methodology to optimize prompt creation for high-quality outputs. Moreover, in order to assess the correctness and reliability of the generated smart contracts, we leverage on Slither, one of the most cutting-edge vulnerability detection tools. Furthermore, we propose a benchmarking suite based on metrics such as compilability, vulnerabilities, and presence of comments, among the others, in order to evaluate the effectiveness of the pipeline in terms of consistency of generated smart contracts, LLM's temperature effect, and prompt selection. The results show that our pipeline is able to produce 98.1% of compilable smart contracts, the temperature value has negligible effect on the generated smart contracts, and the CO-STAR methodology produces valuable and consistent outputs with low-impact vulnerabilities.I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.