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.
2024
48th IEEE Annual Computers, Software, and Applications Conference, COMPSAC 2024
jpn
2024
Proceedings - 2024 IEEE 48th Annual Computers, Software, and Applications Conference, COMPSAC 2024
Institute of Electrical and Electronics Engineers Inc.
24
701
710
automatic code generation; blockchain; LLM; NLP; smart contract; text-to-code
Napoli Emanuele Antonio; Barbara F.; Gatteschi V.; Schifanella C.
File in questo prodotto:
Non ci sono file associati a questo prodotto.

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/2318/2025290
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 1
  • ???jsp.display-item.citation.isi??? ND
social impact