@tevm/voltaire / primitives/Uint
primitives/Uint
Interfaces
UintConstructor()
Defined in: src/primitives/Uint/UintConstructor.ts:69UintConstructor(Defined in: src/primitives/Uint/UintConstructor.ts:70value):Type
Parameters
value
string | number | bigint
Returns
Type
Properties
bitLength()
bitLength: (Defined in: src/primitives/Uint/UintConstructor.ts:112 Get number of bits required to represent valueuint) =>number
Parameters
uint
Type
Value to check
Returns
number
Number of bits (0-256)
Example
bitwiseAnd()
bitwiseAnd: (Defined in: src/primitives/Uint/UintConstructor.ts:97 Bitwise ANDuint,b) =>Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
uint & b
Example
bitwiseNot()
bitwiseNot: (Defined in: src/primitives/Uint/UintConstructor.ts:100 Bitwise NOTuint) =>Type
Parameters
uint
Type
Operand
Returns
Type
~uint & MAX
Example
bitwiseOr()
bitwiseOr: (Defined in: src/primitives/Uint/UintConstructor.ts:98 Bitwise ORuint,b) =>Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
uint | b
Example
bitwiseXor()
bitwiseXor: (Defined in: src/primitives/Uint/UintConstructor.ts:99 Bitwise XORuint,b) =>Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
uint ^ b
Example
dividedBy()
dividedBy: (Defined in: src/primitives/Uint/UintConstructor.ts:94 Divide Uint256 valueuint,b) =>Type
Parameters
uint
Type
Dividend
b
Type
Divisor
Returns
Type
Quotient (uint / b), floor division
Throws
Error if divisor is zeroExample
equals()
equals: (Defined in: src/primitives/Uint/UintConstructor.ts:103 Check equalityuint,b) =>boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint === b
Example
greaterThan()
greaterThan: (Defined in: src/primitives/Uint/UintConstructor.ts:107 Check greater thanuint,b) =>boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint > b
Example
greaterThanOrEqual()
greaterThanOrEqual: (Defined in: src/primitives/Uint/UintConstructor.ts:108 Check greater than or equaluint,b) =>boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint >= b
Example
isValid()
isValid: (Defined in: src/primitives/Uint/UintConstructor.ts:84 Check if value is a valid Uint256value) =>value is Type
Parameters
value
unknown
Value to check
Returns
value is Type
true if value is valid Uint256
Example
isZero()
isZero: (Defined in: src/primitives/Uint/UintConstructor.ts:109 Check if value is zerouint) =>boolean
Parameters
uint
Type
Value to check
Returns
boolean
true if uint === 0
Example
leadingZeros()
leadingZeros: (Defined in: src/primitives/Uint/UintConstructor.ts:113 Get number of leading zero bitsuint) =>number
Parameters
uint
Type
Value to check
Returns
number
Number of leading zeros (0-256)
Example
lessThan()
lessThan: (Defined in: src/primitives/Uint/UintConstructor.ts:105 Check less thanuint,b) =>boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint < b
Example
lessThanOrEqual()
lessThanOrEqual: (Defined in: src/primitives/Uint/UintConstructor.ts:106 Check less than or equaluint,b) =>boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint is less than or equal to b
Example
MAX
MAX: Type
Defined in: src/primitives/Uint/UintConstructor.ts:72
maximum()
maximum: (Defined in: src/primitives/Uint/UintConstructor.ts:111 Get maximum of two valuesuint,b) =>Type
Parameters
uint
Type
First value
b
Type
Second value
Returns
Type
max(uint, b)
Example
MIN
MIN: Type
Defined in: src/primitives/Uint/UintConstructor.ts:73
minimum()
minimum: (Defined in: src/primitives/Uint/UintConstructor.ts:110 Get minimum of two valuesuint,b) =>Type
Parameters
uint
Type
First value
b
Type
Second value
Returns
Type
min(uint, b)
Example
minus()
minus: (Defined in: src/primitives/Uint/UintConstructor.ts:92 Subtract Uint256 value with wrappinguint,b) =>Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
Difference (uint - b) mod 2^256
Example
modulo()
modulo: (Defined in: src/primitives/Uint/UintConstructor.ts:95 Modulo operationuint,b) =>Type
Parameters
uint
Type
Dividend
b
Type
Divisor
Returns
Type
Remainder (uint % b)
Throws
Error if divisor is zeroExample
notEquals()
notEquals: (Defined in: src/primitives/Uint/UintConstructor.ts:104 Check inequalityuint,b) =>boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint !== b
Example
ONE
ONE: Type
Defined in: src/primitives/Uint/UintConstructor.ts:75
plus()
plus: (Defined in: src/primitives/Uint/UintConstructor.ts:91 Add Uint256 value with wrappinguint,b) =>Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
Sum (uint + b) mod 2^256
Example
popCount()
popCount: (Defined in: src/primitives/Uint/UintConstructor.ts:114 Count number of set bits (population count)uint) =>number
Parameters
uint
Type
Value to check
Returns
number
Number of 1 bits
Example
prototype
prototype: UintPrototype
Defined in: src/primitives/Uint/UintConstructor.ts:71
shiftLeft()
shiftLeft: (Defined in: src/primitives/Uint/UintConstructor.ts:101 Left shiftuint,bits) =>Type
Parameters
uint
Type
Value to shift
bits
Type
Number of bits to shift
Returns
Type
uint shifted left by bits (mod 2^256)
Example
shiftRight()
shiftRight: (Defined in: src/primitives/Uint/UintConstructor.ts:102 Right shiftuint,bits) =>Type
Parameters
uint
Type
Value to shift
bits
Type
Number of bits to shift
Returns
Type
uint shifted right by bits
Example
SIZE
SIZE: number
Defined in: src/primitives/Uint/UintConstructor.ts:76
times()
times: (Defined in: src/primitives/Uint/UintConstructor.ts:93 Multiply Uint256 value with wrappinguint,b) =>Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
Product (uint * b) mod 2^256
Example
toAbiEncoded()
toAbiEncoded: (Defined in: src/primitives/Uint/UintConstructor.ts:89 Convert Uint256 to ABI-encoded bytes (32 bytes, big-endian) This is identical to toBytes() - all Uint256 values in ABI encoding are represented as 32-byte big-endian values.uint) =>Uint8Array
Parameters
uint
Type
Uint256 value to encode
Returns
Uint8Array
32-byte ABI-encoded Uint8Array
Example
toBigInt()
toBigInt: (Defined in: src/primitives/Uint/UintConstructor.ts:86 Convert Uint256 to bigintuint) =>bigint
Parameters
uint
Type
Uint256 value to convert
Returns
bigint
bigint value
Example
toBytes()
toBytes: (Defined in: src/primitives/Uint/UintConstructor.ts:88 Convert Uint256 to bytes (big-endian, 32 bytes)uint) =>Uint8Array
Parameters
uint
Type
Uint256 value to convert
Returns
Uint8Array
32-byte Uint8Array
Example
toHex()
toHex: (Defined in: src/primitives/Uint/UintConstructor.ts:85 Convert Uint256 to hex stringuint,padded) =>string
Parameters
uint
Type
Uint256 value to convert
padded
boolean = true
Whether to pad to 64 characters (32 bytes)
Returns
string
Hex string with 0x prefix
Example
toNumber()
toNumber: (Defined in: src/primitives/Uint/UintConstructor.ts:87 Convert Uint256 to numberuint) =>number
Parameters
uint
Type
Uint256 value to convert
Returns
number
number value
Throws
Error if value exceeds MAX_SAFE_INTEGERExample
toPower()
toPower: (Defined in: src/primitives/Uint/UintConstructor.ts:96 Exponentiationuint,exponent) =>Type
Parameters
uint
Type
Base value
exponent
Type
Exponent value
Returns
Type
uint^exponent mod 2^256
Example
toString()
toString: (Defined in: src/primitives/Uint/UintConstructor.ts:90 Convert Uint256 to string representationuint,radix) =>string
Parameters
uint
Type
Uint256 value to convert
radix
number = 10
Base for string conversion (2, 10, 16, etc.)
Returns
string
String representation
Example
tryFrom()
tryFrom: (Defined in: src/primitives/Uint/UintConstructor.ts:83 Try to create Uint256, returns undefined if invalid (standard form)value) =>Type|undefined
Parameters
value
bigint, number, or stringstring | number | bigint
Returns
Type | undefined
Uint256 value or undefined
Example
ZERO
ZERO: Type
Defined in: src/primitives/Uint/UintConstructor.ts:74
Methods
from()
from(Defined in: src/primitives/Uint/UintConstructor.ts:77value):Type
Parameters
value
string | number | bigint
Returns
Type
fromAbiEncoded()
fromAbiEncoded(Defined in: src/primitives/Uint/UintConstructor.ts:82value):Type
Parameters
value
Uint8Array
Returns
Type
fromBigInt()
fromBigInt(Defined in: src/primitives/Uint/UintConstructor.ts:79value):Type
Parameters
value
bigint
Returns
Type
fromBytes()
fromBytes(Defined in: src/primitives/Uint/UintConstructor.ts:81value):Type
Parameters
value
Uint8Array
Returns
Type
fromHex()
fromHex(Defined in: src/primitives/Uint/UintConstructor.ts:78value):Type
Parameters
value
string
Returns
Type
fromNumber()
fromNumber(Defined in: src/primitives/Uint/UintConstructor.ts:80value):Type
Parameters
value
number | bigint
Returns
Type
Type Aliases
BrandedUint
BrandedUint = Type
Defined in: src/primitives/Uint/Uint256Type.ts:19
Deprecated
Use Uint256Type insteadBrandedUint256
BrandedUint256 = Type
Defined in: src/primitives/Uint/Uint256Type.ts:14
Deprecated
Use Uint256Type insteadType
Type =Defined in: src/primitives/Uint/Uint256Type.ts:9 Uint256 typebigint&object
Type Declaration
[brand]
readonly[brand]:"Uint256"
See
https://voltaire.tevm.sh/primitives/uint256 for Uint256 documentationSince
0.0.0Variables
MAX
Defined in: src/primitives/Uint/constants.ts:17 Maximum Uint256 value: 2^256 - 1constMAX:Type
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0MIN
Defined in: src/primitives/Uint/constants.ts:25 Minimum Uint256 value: 0constMIN:Type
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0ONE
Defined in: src/primitives/Uint/constants.ts:41 One valueconstONE:Type
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0SIZE
Defined in: src/primitives/Uint/constants.ts:9 Size in bytes (32 bytes for Uint256)constSIZE:32=32
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Uint256Type
Defined in: src/primitives/Uint/index.ts:105constUint256Type:object
Type Declaration
bitLength()
bitLength: (uint) =>number
Parameters
uint
Type
Returns
number
bitwiseAnd()
bitwiseAnd: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
bitwiseNot()
bitwiseNot: (uint) =>Type
Parameters
uint
Type
Returns
Type
bitwiseOr()
bitwiseOr: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
bitwiseXor()
bitwiseXor: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
clone()
clone: (uint) =>Type
Parameters
uint
Type
Returns
Type
dividedBy()
dividedBy: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
equals()
equals: (uint,b) =>boolean
Parameters
uint
Type
b
Type
Returns
boolean
from()
from: (value) =>Type
Parameters
value
bigint | number | string
Returns
Type
fromAbiEncoded()
fromAbiEncoded: (data) =>Type
Parameters
data
Uint8Array
Returns
Type
fromBigInt()
fromBigInt: (value) =>Type
Parameters
value
bigint
Returns
Type
fromBytes()
fromBytes: (bytes) =>Type
Parameters
bytes
Uint8Array
Returns
Type
fromHex()
fromHex: (hex) =>Type
Parameters
hex
string
Returns
Type
fromNumber()
fromNumber: (value) =>Type
Parameters
value
number
Returns
Type
gcd()
gcd: (a,b) =>Type
Parameters
a
Type
b
Type
Returns
Type
greaterThan()
greaterThan: (uint,b) =>boolean
Parameters
uint
Type
b
Type
Returns
boolean
greaterThanOrEqual()
greaterThanOrEqual: (uint,b) =>boolean
Parameters
uint
Type
b
Type
Returns
boolean
isPowerOf2()
isPowerOf2: (uint) =>boolean
Parameters
uint
Type
Returns
boolean
isValid()
isValid: (value) =>value is Type
Parameters
value
unknown
Returns
value is Type
isZero()
isZero: (uint) =>boolean
Parameters
uint
Type
Returns
boolean
lcm()
lcm: (a,b) =>Type
Parameters
a
Type
b
Type
Returns
Type
leadingZeros()
leadingZeros: (uint) =>number
Parameters
uint
Type
Returns
number
lessThan()
lessThan: (uint,b) =>boolean
Parameters
uint
Type
b
Type
Returns
boolean
lessThanOrEqual()
lessThanOrEqual: (uint,b) =>boolean
Parameters
uint
Type
b
Type
Returns
boolean
max()
max: (…values) =>Type
Parameters
values
…Type[]
Returns
Type
MAX
MAX: Type
maximum()
maximum: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
min()
min: (…values) =>Type
Parameters
values
…Type[]
Returns
Type
MIN
MIN: Type
minimum()
minimum: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
minus()
minus: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
modulo()
modulo: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
notEquals()
notEquals: (uint,b) =>boolean
Parameters
uint
Type
b
Type
Returns
boolean
ONE
ONE: Type
plus()
plus: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
popCount()
popCount: (uint) =>number
Parameters
uint
Type
Returns
number
product()
product: (…values) =>Type
Parameters
values
…Type[]
Returns
Type
shiftLeft()
shiftLeft: (uint,bits) =>Type
Parameters
uint
Type
bits
Type
Returns
Type
shiftRight()
shiftRight: (uint,bits) =>Type
Parameters
uint
Type
bits
Type
Returns
Type
SIZE
SIZE: 32
sum()
sum: (…values) =>Type
Parameters
values
…Type[]
Returns
Type
times()
times: (uint,b) =>Type
Parameters
uint
Type
b
Type
Returns
Type
toAbiEncoded()
toAbiEncoded: (uint) =>Uint8Array
Parameters
uint
Type
Returns
Uint8Array
toBigInt()
toBigInt: (uint) =>bigint
Parameters
uint
Type
Returns
bigint
toBytes()
toBytes: (uint,size?) =>Uint8Array
Parameters
uint
Type
size?
number
Returns
Uint8Array
toHex()
toHex: (uint,padded?) =>string
Parameters
uint
Type
padded?
boolean
Returns
string
toNumber()
toNumber: (uint) =>number
Parameters
uint
Type
Returns
number
toPower()
toPower: (uint,exponent) =>Type
Parameters
uint
Type
exponent
Type
Returns
Type
toString()
toString: (uint,radix?) =>string
Parameters
uint
Type
radix?
number
Returns
string
tryFrom()
tryFrom: (value) =>Type|undefined
Parameters
value
bigint | number | string
Returns
Type | undefined
ZERO
ZERO: Type
ZERO
Defined in: src/primitives/Uint/constants.ts:33 Zero valueconstZERO:Type
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Functions
bitLength()
bitLength(Defined in: src/primitives/Uint/bitLength.ts:16 Get number of bits required to represent valueuint):number
Parameters
uint
Type
Value to check
Returns
number
Number of bits (0-256)
Example
bitwiseAnd()
bitwiseAnd(Defined in: src/primitives/Uint/bitwiseAnd.ts:18 Bitwise ANDuint,b):Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
uint & b
Example
bitwiseNot()
bitwiseNot(Defined in: src/primitives/Uint/bitwiseNot.ts:17 Bitwise NOTuint):Type
Parameters
uint
Type
Operand
Returns
Type
~uint & MAX
Example
bitwiseOr()
bitwiseOr(Defined in: src/primitives/Uint/bitwiseOr.ts:18 Bitwise ORuint,b):Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
uint | b
Example
bitwiseXor()
bitwiseXor(Defined in: src/primitives/Uint/bitwiseXor.ts:18 Bitwise XORuint,b):Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
uint ^ b
Example
clone()
clone(Defined in: src/primitives/Uint/clone.js:17 Create a copy of a Uint256 valueuint):Type
Parameters
uint
Type
Uint256 value to clone
Returns
Type
Copy of the value
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
Example
dividedBy()
dividedBy(Defined in: src/primitives/Uint/dividedBy.ts:19 Divide Uint256 valueuint,b):Type
Parameters
uint
Type
Dividend
b
Type
Divisor
Returns
Type
Quotient (uint / b), floor division
Throws
Error if divisor is zeroExample
equals()
equals(Defined in: src/primitives/Uint/equals.ts:18 Check equalityuint,b):boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint === b
Example
from()
from(Defined in: src/primitives/Uint/from.ts:18 Create Uint256 from bigint or string (standard form)value):Type
Parameters
value
bigint or decimal/hex stringstring | number | bigint
Returns
Type
Uint256 value
Throws
Error if value is out of range or invalidExample
fromAbiEncoded()
fromAbiEncoded(Defined in: src/primitives/Uint/fromAbiEncoded.ts:18 Decode Uint256 from ABI-encoded bytes (32 bytes, big-endian)bytes):Type
Parameters
bytes
Uint8Array
32-byte ABI-encoded data
Returns
Type
Decoded Uint256 value
Throws
Error if bytes length is not 32Example
fromBigInt()
fromBigInt(Defined in: src/primitives/Uint/fromBigInt.ts:16 Create Uint256 from bigintvalue):Type
Parameters
value
bigint
bigint to convert
Returns
Type
Uint256 value
Throws
Error if value out of rangeExample
fromBytes()
fromBytes(Defined in: src/primitives/Uint/fromBytes.ts:16 Create Uint256 from bytes (big-endian)bytes):Type
Parameters
bytes
Uint8Array
bytes to convert
Returns
Type
Uint256 value
Throws
Error if bytes length exceeds 32Example
fromHex()
fromHex(Defined in: src/primitives/Uint/fromHex.ts:19 Create Uint256 from hex stringhex):Type
Parameters
hex
string
Hex string to convert
Returns
Type
Uint256 value
Throws
If value is negativeThrows
If value exceeds maximumExample
fromNumber()
fromNumber(Defined in: src/primitives/Uint/fromNumber.ts:16 Create Uint256 from numbervalue):Type
Parameters
value
number
number to convert
Returns
Type
Uint256 value
Throws
Error if value is not an integer or out of rangeExample
gcd()
gcd(Defined in: src/primitives/Uint/gcd.js:18 Calculate greatest common divisor using Euclidean algorithma,b):Type
Parameters
a
Type
First value
b
Type
Second value
Returns
Type
GCD of a and b
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
Example
greaterThan()
greaterThan(Defined in: src/primitives/Uint/greaterThan.ts:18 Check greater thanuint,b):boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint > b
Example
greaterThanOrEqual()
greaterThanOrEqual(Defined in: src/primitives/Uint/greaterThanOrEqual.ts:18 Check greater than or equaluint,b):boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint >= b
Example
isPowerOf2()
isPowerOf2(Defined in: src/primitives/Uint/isPowerOf2.js:18 Check if value is a power of 2value):boolean
Parameters
value
Type
Value to check
Returns
boolean
True if value is power of 2
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
Example
isValid()
isValid(Defined in: src/primitives/Uint/isValid.ts:16 Check if value is a valid Uint256value):value is Type
Parameters
value
unknown
Value to check
Returns
value is Type
true if value is valid Uint256
Example
isZero()
isZero(Defined in: src/primitives/Uint/isZero.ts:16 Check if value is zerouint):boolean
Parameters
uint
Type
Value to check
Returns
boolean
true if uint === 0
Example
lcm()
lcm(Defined in: src/primitives/Uint/lcm.js:19 Calculate least common multiplea,b):Type
Parameters
a
Type
First value
b
Type
Second value
Returns
Type
LCM of a and b
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
Example
leadingZeros()
leadingZeros(Defined in: src/primitives/Uint/leadingZeros.ts:17 Get number of leading zero bitsuint):number
Parameters
uint
Type
Value to check
Returns
number
Number of leading zeros (0-256)
Example
lessThan()
lessThan(Defined in: src/primitives/Uint/lessThan.ts:18 Check less thanuint,b):boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint < b
Example
lessThanOrEqual()
lessThanOrEqual(Defined in: src/primitives/Uint/lessThanOrEqual.ts:18 Check less than or equaluint,b):boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint is less than or equal to b
Example
max()
max(…Defined in: src/primitives/Uint/max.js:17 Find maximum of multiple Uint256 valuesvalues):Type
Parameters
values
…Type[]
Values to compare
Returns
Type
Maximum value
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
If no values providedExample
maximum()
maximum(Defined in: src/primitives/Uint/maximum.ts:18 Get maximum of two valuesuint,b):Type
Parameters
uint
Type
First value
b
Type
Second value
Returns
Type
max(uint, b)
Example
min()
min(…Defined in: src/primitives/Uint/min.js:15 Find minimum of multiple Uint256 valuesvalues):Type
Parameters
values
…Type[]
Values to compare
Returns
Type
Minimum value
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
If no values providedExample
minimum()
minimum(Defined in: src/primitives/Uint/minimum.ts:18 Get minimum of two valuesuint,b):Type
Parameters
uint
Type
First value
b
Type
Second value
Returns
Type
min(uint, b)
Example
minus()
minus(Defined in: src/primitives/Uint/minus.ts:19 Subtract Uint256 value with wrappinguint,b):Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
Difference (uint - b) mod 2^256
Example
modulo()
modulo(Defined in: src/primitives/Uint/modulo.ts:19 Modulo operationuint,b):Type
Parameters
uint
Type
Dividend
b
Type
Divisor
Returns
Type
Remainder (uint % b)
Throws
Error if divisor is zeroExample
notEquals()
notEquals(Defined in: src/primitives/Uint/notEquals.ts:18 Check inequalityuint,b):boolean
Parameters
uint
Type
First value
b
Type
Second value
Returns
boolean
true if uint !== b
Example
plus()
plus(Defined in: src/primitives/Uint/plus.ts:19 Add Uint256 value with wrappinguint,b):Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
Sum (uint + b) mod 2^256
Example
popCount()
popCount(Defined in: src/primitives/Uint/popCount.ts:16 Count number of set bits (population count)uint):number
Parameters
uint
Type
Value to check
Returns
number
Number of 1 bits
Example
product()
product(…Defined in: src/primitives/Uint/product.js:17 Multiply multiple Uint256 values with wrappingvalues):Type
Parameters
values
…Type[]
Values to multiply
Returns
Type
Product of all values mod 2^256
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
Example
shiftLeft()
shiftLeft(Defined in: src/primitives/Uint/shiftLeft.ts:19 Left shiftuint,bits):Type
Parameters
uint
Type
Value to shift
bits
Type
Number of bits to shift
Returns
Type
uint shifted left by bits (mod 2^256)
Example
shiftRight()
shiftRight(Defined in: src/primitives/Uint/shiftRight.ts:18 Right shiftuint,bits):Type
Parameters
uint
Type
Value to shift
bits
Type
Number of bits to shift
Returns
Type
uint shifted right by bits
Example
sum()
sum(…Defined in: src/primitives/Uint/sum.js:17 Sum multiple Uint256 values with wrappingvalues):Type
Parameters
values
…Type[]
Values to sum
Returns
Type
Sum of all values mod 2^256
See
https://voltaire.tevm.sh/primitives/uint for Uint documentationSince
0.0.0Throws
Example
times()
times(Defined in: src/primitives/Uint/times.ts:19 Multiply Uint256 value with wrappinguint,b):Type
Parameters
uint
Type
First operand
b
Type
Second operand
Returns
Type
Product (uint * b) mod 2^256
Example
toAbiEncoded()
toAbiEncoded(Defined in: src/primitives/Uint/toAbiEncoded.ts:20 Convert Uint256 to ABI-encoded bytes (32 bytes, big-endian) This is identical to toBytes() - all Uint256 values in ABI encoding are represented as 32-byte big-endian values.uint):Uint8Array
Parameters
uint
Type
Uint256 value to encode
Returns
Uint8Array
32-byte ABI-encoded Uint8Array
Example
toBigInt()
toBigInt(Defined in: src/primitives/Uint/toBigInt.ts:16 Convert Uint256 to bigintuint):bigint
Parameters
uint
Type
Uint256 value to convert
Returns
bigint
bigint value
Example
toBytes()
toBytes(Defined in: src/primitives/Uint/toBytes.ts:16 Convert Uint256 to bytes (big-endian, 32 bytes)uint):Uint8Array
Parameters
uint
Type
Uint256 value to convert
Returns
Uint8Array
32-byte Uint8Array
Example
toHex()
toHex(Defined in: src/primitives/Uint/toHex.ts:18 Convert Uint256 to hex stringuint,padded):string
Parameters
uint
Type
Uint256 value to convert
padded
boolean = true
Whether to pad to 64 characters (32 bytes)
Returns
string
Hex string with 0x prefix
Example
toNumber()
toNumber(Defined in: src/primitives/Uint/toNumber.ts:17 Convert Uint256 to numberuint):number
Parameters
uint
Type
Uint256 value to convert
Returns
number
number value
Throws
Error if value exceeds MAX_SAFE_INTEGERExample
toPower()
toPower(Defined in: src/primitives/Uint/toPower.ts:19 Exponentiationuint,exponent):Type
Parameters
uint
Type
Base value
exponent
Type
Exponent value
Returns
Type
uint^exponent mod 2^256
Example
toString()
toString(Defined in: src/primitives/Uint/toString.ts:19 Convert Uint256 to string representationuint,radix):string
Parameters
uint
Type
Uint256 value to convert
radix
number = 10
Base for string conversion (2, 10, 16, etc.)
Returns
string
String representation
Example
tryFrom()
tryFrom(Defined in: src/primitives/Uint/tryFrom.ts:17 Try to create Uint256, returns undefined if invalid (standard form)value):Type|undefined
Parameters
value
bigint, number, or stringstring | number | bigint
Returns
Type | undefined
Uint256 value or undefined

