Skip to main content
Uint256 (Uint256Type) is a branded bigint constrained to [0,2256−1][0, 2^{256} - 1] — the native unsigned word type of the Ethereum Virtual Machine.

Quick Start

Import Uint256 (namespace) or Uint (callable constructor) from @tevm/voltaire or @tevm/voltaire/Uint.

Bounds & Constants

API Reference

Constructors & Validation

Conversions

Arithmetic, Bitwise & Number Theory

Edge Cases

  • Uint256.minus(0n, 1n) wraps to Uint256.MAX.
  • Uint256.plus(Uint256.MAX, 1n) wraps to 0n.
  • Uint256.plusChecked(Uint256.MAX, 1n) throws UintOverflowError; Uint256.minusChecked(0n, 1n) throws UintNegativeError.
  • Uint256.shiftLeft(x, 256n) and Uint256.shiftRight(x, 256n) yield 0n.
  • Uint256.fromAbiEncoded throws InvalidLengthError if input length is not 32.