Skip to main content
Alias for Uint with U256-specific naming. The standard integer type in Ethereum.
import * as U256 from 'voltaire-effect/primitives/U256'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'

// Schema: from string, number, bigint, or hex
const value = Schema.decodeSync(U256.String)('1000000000000000000')
const fromHex = Schema.decodeSync(U256.FromHexSchema)('0xde0b6b3a7640000')

// Effect: validated construction
const program = U256.from('1000000000000000000')
// Effect.Effect<U256Type, U256Error>

const result = await Effect.runPromise(program)

Constructors

FunctionInput
fromstring, number, bigint
fromHexhex string
fromBytesUint8Array
fromNumbernumber
fromBigIntbigint

Errors

Fails on negative values or overflow (> 2²⁵⁶ - 1).
const bad = await Effect.runPromiseExit(U256.from(-1))
// Failure: U256Error