Slither

Slither

Community Analyzer

Assert state change SLITHER-W1068

Anti-pattern
Minor

Incorrect use of assert(). See Solidity best practices.

Exploit Scenario

contract A {

  uint s_a;

  function bad() public {
    assert((s_a += 1) > 10);
  }
}

The assert in bad() increments the state variable s_a while checking for the condition.

Recommendation

Use require for invariants modifying the state.

Learn more

assert-state-change on Slither's wiki.