Ever wondered how to verify smart contracts written in Solidy? Thanks to our deep embedding of Solidty into Isabelle/HOL, you can now start verifying smart contracts in Isabelle.

Our formalization is available in the Archive of Formal Proofs [1], which can be easily added to Isabelle/HOL. If you want to read a more high-level description of the underlying work, read our conference papers on the topic [3].

[1]

D. Marmsoler and A. D. Brucker, “Isabelle/solidity: A deep embedding of solidity in isabelle/HOL,” *Archive of Formal Proofs*, Jul. 2022,

[2]

D. Marmsoler and A. D. Brucker, “A denotational semantics of Solidity in Isabelle/HOL,” in *Software engineering and formal methods (SEFM)*, R. Calinescu and C. Pasareanu, Eds. Heidelberg: Springer-Verlag, 2021.

[3]

D. Marmsoler and A. D. Brucker, “Conformance testing of formal semantics using grammar-based fuzzing,” in *TAP 2022: Tests and proofs*, L. Kovacs and K. Meinke, Eds. Heidelberg: Springer-Verlag, 2022.

In our work “A Denotational Semantics of Solidity in Isabelle/HOL” [1] we presented a formal semantics for Solidity, the most common language for implementing smart contracts. Such a formal semantics one of the corner stones of developing a formal verification approach that, mathematically, can prove the absence of certain types of bugs (e.g., such as the Parity Wallet bug that made USD 280mil worth of Ether inaccessible).

But, of course, any verification can only be as good as the underlying semantics. So, how do we ensure that our formal semantics actually captures the behavior of Solidity faithfully? This is the question we answer in our latest paper [2] that will be presented at the International Conference on Tests and Proofs.

In our approach, we use grammar-based fuzzing, a technique that generates example programs from a formal grammar. Our goal is to ensure that our post-hoc developed formal semantics of Solidity complies to the real world system, i.e., our formalization should behave identical to the implementation. For ensuring this, we generate a test oracle from our formal specification, which allows us to check that executing a test case (generated by the grammar-based fuzzer) executed on the formal semantics yields the same result as executed on the Ethereum blockchain. Our main contributions are:

- An approach extending a parse grammar for Solidity to ensure that a generic grammar-based fuzzer generates type correct Solidity programs, instead of generating syntactically correct, but often ill-typed, programs.
- An approach for automatically deriving a test-oracle from a formal specification in Isabelle/HOL that allows to efficiently decide if a test case passes or fails and that allows to measure the test coverage in terms of statements and expressions of the target language usually based on an implicit test specification that informally can be described as “no crashes occur”.
- A framework for testing the compliance of a formal semantics of Solidity in Isabelle/HOL to their execution on the Ethereum blockchain

**Update:** The formalization is now also available in the Archive of Formal Proofs [3].

[1]

D. Marmsoler and A. D. Brucker, “A denotational semantics of Solidity in Isabelle/HOL,” in *Software engineering and formal methods (SEFM)*, R. Calinescu and C. Pasareanu, Eds. Heidelberg: Springer-Verlag, 2021.

[2]

D. Marmsoler and A. D. Brucker, “Conformance testing of formal semantics using grammar-based fuzzing,” in *TAP 2022: Tests and proofs*, L. Kovacs and K. Meinke, Eds. Heidelberg: Springer-Verlag, 2022.

[3]

D. Marmsoler and A. D. Brucker, “Isabelle/solidity: A deep embedding of solidity in isabelle/HOL,” *Archive of Formal Proofs*, Jul. 2022,

Smart contracts are programs, usually automating legal agreements such as financial transactions. Thus, bugs in smart contracts can lead to large financial losses. For example, an incorrectly initialized contract was the root cause of the Parity Wallet bug that made USD 280mil worth of Ether inaccessible. Ether is the cryptocurrency of the Ethereum blockchain that uses Solidity for expressing smart contracts.

In our SEFM paper [1], we address this problem by presenting an executable denotational semantics for Solidity in the interactive theorem prover Isabelle/HOL. This formal semantics builds the foundation of an interactive program verification environment for Solidity programs and allows for inspecting Solidity programs by (symbolic) execution. We combine the latter with grammar-based fuzzing to ensure that our formal semantics complies to the Solidity implementation on the Ethereum Blockchain. Finally, we demonstrate the formal verification of Solidity programs by two examples: constant folding and memory optimization.

The formalization and presented tools are available on Zenodo
**marmsoler.ea:zenodo-isolidity:2021?**.

[1]

D. Marmsoler and A. D. Brucker, “A denotational semantics of Solidity in Isabelle/HOL,” in *Software engineering and formal methods (SEFM)*, R. Calinescu and C. Pasareanu, Eds. Heidelberg: Springer-Verlag, 2021.