0/5
--- #### Implementing the `hellFunc` in Certora We're now moving beyond the basics to writing a rule in Certora that makes sense. The first variant to consider is ensuring that the `hellFunc` must never revert. To address this, we must determine how to run our `hellFunc` within Certora. Specifically, how do we communicate to Certora to symbolically execute the `hellFunc` amidst its mathematical processes? #### Adding a Methods Block One approach is to add a methods block. This is not strictly necessary since Certora is capable of discerning available functions on its own. However, to clarify our intentions, we'll explicitly define a methods block. This block will look similar to a Solidity interface but includes the unique `envfree` keyword. ```js function hellFunc(uint128) external returns uint256 envfree; ``` ### Understanding the `envfree` Keyword According to Certora's documentation, the methods block can contain two types of method or function declarations: nonsumary and summary. For our purposes, we will ignore summary declarations and focus on nonsumary declarations, which mirror interface definitions in Solidity closely. The key distinction in our declaration is the `envfree` tag following the returns clause. This tag has two significant implications: 1. **Simplifying Calls**: When using the Certora verification language, there's no need to explicitly pass an environmental value as the first argument during method calls. 2. **Independence from Environment Variables**: The prover ensures that the method’s implementation in the contract being verified does not depend on any environmental variables. This means aspects like message value, message sender, and the broader environment where the function is called are irrelevant.
A technical guide to writing methods in the Certora prover using the “methods” block. This lesson covers the basics of the “methods” block and explains how to specify different methods and their returns. It also discusses the concepts of “envfree” tags and how they affect the proving process.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Solidity Developer
Assembly and Formal VerificationDuration: 30min
Duration: 4h 38min
Duration: 3h 57min
Duration: 1h 56min
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar