Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 905 Bytes

File metadata and controls

18 lines (17 loc) · 905 Bytes

require() should be used for checking error conditions on inputs and return values while assert() should be used for invariant checking. Between solc 0.4.10 and 0.8.0, require() used REVERT (0xfd) opcode which refunded remaining gas on failure while assert() used INVALID (0xfe) opcode which consumed all the supplied gas. (see here)


Slide Screenshot

052.jpg


Slide Text

  • assert() vs require() -> Different Usages
  • assert() -> Invariants
  • No Failures Expected
  • require() -> Validation Failures Expected
  • Use Appropriately

References


Tags