When you call require() with an argument that equals false, require will throw an error, the rest of the code will not be executed and the transaction will revert.

If you call it with an argument that equals true, the code will just run as expected.

So what does require return? Say if you went if(require(false)) {}, what would happen?

2 Answers 2


The require function does not return anything. You can't use it as if(require(false)) {}, it will not compile.

If the condition passed to the require function is true, nothing happens, and the code keeps executing. If the condition returns false, then require throws an Error with no data, or optionally an Error(string), with the string message that you pass as the second argument to the require function:

require(false, "There was an error");

Check the docs: https://docs.soliditylang.org/en/v0.8.17/control-structures.html#panic-via-assert-and-error-via-require


An Error(string) exception (or an exception without data) is generated by the compiler if calling require(x) where x evaluates to false.

See: https://docs.soliditylang.org/en/v0.8.16/control-structures.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.