Skip to content

Lesson 4 · 3 min · Advanced

Spot the bug: integer overflow

On this page

Spot the bug — integer overflow (pre-Solidity 0.8)

Before Solidity 0.8, integer arithmetic silently wrapped on overflow — so a token balance could wrap from a huge number to 0 (or vice versa). Solidity 0.8+ has built-in overflow checks, but legacy code and unchecked blocks still appear.

Below zero wraps to the top

02256 − 1balance 5− 6unchecked { }: wraps to 2256 − 1,a 78-digit numberSolidity 0.8+: reverts
A uint can’t go below zero, so unchecked arithmetic wraps around to the largest value instead. Since Solidity 0.8, arithmetic reverts on overflow unless it sits in an unchecked block.

Vulnerable transfer

Click the line you think is the bug
Vulnerable transfer
Educational only, not financial or legal advice.