Порівняльний аналіз генерації смарт-контрактів Solidity за допомогою великих мовних моделей на основі формальних алгебраїчних специфікацій
| dc.contributor.affiliation | Херсонський державний університет | |
| dc.contributor.author | Песчаненко, Володимир | |
| dc.contributor.author | Коннова, Ольга | |
| dc.coverage.placename | Львів | |
| dc.date.accessioned | 2025-10-28T15:10:13Z | |
| dc.date.issued | 2025 | |
| dc.date.submitted | 2025 | |
| dc.description.abstract | Дана стаття присвячена порівняльному аналізу автоматичної генерації смартконтрактів на мові Solidity за допомогою великих мовних моделей на основі двох підходів: текстових описів природною мовою та формальних алгебраїчних специфікацій. У ході роботи було проаналізовано смарт-контракти, згенеровані великими мовними моделями (ChatGPT-4, Claude 3.7 Sonnet, DeepSeek-V3), а також інструментом на основі штучного інтелекту GitHub Copilot, з оцінкою їхньої синтаксичної коректності та відповідності початковим вимогам. Безпека смарт-контрактів оцінювалася за допомогою статичного аналізу з використанням інструменту Slither, для виявлення потенційних вразливостей, зокрема атак повторного входу та арифметичних переповнень. Для створення формальної моделі ми використовували інсерційне моделювання, яке дозволяє формально описувати поведінку смарт-контрактів через алгебраїчні специфікації. Для покращення інтерпретації великими мовними моделями алгебраїчних специфікацій, нами було запропоновано підхід промптингу з невеликою кількістю прикладів, який передбачає надання LLM демонстраційних прикладів алгебраїчних специфікацій і відповідного коду Solidity для покращення інтерпретації формальних моделей. Запропонований підхід дозволив підвищити точність трансляції формальних специфікацій у код, зменшити кількість синтаксичних помилок та забезпечити кращу відповідність до вихідної моделі. У ході дослідження було виявлено, що текстові запити є простішими для швидкої генерації, однак менш надійними. Через властиву їм двозначність вони частіше призводять до появи прихованих вразливостей. Натомість формальні моделі вимагають більше зусиль для налаштування великих мовних моделей та усунення помилок інтерпретації, проте дозволяють значно точніше відобразити логіку смарт-контракту, що забезпечує більш якісну генерацію контрактів зі складною поведінкою. This article presents a comparative analysis of automatic Solidity smart contract generation using large language models (LLMs) based on two approaches: natural language textual descriptions and formal algebraic specifications. The study analyzes smart contracts generated by LLMs (ChatGPT-4, Claude 3.7 Sonnet, DeepSeek-V3) as well as by the AI-based tool GitHub Copilot, evaluating their syntactic correctness, compliance with initial requirements, and security. The security of the smart contracts was assessed through static analysis using the Slither tool to identify potential vulnerabilities, including reentrancy attacks and arithmetic overflows. To create the formal specification, we applied the Insertion Modeling System (IMS), which enables formal descriptions of smart contract behavior using algebraic specifications. To improve the interpretation of these specifications by large language models, we proposed a few-shot prompting approach, which involves providing LLM with demonstration examples of algebraic specifications and the corresponding Solidity code to improve the interpretation of formal models. The proposed approach allowed us to increase the accuracy of translating formal specifications into code, reduce the number of syntax errors, and ensure better compliance with the original model. The study found that natural language prompts are easier to use for quick code generation but are less reliable, as their inherent ambiguity tends to produce hidden vulnerabilities. In contrast, formal models require additional effort to guide the LLM and eliminate interpretation errors, but they allow for a much more accurate representation of contract logic, resulting in higher-quality generation of contracts with complex behavior. | |
| dc.format.pages | 229-243 | |
| dc.identifier.citation | Песчаненко В. Порівняльний аналіз генерації смарт-контрактів Solidity за допомогою великих мовних моделей на основі формальних алгебраїчних специфікацій / Володимир Песчаненко, Ольга Коннова // Вісник Національного університету "Львівська політехніка". Інформаційні системи та мережі. – 2025. – Випуск 18 (частина 1). – С. 229–243. | |
| dc.identifier.uri | https://ena.lpnu.ua/handle/ntb/115498 | |
| dc.language.iso | uk | |
| dc.publisher | Національний університет «Львівська політехніка» | |
| dc.relation.references | Bergmann, D. (2024). Context window. IBM.com. https://www.ibm.com/think/topics/context-window Chatterjee, S., Ramamurthy, B. (2025). Efficacy of Various Large Language Models in Generating Smart Contracts. In: Arai, K. (eds) Advances in Information and Communication. FICC 2025. Lecture Notes in Networks and Systems, vol 1284. Springer, Cham. https://doi.org/10.1007/978-3-031-85363-0_31 Cleary, D. (2025). In Context Learning Guide. PromptHub. https://www.prompthub.us/blog/in-context-learning-guide Crytic. Slither static analysis framework. GitHub. https://github.com/crytic/slither Fadi, B., Napoli, E. A., Gatteschi, V., & Schifanella, C. (2024). Automatic Smart Contract Generation Through LLMs: When The Stochastic Parrot Fails. In Proceedings of DLT 2024. CEUR. Fravoll. Checks, Effects, Interactions pattern in Solidity. (2025) https://fravoll.github.io/soliditypatterns/checks_effects_interactions.html Kang, I., Woensel, W. V., & Seneviratne, O. (2024). Using Large Language Models for Generating Smart Contracts for Health Insurance from Textual Policies. In AI for Health Equity and Fairness (pp. 129–146). Springer. https://doi.org/10.1007/978-3-031-63592-2_11 Letichevsky, A., Kapitonova, J., Letichevsky Jr, A., Volkov, V., Baranov, S., & Weigert, T. (2005). Basic protocols, message sequence charts, and the verification of requirements specifications. Computer Networks, 49(5), 661–675. https://doi.org/10.1016/j.comnet.2005.05.005 Letichevsky, A., Letychevskyi, O., & Peschanenko, V. (2016). Insertion modeling and its applications. Computer Science Journal of Moldova, 72(3), 357–370. Modi, M. (2024). Transforming software development through generative AI: A systematic analysis of automated development practices. International Journal of Scientific Research in Computer Science, Engineering and Information Technology, 10(6), 536–547. https://doi.org/10.32628/cseit24106197 Peschanenko, V., Poltorackiy, M., & Konnova, O. (2025). Verification of Smart Contract Code Generated by Applying Artificial Intelligence. In: Ermolayev, V., et al. Information and Communication Technologies in Education, Research, and Industrial Applications. ICTERI 2024. Communications in Computer and Information Science, vol 2359. Springer. https://doi.org/10.1007/978-3-031-81372-6_1 Prompt Engineering Guide. Few-shot prompting. https://www.promptingguide.ai/techniques/fewshot Wong, M. F., Guo, S., Hang, C. N., Ho, S., & Tan, C. W. (2023). Natural language generation and understanding of big code for AI-assisted programming: A review. Entropy, 25. | |
| dc.relation.uri | https://doi.org/10.23939/sisn2025.18.229 | |
| dc.subject | блокчейн, смарт-контракти, штучний інтелект, великі мовні моделі, алгебраїчні специфікації, інсерційне моделювання, генерація смарт-контрактів, Solidity, blockchain, smart contracts, artificial intelligence, LLM, algebraic specifications, insertion modeling, smart contract generation, Solidity | |
| dc.subject.udc | 004.415:004.89 | |
| dc.title | Порівняльний аналіз генерації смарт-контрактів Solidity за допомогою великих мовних моделей на основі формальних алгебраїчних специфікацій | |
| dc.title.alternative | Comparative analysis of Solidity smart contract generation using large language models based on formal algebraic specifications | |
| dc.type | Article |