What is formal verification in smart contracts?
Formal verification is proving, with mathematical tools, that a contract satisfies a written specification for every possible input and state. A test shows the code works for the cases it tried, while a proof shows that no case breaks the property, as long as the specification says what you meant (ethereum.org).
How does formal verification differ from testing?
| Approach | Covers | Result |
|---|---|---|
| Unit tests | The inputs you chose | Passes for those cases |
| Fuzzing | Many generated inputs | No failure found in the runs made |
| Formal verification | Every input and reachable state | Proved, a counterexample, or no answer in time |
ethereum.org groups the tools into specification languages, program verifiers such as the Certora Prover, the Solidity SMTChecker and KEVM, and theorem provers (ethereum.org). Trail of Bits lists Halmos, Certora and KEVM as formal verification tools for checking invariants (Trail of Bits).
What does a property look like?
The simplest specification is an assert. With the CHC engine turned on (--model-checker-engine=chc), the SMTChecker built into the compiler tries to prove every assertion for all inputs, treating require conditions as assumptions (Solidity docs).
A cap written as an assertion the SMTChecker can try to prove (illustrative, not audited code) CappedVault.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
contract CappedVault {
uint256 public constant CAP = 1_000_000 ether;
uint256 public totalDeposits;
function deposit(uint256 amount) external {
require(totalDeposits + amount <= CAP, "over cap");
totalDeposits += amount;
assert(totalDeposits <= CAP); // must hold for every amount and every earlier state
}
}
Where does formal verification fall short?
A proof is only as good as its specification: a property nobody wrote is never checked, and ethereum.org stresses that the specification must describe the behavior you expect and that writing one takes skill and time. The Solidity docs also warn that a reported bug can be a false positive caused by abstractions in the checker, and that the solver can time out without an answer (Solidity docs). A practical split is to prove the few properties whose failure would lose funds and to test the rest.
FAQ
Is formal verification the same as symbolic execution?
They overlap without being the same thing. Symbolic execution is one technique some verifiers use, exploring paths with symbolic inputs, while formal verification is the goal of proving a property for all inputs, which can also rely on model checking or theorem proving.
Sources
- Formal verification of smart contracts, ethereum.org checked 3 December 2026
- The call for invariant-driven development, Trail of Bits checked 3 December 2026
- SMTChecker and formal verification, Solidity documentation checked 3 December 2026