Skip to main content

Try it Live

Run Uint examples in the interactive playground

Input Types

Uint.from accepts multiple input types for flexibility:

BigInt (JavaScript)

BigInt values must be in range [0, 2^256 - 1]. Negative values and values exceeding maximum will throw.

Number (JavaScript)

Numbers must be safe integers. Use bigint for values > Number.MAX_SAFE_INTEGER (2^53 - 1).

String - Decimal

String - Hexadecimal

Hex strings with or without 0x prefix:

Validation

All inputs validated before construction: Range checks:
Format checks:
Type checks:

Usage Patterns

Constructor Selection

Safe Parsing

Type Conversion

Performance

Zero-copy for direct Uint8Array construction (fromBytes, fromAbiEncoded). Conversion required for strings (parses and allocates new Uint8Array). For performance-critical code, prefer passing bigint directly or using fromBytes.

See Also