Skip to main content

Try it Live

Run Uint examples in the interactive playground

Hex String Format

Hex strings represent unsigned integers in hexadecimal (base 16).

Valid Formats

Prefix Handling

The 0x prefix is optional:
Always use 0x prefix to make hex strings unambiguous, especially when debugging.

Case Insensitivity

Length and Range

Maximum Length

Hex strings for Uint256 can have up to 64 hex digits (not including 0x prefix):

Minimum Length

No minimum - leading zeros are implicit:

Common Values

Powers of 2

Common Ethereum Values

Error Handling

Invalid Characters

Overflow

Empty String

Usage Patterns

Parsing Ethereum Data

Converting from Other Primitives

Safe Parsing

Performance

Hex parsing requires:
  1. Character validation (each char must be 0-9, a-f, A-F)
  2. Conversion to bytes
  3. BigInt construction
For performance-critical code, prefer:
  • fromBytes if you already have Uint8Array
  • from(bigint) if you already have BigInt

See Also