Uint32
A branded type for 32-bit unsigned integers (0 to 4,294,967,295). Represented as JavaScriptnumber with compile-time type safety.
Overview
Uint32Type provides:
- Compile-time type branding
- Range validation (0 to 2^32-1)
- Full arithmetic and bitwise operations
- Efficient
numberrepresentation (fits in JavaScript safe integer range)
Type Definition
Range
- Minimum: 0
- Maximum: 4,294,967,295 (2^32 - 1)
- Size: 32 bits (4 bytes)
Constants
Construction
from
Create from number, bigint, or string:fromNumber
fromBigInt
fromHex
fromBytes
Create from Uint8Array (big-endian, up to 4 bytes):fromAbiEncoded
Create from 32-byte ABI-encoded data:tryFrom
Safe construction that returns undefined on invalid input:Conversion
toNumber
toBigInt
toHex
toBytes
toAbiEncoded
toString
Arithmetic
plus
minus
times
dividedBy
modulo
toPower
Comparison
equals
lessThan / greaterThan
isZero
minimum / maximum
Bitwise Operations
bitwiseAnd / bitwiseOr / bitwiseXor
bitwiseNot
shiftLeft / shiftRight
Bit Analysis
bitLength
leadingZeros
popCount
Validation
isValid
Use Cases
- Block numbers: Ethereum block numbers fit in 32 bits until ~year 2100
- Gas limits: Transaction and block gas limits
- Timestamps: Unix timestamps (valid until year 2106)
- Nonces: Transaction nonces
- Indices: Array indices, loop counters
- IP addresses: IPv4 addresses

