# Generation of Optimized Solidity Code for Machine Learning Models using LLMs

arXiv: https://arxiv.org/abs/2503.06203 · HTML: https://mlsanity.com/paper/2503.06203/

## Key facts

- Cited by 1 papers in the map (data through 14 Oct 2026).
- Builds on 5 of its 25 references that are in the map.
- First posted on arXiv 8 Mar 2025.

## Builds on (most cited first, 5 of 5)

- [Decentralized & Collaborative AI on Blockchain](https://mlsanity.com/paper/1907.07247/) (2019)
- [Trustless Machine Learning Contracts; Evaluating and Exchanging Machine Learning Models on the Ethereum Blockchain](https://mlsanity.com/paper/1802.10185/) (2018)
- [Analysis of Models for Decentralized and Collaborative AI on Blockchain](https://mlsanity.com/paper/2009.06756/) (2020)
- [Leveraging Machine Learning for Multichain DeFi Fraud Detection](https://mlsanity.com/paper/2306.07972/) (2023)
- [ML2SC: Deploying Machine Learning Models as Smart Contracts on the Blockchain](https://mlsanity.com/paper/2404.16967/) (2024)

## Built on by (most cited first, 1 of 1)

- [On-Chain Decentralized Learning and Cost-Effective Inference for DeFi Attack Mitigation](https://mlsanity.com/paper/2510.16024/) (2025)

## Abstract (arXiv)

While a plethora of machine learning (ML) models are currently available, along with their implementation on disparate platforms, there is hardly any verifiable ML code which can be executed on public blockchains. We propose a novel approach named LMST that enables conversion of the inferencing path of an ML model as well as its weights trained off-chain into Solidity code using Large Language Models (LLMs). Extensive prompt engineering is done to achieve gas cost optimization beyond mere correctness of the produced code, while taking into consideration the capabilities and limitations of the Ethereum Virtual Machine. We have also developed a proof of concept decentralized application using the code so generated for verifying the accuracy claims of the underlying ML model. An extensive set of experiments demonstrate the feasibility of deploying ML models on blockchains through automated code translation using LLMs.
