The Pattern
View Code
View Code
Overflow Checks
Addition Overflow
a + b won’t exceed the maximum value.
Example: Adding balances, increasing supply
Subtraction Underflow
a >= b to prevent negative results.
Example: Deducting balances, burning tokens
Multiplication Overflow
Type Bounds
DifferentUint sizes have different maximum values:
Uint<8>max: 255Uint<16>max: 65,535Uint<32>max: 4,294,967,295Uint<64>max: 18,446,744,073,709,551,615Uint<128>max: 340,282,366,920,938,463,463,374,607,431,768,211,455