Skip to content

Exception Handling: Require, Assert and Revert in Solidity

In this Lab you will learn more about Exception handling. At the end of the Lab I want you to be fully aware of when and how to use require, assert and revert.

How these behave with transactions and also between Smart Contracts.

What You Know At The End Of The Lab

🔎 How to validate user input with require

🔪 How to validate invariants with assert

🕵️ Observe Transactions and understand the reason why they are failing

Prerequisites - You need:

  1. Chrome or Firefox browser.

  2. An Internet connection

  3. About 60 Minutes of your precious time ⌛

Get Started

💪 💪 💪 Let's get started!

Using Solidity 0.6

In this lecture we deliberately using an older version of Solidity to demonstrate integer rollover assertion. This won't be necessary anymore with Solidity 0.8, but it is still a very common scenario in many recent DeFi Startups who are not yet using Solidity 0.8.


Last update: April 10, 2022