SolBehave: Evaluating the Behavioural Correctness of LLM-Generated Smart Contracts
Organizations: University of Bologna, Bologna, Italy · University of Copenhagen, Copenhagen, Denmark
Abstract
Large language models increasingly generate Solidity smart contracts that, once deployed, can never be patched, making a single latent fault permanent and exploitable. Yet current evaluations mostly ask only whether generated code compiles. We introduce SolBehave, a benchmark for evaluating the correctness of model-generated contracts at scale, moving beyond ad hoc unit tests. Across 250 real, reproducible Ethereum contracts, we apply three complementary tests of behavioural fidelity: differential fuzzing, historical-transaction replay, and, as our core contribution, synthetic-transaction replay guided by a Dynamic Condition Response (DCR) graph that enumerates the space of legitimate function-call sequences. Differential fuzzing compares each generated function with the original on automatically generated inputs; historical replay compares the whole contract on the transactions it actually received on-chain; DCR-guided replay compares it on sequences of calls that follow its intended usage, including orderings that never occurred on-chain. We evaluate seven state-of-the-art open-weight models after one round of automated repair. Compilation success ranges from 26.4% to 92.7%, but under differential fuzzing only 31.4% of all generated function bodies that compile, pooled over models and samples, are equivalent to the original. Divergence at the contract level is the norm rather than the exception: for six of the seven models, between 13% and 31% of the generated contracts that compile diverge from the original under historical replay, and between 13% and 44% under DCR-guided replay; only Gemma-4-31B stays below 3% on both. Compilation is therefore a necessary condition for correctness and far from a sufficient one.
Figures & tables
| Compile@10 | |||
| Model | Raw | Repaired | Gain |
| Gemma-4-31B | 89.1% | 92.7% | |
| Qwen3.6-27B | 64.7% | 71.3% | |
| Qwen3-Coder-30B | 53.2% | 61.8% | |
| Gemma-4-12B | 48.0% | 57.9% | |
| Ornith-35B | 41.2% | 52.1% | |
| Relation | judgements | P | R | F1 | ||
| TP | FP | FN | ||||
| condition | 65 | 3 | 12 | 0.96 | 0.84 | 0.90 |
| response | 18 | 6 | 1 | 0.75 | 0.95 | 0.84 |
| inclusion | 21 | 23 | 0 | 0.48 | 1.00 | 0.65 |
| exclusion | 39 | 25 | 6 | 0.61 | 0.87 | 0.72 |
| all | 143 | 57 | 19 | 0.72 | 0.88 | 0.79 |
| Model | O2 | O3 | ||||||||
| matched | fixed | |||||||||
| Compile@10 | Status | Status | Status | |||||||
| Gemma-4-31B | 92.7% | 234 | 99.6% | 174 | 98.4% | 174 | 98.4% | |||
| Qwen3.6-27B | 71.3% | 214 | 96.9% | 157 | 96.7% | 162 | 95.8% | |||
| Qwen3-Coder-30B | 61.8% | 183 | 95.5% | 125 | 96.1% | 136 | 95.5% | |||
| Gemma-4-12B | 57.9% | 169 | 95.4% | 127 | 94.6% | 129 | 94.6% | |||
| Extractor | O3 coverage | Contracts O3 O2 | Functions covered by one oracle only | |
| O3 only | O2 only | |||
| Gemma-4-31B | 47.3% | 84 | 311 | 511 |
| Qwen3.6-27B | 46.1% | 81 | 305 | 520 |
| Gemma-4-12B | 44.6% | 72 | 292 | 537 |
| Devstral-24B | 44.2% | 77 | 301 | 535 |
| Ornith-35B | 41.6% | 68 | 276 | 566 |
| Model | O1: equivalent | |
| Functions | Contracts | |
| Gemma-4-31B | 33.4% | 34.0% |
| Qwen3.6-27B | 35.5% | 34.4% |
| Qwen3-Coder-30B | 26.6% | 29.9% |
| Gemma-4-12B | 18.8% | 13.1% |
| Ornith-35B | 16.9% | 15.6% |
| Model | one oracle only | two oracles | all | |||||
| O1 | O2 | O3 | O1,O2 | O1,O3 | O2,O3 | |||
| Gemma-4-31B | 170 | 93 | 0 | 0 | 0 | 3 | 0 | 2 |
| Qwen3.6-27B | 158 | 70 | 0 | 0 | 5 | 8 | 0 | 15 |
| Qwen3-Coder-30B | 133 | 50 | 0 | 0 | 15 | 7 | 0 | 14 |
| Gemma-4-12B | 126 | 87 | 0 | 0 | 10 | 5 | 0 | 11 |
| Ornith-35B | 143 | 99 | 0 | 0 | 7 | 6 | 0 | 21 |
| Functions per contract | Compile@10 | s/sample | |
| Mean | Range | ||
| 1–5 | 54.2–88.9% | ||
| 6–10 | 35.0–69.4% | ||
| 11–15 | 24.2–64.2% | ||
| 16–20 | 16.7–70.6% | ||
| 21–25 | 3.9–46.4% | ||
Code Generation Evaluation
Code generation evaluation measures whether AI-produced programs are correct, reliable, secure, efficient, and faithful to their specifications.
See all 214 papers