Year: 2026
Type: dissertation
Abstract: Smart contracts are self-executing programs deployed on blockchain platforms that automate transactions and enforce digital agreements without intermediaries. Despite their transformative potential for decentralized finance, legal automation, and supply chain governance, their adoption is constrained by three interrelated barriers: the programming expertise required to write correct Solidity code excludes non-technical users; the immutable nature of deployed contracts makes undetected vulnerabilities permanently exploitable; and the absence of accessible comprehension tools prevents stakeholders from auditing the code that governs their assets. This thesis addresses these limitations through six contributions organized around three complementary research questions, concerning vulnerability correction, automated contract generation, and visual comprehension. First, this work investigates the application of Large Language Models (LLMs) for automatic smart contract generation from legal agreements and textual descriptions. Through comprehensive evaluation of multiple state-of-the-art LLMs including GPT-4 by OpenAI, Claude 3.5 by Anthropic, Mistral by MistralAI, and Gemini by Google, employing the CO-STAR prompt engineering methodology, the research reveals fundamental limitations in current LLM capabilities [1]. Analysis of 57 generated smart contracts demonstrates that while LLMs achieve promising compilation rates, they consistently produce production-unsafe code containing undetected logical flaws, incorrect implementation of legal requirements, and critical security vulnerabilities. The findings establish that contemporary LLMs cannot autonomously generate reliable smart contracts, highlighting the necessity for hybrid approaches combining AI assistance with expert validation. Towards the second research question, three studies of increasing scope investigate LLM-based smart contract generation from legal agreements.A GPT-4-build generation pipeline and the CO-STAR prompt engineering methodology achieve vi 98.1% compilability across 17 prompt templates applied to a property rental agreement.A subsequent expert manual evaluation of 68 generated contracts reveals five categories of critical failure invisible to automated tools, including permanently frozen funds, absent deposit logic, and universal currency mismanagement.A multi-model comparative study then extends the analysis to four frontier LLMs (GPT-4-Turbo, Claude 3.5, Mistral, and Gemini) across five legal agreements of varying complexity, totaling 480 API calls. Results establish a performance hierarchy (Claude > GPT-4-Turbo > Gemini > Mistral), demonstrate non-linear performance degradation with agreement complexity, and show that supplying a worked exemplar together with reasoning-mode inference yields substantial improvements on the weakest model-agreement combination. The collective conclusion is that current LLMs cannot autonomously generate production-ready smart contracts and that expert review is an indispensable complement to automated metrics. Third, to address the accessibility challenge, this thesis presents an innovative visualization and analysis tool that enhances smart contract comprehension through UML-based representations and AI-powered annotations. The system integrates automated security auditing via Slither, version control mechanisms, and intelligent code analysis using LLMs.Comparative evaluation against Remix IDE using the NASA-TLX questionnaire demonstrates a statistically significant workload reduction (52.66 versus 71.74; Wilcoxon signed-rank test, n = 36, p < 0.001), with particular improvements in mental demand, temporal demand, and user frustration. The tool successfully bridges the knowledge gap for intermediate users while maintaining utility for experts, making smart contract development and analysis accessible to everyone. Collectively, these contributions demonstrate that LLMs and visual tools can meaningfully reduce barriers to smart contract development while establishing that human oversight remains essential for production-quality outcomes. Contents List of Figures xiv List of Tables xvi 8.2 NASA-TLX raw ratings per dimension and weighted overall workload score for the proposed tool and Remix IDE.Lower values indicate lower perceived workload. The p-values are those of two-sided Wilcoxon signed-rank tests on the 36 matched pairs, Holm-corrected across the six dimensions; the overall row reports the test on the participant-level weighted composite. . . . . . . . . . . . . . . . .
Source: PORTO@Iris
Author: NAPOLI, EMANUELE ANTONIO
Institution: Politecnico di Torino
Language: English
Subfield: Information Systems
Field: Computer Science
Domain: Physical Sciences
Open Access status: green
OpenAlex ID: W7224043072
