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
International Computer Software and Applications Conference
jpn
2024
Proceedings - 2024 IEEE 48th Annual Computers, Software, and Applications Conference, COMPSAC 2024
Institute of Electrical and Electronics Engineers Inc.
24
701
710
979-8-3503-7696-8
automatic code generation, blockchain, LLM, NLP, smart contract, text-to-code
Napoli Emanuele Antonio; Barbara F.; Gatteschi V.; Schifanella C.
File in questo prodotto:
File Dimensione Formato  
2024_COMPSAC.pdf

Accesso aperto

Tipo di file: POSTPRINT (VERSIONE FINALE DELL’AUTORE)
Dimensione 825.74 kB
Formato Adobe PDF
825.74 kB Adobe PDF Visualizza/Apri
Leveraging_Large_Language_Models_for_Automatic_Smart_Contract_Generation.pdf

Accesso riservato

Tipo di file: PDF EDITORIALE
Dimensione 632.29 kB
Formato Adobe PDF
632.29 kB Adobe PDF   Visualizza/Apri   Richiedi una copia

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 15
  • ???jsp.display-item.citation.isi??? 8
social impact