Skip to main content
Voltaire models unsigned fixed-width integers as branded bigint values (Uint8, Uint16, Uint32, Uint64, Uint128, and Uint / Uint256). Every constructor validates range bounds on creation (0 to 2^N - 1), and arithmetic matches EVM modular semantics modulo 2N2^N.

Width Family

Quick Start

Import from @tevm/voltaire or @tevm/voltaire/Uint.

Uint vs Uint256 Exports

  • Uint is a callable constructor (Uint(value)) with static methods (Uint.plus, Uint.toHex, etc.) and constants (MAX, MIN, ZERO, ONE, SIZE).
  • Uint256 is the full 256-bit namespace from @tevm/voltaire/Uint (Uint256.from, Uint256.plus, plus variadic sum, product, min, max, gcd, lcm, isPowerOf2, clone).
  • All arithmetic, bitwise, comparison, and conversion functions share the same Uint256Type branded bigint.

API Summary (Uint / Uint256)

Wrapping & Division Semantics

  • plus, minus, times, and toPower wrap modulo 22562^{256} to match EVM opcodes (ADD, SUB, MUL, EXP).
  • dividedBy and modulo throw on division by zero.
  • from* throws IntegerUnderflowError on negative values and IntegerOverflowError on values > MAX; tryFrom returns undefined instead of throwing.