Skip to main content

How Can a Developer Intentionally Disable the Overflow Checks in Solidity 0.8.0?

A developer can intentionally disable the automatic overflow and underflow checks in Solidity 0.8.0 and later by enclosing the arithmetic operation within an unchecked block. This is done to save gas in situations where the developer is absolutely certain that the operation cannot overflow or underflow, such as incrementing a loop counter that is guaranteed to stay within a small range.

It is a trade-off: reduced gas cost for manual security assurance.

How Does a SAFT (Simple Agreement for Future Tokens) Differ from a SAFE (Simple Agreement for Future Equity)?
How Does the Concept of a “Safe Harbor” Apply to Crypto Regulation?
What Is an Integer Overflow and How Does It Impact Token Balances?
Why Is SafeMath Less Necessary in Solidity 0.8.0 and Later?