Search⌘ K
AI Features

Error Handling in Solidity

Explore how to manage errors effectively in Solidity smart contracts using require, assert, revert, and custom errors. Understand when and how to apply these techniques to prevent faulty transactions and maintain contract integrity.

Error handling in Solidity

Solidity provides us with a number of options to check for and handle errors and unwanted behaviors in our smart contract. These options include:

  • require

  • assert

  • revert

  • Custom errors

Basically, these four options do the same thing: terminate further execution of code if certain conditions are met (or unmet) and revert the contract to the state it was in before it was called. Let’s take a closer look at how and where to use each.

...