Rules › Solidity
unchecked { } arithmetic
Overflow checks are off inside unchecked; make sure every operation there is provably bounded.
Why it matters
Inside unchecked { }, Solidity 0.8's overflow checks are off. That's fine for provably bounded math (a loop counter that can't reach type(uint256).max) and saves gas, but anything derived from user input, balances or prices must stay checked. This rule flags every block so you can confirm each one.
Vulnerable
unchecked {
balances[to] += amount; // user-controlled: may wrap
}
Fixed
for (uint256 i; i < items.length; ) {
// ...
unchecked { ++i; } // bounded by items.length
}
What other tools call it
| Tool | Detector or reference |
|---|---|
| SWC registry | SWC-101 |
Check your code
Paste a contract into the in-browser checker, or let the Claude Code plugin scan before every deploy. The quick check for this rule is a pattern match: treat a hit as "look here", and a miss as no guarantee.
Related rules
- tx.origin used for authorization
- State written after an external call (reentrancy)
- Return value of a low-level call is ignored
- delegatecall to an address the caller controls
- Initializer anyone can call
- Privileged function without access control
Static analysis finds known bug classes; it can't prove code is safe and isn't an audit. Get a professional audit before deploying code that will hold value.