[Paper Review] Deductive Proof of Ethereum Smart Contracts Using Why3
This paper presents a formal verification framework for industrial Ethereum smart contracts using Why3, a deductive verification tool. It encodes Solidity contracts into WhyML, specifies safety properties (e.g., absence of runtime errors and correct token transfers), verifies them using automated theorem provers, and compiles the verified contracts to EVM bytecode while estimating gas consumption. The key contribution is demonstrating Why3's feasibility for verifying complex, real-world smart contracts with formal guarantees.
A bug or error is a common problem that any software or computer program may encounter. It can occur from badly writing the program, a typing error or bad memory management. However, errors can become a significant issue if the unsafe program is used for critical systems. Therefore, formal methods for these kinds of systems are greatly required. In this paper, we use a formal language that performs deductive verification on an Ethereum Blockchain application based on smart contracts, which are self-executing digital contracts. Blockchain systems manipulate cryptocurrency and transaction information. Therefore , if a bug occurs in the blockchain, serious consequences such as a loss of money can happen. Thus, the aim of this paper is to propose a language dedicated to deductive verification, called Why3, as a new language for writing formal and verified smart contracts, thereby avoiding attacks exploiting such contract execution vulnerabilities. We first write a Why3 smart contracts program; next we formulate specifications to be proved as absence of RunTime Error properties and functional properties, then we verify the behavior of the program using the Why3 system. Finally we compile the Why3 contracts to the Ethereum Virtual Machine (EVM). Moreover, we give a set of generic mathematical statements that allows verifying functional properties suited to any type of smart contracts holding cryptocurrency, showing that Why3 can be a suitable language to write smart contracts. To illustrate our approach, we describe its application to a realistic industrial use case.
Motivation & Objective
- To address the critical security risks in industrial smart contracts, such as financial loss from bugs, by applying formal verification.
- To evaluate whether Why3, a deductive verification platform, can be effectively used to specify, verify, and compile complex smart contracts.
- To extend formal verification beyond simple contracts to include functional properties involving multiple data types (e.g., tokens, addresses, balances) and complex logic.
- To provide a gas estimation mechanism within the formal verification pipeline, linking correctness with execution cost.
Proposed method
- Encoding existing Solidity-based smart contracts from the Blockchain Energy Market Place (BEMP) application into WhyML, a high-level formal language within Why3.
- Specifying functional properties such as correct balance transfers, valid transaction conditions, and absence of runtime errors using preconditions, postconditions, and invariants.
- Using Why3’s integrated theorem provers (e.g., Alt-ergo, Z3, CVC4) to automatically discharge proof obligations for correctness and safety.
- Instrumenting functions with gas cost annotations using the `@evm:gas_checking` annotation to estimate computational cost during verification.
- Compiling verified Why3 contracts into EVM-compatible bytecode using Why3’s code generation pipeline.
- Integrating a custom gas cost model that tracks gas usage per operation and aggregates it across function calls.
Experimental results
Research questions
- RQ1Can Why3 be effectively used to formally verify industrial-scale Ethereum smart contracts with complex logic and multiple data types?
- RQ2How accurately can gas consumption be estimated within a deductive verification framework for smart contracts?
- RQ3Can formal verification using Why3 prevent runtime errors and ensure functional correctness in real-world applications like BEMP?
- RQ4What is the overhead and expressiveness of specifying complex properties (e.g., order matching, balance transfers) in WhyML compared to Solidity?
- RQ5To what extent can the Why3 pipeline support end-to-end verification, from specification to EVM compilation?
Key findings
- The Why3 framework successfully verified a complex trading contract from the BEMP application, including correct handling of balances, token transfers, and order matching.
- The formal specification successfully proved the absence of runtime errors such as array out-of-bounds access and division by zero.
- The system correctly verified functional properties, including correct ether and green token transfers between market participants.
- Gas consumption was accurately estimated using annotated cost models, with per-operation gas costs (e.g., 128 for list traversal, 185 for allocation) integrated into the verification process.
- The verified contracts were successfully compiled into EVM bytecode, demonstrating end-to-end trustworthiness from specification to deployment.
- The approach proved scalable to a multi-user, multi-participant energy trading system, showing applicability beyond simple contracts.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.