Lithe EVM Language Adds Built-In Formal Verification

Banner for the Lithe EVM language, a formally verifiable smart contract language built for AI agents

The Lithe EVM language started as an experiment: could AI agents design and build a smart contract language from scratch? Twelve days after the first prompt, a working version existed, and the output was already roughly 30% smaller than what an optimised solc build produced. The finished language builds formal verification into the toolchain and is already running on Ethereum mainnet.

The Lithe EVM language ships with its own compiler and standard library. It targets the Ethereum Virtual Machine, so contracts deploy like any other.

Why a new smart contract language

AI agents now write smart contracts, and they also attack them. Anthropic’s SCONE-bench pointed 10 models at 405 contracts with documented real-world exploits, and between them the models broke about half.

The bugs that cost the most are usually plain ones. Access-control flaws, such as a missing check on who is calling a function, made up roughly two thirds of the $1.42 billion in 2024 losses that OWASP reviewed. Solidity leaves much of this to convention, and language models forget conventions just as people do. Lithe turns many of those conventions into compiler rules and makes the remaining ones easy to audit.

A language has limits: most stolen value leaves through offchain channels such as leaked keys and compromised servers.

Lithe: A Formally Verifiable EVM Language Built for Agents
Image: Celestia Blog

How Lithe blocks reentrancy

In Solidity, a function that calls another contract hands over control. That contract can run any code before the first function finishes, including calling straight back in. This is the pattern behind the 2016 DAO hack.

Lithe treats each entrypoint as one atomic state change and postpones any state-changing external call until that change is done. A defer keyword holds an outgoing transfer until the new balance is saved, so a vault that writes the transfer before the balance update is still safe.

Access checks work on groups. An owner check applied to a group of actions covers any action added to it later. The compiler also rejects an external function that can fail without listing the error in a raises clause.

Lithe EVM language image 2
Image: Celestia Blog

Tools for auditors

A wrong check can still compile in Lithe, but the tooling makes it visible. Two commands do most of the work:

  • lithe abi-tree maps the route to every function along with the checks guarding it.
  • lithe footprint reports each function’s writes, deferred calls and raised errors.
Lithe EVM language image 3
Image: Celestia Blog

Formal verification on the deployed bytecode

A developer writes a spec describing what the contract should do. The lithe prove command then tests the contract against it across all inputs and all call orderings. Because it examines the bytecode that actually gets deployed, a compiler bug that breaks the spec would show up too. With the –code flag, it can also check contracts that are already live onchain.

Lithe EVM language benchmark results

Fifty-one benchmark contracts were compiled with Lithe, solc and Paradigm’s new Solidity compiler Solar. Lithe’s optimiser mixes original techniques with a few taken from Solar, and it led on every metric:

  • Bytecode shrank by about 40% against the best solc build and 7% against Solar’s size-optimised build.
  • Deploying OpenZeppelin’s ERC-20 used 34% less gas than solc, and the ERC-721 used 41% less.
  • Transactions used about 2.5% less gas than solc and roughly matched Solar.
  • Compiling the full set took roughly 0.6 seconds, versus 0.7 for Solar and 3.2 for solc at its fastest.

Built by agents, for agents

The agents worked inside Recur, a workflow tool its author also wrote. It assigns each task to a group of agents that plan, write and cross-review until it’s finished. The group wrote around 140,000 lines of Rust and 20,000 lines of Lithe, a language new to every one of them.

The language is designed for agents as users too. Compiler hints name the fix: forget to mark a deposit function payable and the message tells the agent to write external payable function. The lithe analysis command emits each function’s reads, writes and errors as JSON, so an agent can inspect a contract without parsing source. The documentation is available as plain text for models, and its code examples are tested against the compiler.

The main lesson was to give agents verification they can’t game. One agent claimed a compiler change left ABI output untouched, but most of the contracts it compared had failed to compile, so it was matching error messages. The benchmarks close that gap by replaying every transaction against the Solidity builds, where return data and logs match or they don’t.

What’s already running on mainnet

The Lithe EVM language is still experimental, but it’s live on Ethereum mainnet. Its author used it to rewrite Modularium’s NFT contracts in place of the Solidity originals. Several contracts that draw art onchain return byte-identical output to the originals while using 65% to 79% less gas for rendering. The contracts carry 40 spec files, all verified with lithe prove.

The author also works on payment rails that let agents buy data and services under code-enforced limits. Lithe tests whether agents can write those limits too, in a form people can verify. Developers who want to test it can try the playground, read the docs or browse the repository.

Source: Celestia Blog

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.