ML2SC: Deploying Machine Learning Models as Smart Contracts on the Blockchain
Zhikai Li, Steve Vott, Bhaskar Krishnamachar

TL;DR
This paper introduces ML2SC, a tool that automatically translates PyTorch ML models into Solidity smart contracts, enabling on-chain deployment and inference with transparent, tamper-proof execution on blockchain.
Contribution
ML2SC is the first automated translator from PyTorch models to Solidity, facilitating secure on-chain ML inference with accurate cost modeling and maintained classification accuracy.
Findings
Gas costs increase linearly with model size and complexity.
On-chain inference accuracy matches off-chain PyTorch results.
ML2SC successfully deploys and updates models on blockchain.
Abstract
With the growing concern of AI safety, there is a need to trust the computations done by machine learning (ML) models. Blockchain technology, known for recording data and running computations transparently and in a tamper-proof manner, can offer this trust. One significant challenge in deploying ML Classifiers on-chain is that while ML models are typically written in Python using an ML library such as Pytorch, smart contracts deployed on EVM-compatible blockchains are written in Solidity. We introduce Machine Learning to Smart Contract (ML2SC), a PyTorch to Solidity translator that can automatically translate multi-layer perceptron (MLP) models written in Pytorch to Solidity smart contract versions. ML2SC uses a fixed-point math library to approximate floating-point computation. After deploying the generated smart contract, we can train our models off-chain using PyTorch and then…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsBlockchain Technology Applications and Security
MethodsLib
