Solidity LLM
Updated May 29, 2026, 12:30 PM
Solidity LLM
Solidity LLM
An open-source 2-billion-parameter language model fine-tuned specifically for Solidity smart contract generation. Hosted on HuggingFace, MIT-licensed, and completely free to run on your own hardware.
Key Facts
| Model | Chain-GPT/Solidity-LLM |
| Parameters | 2B |
| License | MIT |
| Cost | Free (self-hosted) |
| Platform | HuggingFace |
| Compilation Success Rate | 83% |
When to Use This vs. the Smart Contract Generator
| Solidity LLM | Smart Contract Generator | |
|---|---|---|
| Cost | Free | 1 credit per request |
| Hosting | Self-hosted (you need a GPU) | Cloud API |
| Model size | 2B parameters | Larger, more capable model |
| Quality | Good (83% compilation rate) | Higher quality, production-tuned |
| Offline | Yes | No |
| Best for | Experimentation, CI pipelines, air-gapped environments | Production contracts, complex logic |
Use the Solidity LLM when you need offline generation, want zero API costs, or are integrating into CI/CD pipelines. Use the Smart Contract Generator when you need higher-quality output for production contracts.
Quick Start -- Python
Install Dependencies
pip install transformers torch
Generate a Smart Contract
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "Chain-GPT/Solidity-LLM"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
prompt = "Create a Solidity smart contract for an ERC-20 token with a 2% burn mechanism"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=1024,
temperature=0.7,
do_sample=True,
)
generated_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_code)
With GPU Acceleration
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "Chain-GPT/Solidity-LLM"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto",
)
prompt = "Write a Solidity contract for a multi-signature wallet requiring 3 of 5 approvals"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=1024,
temperature=0.7,
do_sample=True,
)
generated_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_code)
Tips
- The 83% compilation success rate means roughly 1 in 5 outputs may need manual correction. Always compile and test the output.
- Pair the generated output with the Smart Contract Auditor to catch vulnerabilities before deployment.
- Use
float16anddevice_map="auto"for efficient GPU memory usage. - The model works well for standard patterns (ERC-20, ERC-721, staking, vesting) but may struggle with highly novel or complex contract logic.
- For production-critical contracts, consider using the cloud-based Smart Contract Generator instead.