If so, why was the name require chosen instead of just assert like most modern programming languages?

Where does the name require originate from?

3 Answers 3


Solidity contains both.

require(false) is handled as a user-provided exception (like throw). assert(false) is handled as a run time exception (like out of gas, among others).

Internally, Solidity performs a revert operation (instruction 0xfd) when a user-provided exception is thrown or the condition of a require call is not met. In contrast, it performs an invalid operation (instruction 0xfe) if a runtime exception is encountered or the condition of an assert call is not met. In both cases, this causes the EVM to revert all changes made to the state. The reason for this is that there is no safe way to continue execution, because an expected effect did not occur. Because we want to retain the atomicity of transactions, the safest thing to do is to revert all changes and make the whole transaction (or at least call) without effect.


The difference between revert and invalid is described in this answer.

INVALID will throw the transaction, its state changes and cause the consumption of all gas sent with it.

As of Solidity 0.4.10 there is now a revert() call which enacts the REVERT opcode introduced in EIP140. This opcode, halts the contract, throws state changes but refunds unused gas.


It's basically a short form. The idea likely originates from "requiring things to be there", which checks for a boolean condition, but also can check things the assert way.


I'd never recommend to use require, hence it was caught working unpredictable. I used it to ensure two addresses are equal, and require failed even they were, whilst if ... throw worked fine for the same. I killed a day to find it. Thanks to unit tests on my contracts that revealed the problem before deployment.

  • 1
    throw was deprecated in 0.4.13
    – Joe
    Jul 27, 2017 at 14:11
  • No sense in deprecation where there is no working analogues left.
    – brawaga
    Jul 28, 2017 at 3:29
  • According to this answer they compile the same so I'm not sure what your problem was with require
    – Joe
    Jul 28, 2017 at 8:49
  • I saw that, but my case shows that it might not be they have the same byte code.
    – brawaga
    Jul 31, 2017 at 5:52
  • i use require a lot and I never experienced any problems with it.
    – user813
    Nov 3, 2017 at 5:31

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.