10.SWC-110_assert
2023-07-13 16:11:12
# 09.SWC
SWC-110_assert
Assert Violation
Description: The Solidity
assert()
function is meant to assert invariants. Properly functioning code should never reach a failing assert statement. A reachable assertion can mean one of two things:- A bug exists in the contract that allows it to enter an invalid state;
- The
assert
statement is used incorrectly, e.g. to validate inputs.
Remediation: Consider whether the condition checked in the
assert()
is actually an invariant. If not, replace theassert()
statement with arequire()
statement.If the exception is indeed caused by unexpected behaviour of the code, fix the underlying bug(s) that allow the assertion to be violated.