Skip to main content
@tevm/voltaire
@tevm/voltaire / index / BrandedBytes32

BrandedBytes32

Type Aliases

Bytes32Like

Bytes32Like = Bytes32Type | string | Uint8Array | bigint | number
Defined in: src/primitives/Bytes/Bytes32/Bytes32Type.ts:11 Inputs that can be converted to Bytes32

Variables

SIZE

const SIZE: 32 = 32
Defined in: src/primitives/Bytes/Bytes32/Bytes32Type.ts:13

ZERO

const ZERO: Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/constants.js:12 Zero Bytes32 constant (32 zero bytes)

Functions

Bytes32()

Bytes32(value): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/index.ts:49

Parameters

value
Bytes32Like

Returns

Bytes32Type

clone()

clone(bytes): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/clone.js:14 Clone a Bytes32 value

Parameters

bytes
Bytes32Type Value to clone

Returns

Bytes32Type Cloned value

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


compare()

compare(a, b): number
Defined in: src/primitives/Bytes/Bytes32/compare.js:15 Compare two Bytes32 values

Parameters

a
Bytes32Type First value
b
Bytes32Type Second value

Returns

number -1 if a < b, 0 if equal, 1 if a > b

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


equals()

equals(a, b): boolean
Defined in: src/primitives/Bytes/Bytes32/equals.js:15 Check if two Bytes32 values are equal

Parameters

a
Bytes32Type First value
b
Bytes32Type Second value

Returns

boolean True if equal

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


from()

from(value): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/from.js:23 Create Bytes32 from string, bytes, number, or bigint

Parameters

value
Value to convert string | number | bigint | Uint8Array<ArrayBufferLike>

Returns

Bytes32Type Bytes32

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Throws

If input is invalid or wrong length

Example


fromBigint()

fromBigint(value): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/fromBigint.js:16 Create Bytes32 from bigint (padded to 32 bytes)

Parameters

value
bigint Bigint to convert

Returns

Bytes32Type Bytes32 (big-endian)

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


fromBytes()

fromBytes(bytes): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/fromBytes.js:18 Create Bytes32 from raw bytes

Parameters

bytes
Uint8Array<ArrayBufferLike> Raw bytes (must be 32 bytes)

Returns

Bytes32Type Bytes32

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Throws

If bytes is wrong length

Example


fromHex()

fromHex(hex): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/fromHex.js:19 Create Bytes32 from hex string

Parameters

hex
string Hex string with optional 0x prefix

Returns

Bytes32Type Bytes32

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Throws

If hex is wrong length

Throws

If hex contains invalid characters

Example


fromNumber()

fromNumber(value): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/fromNumber.js:16 Create Bytes32 from number (padded to 32 bytes)

Parameters

value
number Number to convert

Returns

Bytes32Type Bytes32 (big-endian)

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


isZero()

isZero(bytes): boolean
Defined in: src/primitives/Bytes/Bytes32/isZero.js:14 Check if Bytes32 is all zeros

Parameters

bytes
Bytes32Type Value to check

Returns

boolean True if all zeros

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


size()

size(_bytes): 32
Defined in: src/primitives/Bytes/Bytes32/size.js:16 Get size of Bytes32 (always 32)

Parameters

_bytes
Bytes32Type Bytes32 value

Returns

32 Size in bytes

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


toAddress()

toAddress(bytes): AddressType
Defined in: src/primitives/Bytes/Bytes32/toAddress.js:14 Extract Address from Bytes32 (last 20 bytes)

Parameters

bytes
Bytes32Type Bytes32 to extract from

Returns

AddressType Address

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


toBigint()

toBigint(bytes): bigint
Defined in: src/primitives/Bytes/Bytes32/toBigint.js:14 Convert Bytes32 to bigint (big-endian)

Parameters

bytes
Bytes32Type Bytes32 to convert

Returns

bigint Bigint value

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


toHash()

toHash(bytes): HashType
Defined in: src/primitives/Bytes/Bytes32/toHash.js:14 Convert Bytes32 to Hash (same size, different semantic meaning)

Parameters

bytes
Bytes32Type Bytes32 to convert

Returns

HashType Hash

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


toHex()

toHex(bytes): string
Defined in: src/primitives/Bytes/Bytes32/toHex.js:14 Convert Bytes32 to hex string

Parameters

bytes
Bytes32Type Bytes32 to convert

Returns

string Hex string with 0x prefix

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


toUint8Array()

toUint8Array(bytes): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Bytes/Bytes32/toUint8Array.js:14 Convert Bytes32 to Uint8Array

Parameters

bytes
Bytes32Type Bytes32 to convert

Returns

Uint8Array<ArrayBufferLike> Raw bytes

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example


zero()

zero(): Bytes32Type
Defined in: src/primitives/Bytes/Bytes32/zero.js:15 Create a zero-filled Bytes32

Returns

Bytes32Type Zero-filled Bytes32

See

https://voltaire.tevm.sh/primitives/bytes/bytes32 for documentation

Since

0.0.0

Example

References

Bytes32Type

Re-exports Bytes32Type