Solidity Bug Hunt Easy +10 XP
Integer Overflow (old)
In Solidity <0.8.0, what is the risk here?
SolidityFind the bug
1
uint8 max = 255;2
max += 1; The bug is on line 2
Select the correct fix
Show answer and explanation
Answer: Wraps to 0 (overflow) — use SafeMath or ^0.8.0
Before 0.8.0, Solidity didn't check for overflow. 255 + 1 wraps to 0. In 0.8.0+, this reverts automatically.
Hint: Solidity 0.8.0 added built-in overflow protection.
What this challenge tests
Bug Hunt in Solidity: overflow, safemath.