A smart contract's formal spec, readable like high-level code, and provably tied to the raw EVM bytecode. That is the new evm-smith experiment. Here is the whole behavioural spec of a WETH contract that an auditor reads: (More and full write-up below)

Jun 24, 2026 · 4:53 PM UTC

16
12
136
13,634
2/ `deposit` credits the caller by `msg.value` and touches nobody else, `withdraw` debits exactly x, unknown selectors revert. Plain pre and post conditions. The 86 bytes of bytecode are separately proven to satisfy each line.
1
6
638
3/ The fun part: we spec what a compiler usually hides. Function selector dispatch and ABI argument decoding never show up in Solidity source, the compiler emits them. With no compiler in the loop, we wrote those bytes ourselves and can state and prove what they mean.
1
4
548
4/ The readable surface is a tiny eDSL: a predicate for "a call to f", an `ensures` for "running it guarantees", and accessors like `balance[sender]` and `old balance[sender]`. About 150 lines of definitions, no heavy metaprogramming. Easy to read or to change.
1
4
418
5/ Each function reads as a big-step over a selector under preconditions, basically a Hoare triple: {withdraw call, funded, no reentrancy} run {caller debited by exactly x} The instruction by instruction walk stays hidden inside the proof.
1
4
381
6/ Two one-line lemmas pin "the selector" and "the argument" to what the compiler actually emits: `shr(224, calldataload(0))` and `calldataload(4)`. So the spec's selector and argument are, by construction, the ABI's. Solvency reads the same way.
1
6
522
7/ `Spec.lean` is a proof-free interface; a separate witness proves the bytecode obeys every field. The readable file is what a human signs off on, and the proof makes it mean something. Full post: leonardoalt.github.io/human-… Reach out if you want to contribute!
12
518
Sort replies: Relevant Recent Liked
Replying to @leonardoalt
This is beautiful. Have you tried this approach with more complex contracts?
1
3
133
Replying to @leonardoalt
This looks really interesting, have wanted something like this to exist for a long time!
4
270
Replying to @leonardoalt
untouched(others) is simply beautiful syntax The gods smile upon you.
3
196
Replying to @leonardoalt
Sick
1
225
Replying to @leonardoalt
Damn this is very cool 🔥
2
198
Replying to @leonardoalt
Mmm a contract of invariants
2
195
Replying to @leonardoalt
No compiler trust
1
99
Replying to @leonardoalt
this is the bit i keep coming back to: readable spec only matters if the bytecode tie is real
2
Replying to @leonardoalt
honestly this is the part i like: the readable spec becomes a real security artifact, not just audit prose
3
Replying to @leonardoalt
interesting, making the spec readable is prob the only way the proof gets useful to auditors
2
Replying to @leonardoalt
This is great.😏
108
Replying to @leonardoalt
I’d love to see more. For ERC20 contracts, individual function invariants might work. But, many contracts require multi-transaction invariants expressed in temporal logic (LTL formulas).
64
Replying to @leonardoalt
Most exploits are violations of assumptions that were never written down.
114