Skip to main content

Try it Live

Run Uint examples in the interactive playground
import { UintSchema } from '@tevm/voltaire/Uint/effect'

const u = UintSchema.from(255n)
u.toHex(false) // '0xff'

Output Format

Hex strings are minimal - no unnecessary leading zeros:
Uint.toHex(Uint(0n))      // "0x0"
Uint.toHex(Uint(1n))      // "0x1"
Uint.toHex(Uint(15n))     // "0xf"
Uint.toHex(Uint(16n))     // "0x10"
Uint.toHex(Uint(255n))    // "0xff"
Uint.toHex(Uint(256n))    // "0x100"

Always Lowercase

Uint.toHex(Uint(0xdeadbeefn))  // "0xdeadbeef"

Always Has 0x Prefix

// Never returns without prefix
Uint.toHex(Uint(255n))  // "0xff" (not "ff")

Usage Patterns

Logging and Debugging

const value = Uint(12345n)
console.log(`Value: ${Uint.toHex(value)}`)  // "Value: 0x3039"

Ethereum RPC

// Format for JSON-RPC
const balance = Uint(1000000000000000000n)
const rpcValue = Uint.toHex(balance)  // "0xde0b6b3a7640000"

await eth_sendTransaction({
  value: rpcValue
})

Storage Keys

const slot = Uint(5n)
const key = Uint.toHex(slot)  // "0x5"

See Also