Solidity-Code-LLM is a fine tuned large language model designed to understand, generate, and analyze smart contracts written in Solidity. Developed by ChainGPT—a leader in AI infrastructure for the Web3 and blockchain space—this model is purpose-built for the decentralized development ecosystem.
Developed by: ChainGPT
License: MIT License
Finetuned from model: Salesforce/codegen-2B-multi
ChainGPT Logo
Model Details
Model Description
Solidity-Code-LLM is a specialized language model trained in two stages: pre-training on a large, unstructured Solidity dataset, followed by instruction-based fine-tuning on a cleaned, curated dataset. Unlike general-purpose code models, it is exclusively focused on Solidity—the dominant language for Ethereum-compatible blockchains—making it an efficient and accurate assistant for writing and debugging smart contracts across a wide range of use cases, including tokens, DApps, DAOs, and governance protocols.
Model Features
Type: Code Gen For Causal LLM
Tokenizer: GPT2Tokenizer
Number of Parameters: 2B
Number of Layers: 32 Transformer blocks
Context Length: Full 2048 tokens
Dtype: bfloat16
Model Sources
Model is deployed on huggingface space for inference
Good OpenZeppelin Compliance (~65%), indicating frequent use of standard libraries and contract patterns. While GPT-4.5, being a much larger model, naturally exhibits stronger adherence to OpenZeppelin standards due to its broader training data, Solidity LLM achieves commendable compliance given its smaller size.
Top Gas Efficiency (~72%), producing optimized code as evaluated by tools like Slither.
Moderate Security Score (~58%), showing acceptable security posture but room for improvement. GPT-4.5 benefits from its scale in handling more security cases.
Concise Code (~70% LOC score), generating relatively compact and efficient smart contracts.
Uses
Direct Use
Assisting developers in writing Solidity smart contracts.
Educational tool for learning Solidity.
Auto-generating documentation or contract templates.
Downstream Use
Integrated into IDEs or smart contract development platforms.
Supporting autonomous agents that interact with blockchains.
Out-of-Scope Use
Not suitable for general-purpose code generation in languages other than Solidity.
Not intended for legal auditing or formal verification without human oversight.
Should not be used to deploy contracts to production without expert review.
Bias, Risks, and Limitations
May reflect biases from web-scraped content (e.g., outdated or insecure coding practices).
Model might hallucinate code or provide syntactically valid but logically incorrect suggestions.
Risks associated with using AI-generated code in high-stakes or financial environments without thorough vetting.
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Manual code review and testing are strongly recommended before deployment.
How to Get Started with the Model
The model follows a two-step generation process: it first produces a natural language description of the code, and subsequently generates the corresponding source code based on the given prompt. The complete output is generated internally before being displayed to the user. For scenarios requiring direct code generation without intermediate descriptions, a streaming mode can be utilized to produce code in real time.
To evaluate the performance of our fine-tuned LLM specialized in Solidity smart contract generation, we used Slither, a static analysis framework widely used for analyzing Solidity code.
We focused on following key evaluation criteria:
Compilation Success Rate
We measured the percentage of generated smart contracts that compile successfully without modification. This helps assess the syntactic and structural correctness of the model outputs.
OpenZeppelin Standards Compliance
We verified whether the generated contracts adhere to best practices by checking for proper usage of OpenZeppelin libraries. This includes ensuring the latest or stable versions of libraries are used and the overall contract structure aligns with established OpenZeppelin patterns.
Gas Optimization Opportunities
Using Slither’s gas optimization analysis, we identified areas in the generated contracts where gas usage could be reduced. We measured the number and types of optimization suggestions as an indicator of how efficient the generated code is.
Security Vulnerabilities
We analyzed each contract for known security vulnerabilities using Slither’s built-in detectors. We recorded the number and severity of the vulnerabilities detected, providing a measure of the security quality of the model’s outputs.
Average Lines of Code (LOC)
Captures the average number of lines per generated contract, excluding blank lines but including comments. This metric reflects code verbosity or conciseness, and helps gauge implementation completeness versus potential redundancy.
These metrics collectively provide a multi-dimensional view of the model’s effectiveness, spanning correctness, efficiency, security, and usability. They are designed to reflect both automated benchmarks and real-world developer expectations.
Summary
Solidity LLM, despite its compact 2B parameter size, delivers standout performance in generating Solidity smart contracts. It achieved the highest compilation success rate (83%), showcasing robust syntactic and structural understanding. Its strong OpenZeppelin compliance (65%), though slightly behind very large models like GPT-4.5, is impressive given the scale difference, reflecting reliable use of industry-standard patterns and libraries.
Further, Solidity LLM ranked highest in gas efficiency (72%), producing optimized code suitable for cost-sensitive deployments. While the security score (58%) indicates room for improvement, the model consistently generated secure-enough contracts for practical use. Its concise output (70% LOC score) also suggests an efficient coding style, balancing brevity with completeness.
Overall, Solidity LLM proves to be a resource-efficient, reliable, and well-balanced model for Solidity code generation.
Looking ahead, future releases will focus on improving support for newer versions of the Solidity language and OpenZeppelin libraries, enhancing user interaction by enabling contract modifications, expanding compatibility to other languages like Rust, and developing larger models capable of handling longer context windows.