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

BrandedBytes16

Type Aliases

Bytes16Like

Bytes16Like = Bytes16Type | string | Uint8Array
Defined in: src/primitives/Bytes/Bytes16/Bytes16Type.ts:11 Inputs that can be converted to Bytes16

Variables

SIZE

const SIZE: 16 = 16
Defined in: src/primitives/Bytes/Bytes16/Bytes16Type.ts:13

ZERO

const ZERO: Bytes16Type
Defined in: src/primitives/Bytes/Bytes16/constants.js:10 Zero Bytes16 constant (16 zero bytes)

Functions

Bytes16()

Bytes16(value): Bytes16Type
Defined in: src/primitives/Bytes/Bytes16/index.ts:39

Parameters

value
Bytes16Like

Returns

Bytes16Type

clone()

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

Parameters

bytes
Bytes16Type Value to clone

Returns

Bytes16Type Cloned value

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const cloned = Bytes16.clone(bytes);

compare()

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

Parameters

a
Bytes16Type First value
b
Bytes16Type Second value

Returns

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

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const result = Bytes16.compare(a, b);

equals()

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

Parameters

a
Bytes16Type First value
b
Bytes16Type Second value

Returns

boolean True if equal

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const equal = Bytes16.equals(a, b);

from()

from(value): Bytes16Type
Defined in: src/primitives/Bytes/Bytes16/from.js:19 Create Bytes16 from string or bytes

Parameters

value
Hex string with optional 0x prefix or Uint8Array string | Uint8Array<ArrayBufferLike>

Returns

Bytes16Type Bytes16

See

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

Since

0.0.0

Throws

If input is invalid or wrong length

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const bytes = Bytes16.from('0x1234567890abcdef1234567890abcdef');
const bytes2 = Bytes16.from(new Uint8Array(16));

fromBytes()

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

Parameters

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

Returns

Bytes16Type Bytes16

See

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

Since

0.0.0

Throws

If bytes is wrong length

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const bytes = Bytes16.fromBytes(new Uint8Array(16));

fromHex()

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

Parameters

hex
string Hex string with optional 0x prefix

Returns

Bytes16Type Bytes16

See

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

Since

0.0.0

Throws

If hex is wrong length

Throws

If hex contains invalid characters

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const bytes = Bytes16.fromHex('0x1234567890abcdef1234567890abcdef');

isZero()

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

Parameters

bytes
Bytes16Type Value to check

Returns

boolean True if all zeros

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const isAllZeros = Bytes16.isZero(bytes);

size()

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

Parameters

_bytes
Bytes16Type Bytes16 value

Returns

16 Size in bytes

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const s = Bytes16.size(bytes); // 16

toHex()

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

Parameters

bytes
Bytes16Type Bytes16 to convert

Returns

string Hex string with 0x prefix

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const hex = Bytes16.toHex(bytes);
// "0x1234567890abcdef1234567890abcdef"

toUint8Array()

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

Parameters

bytes
Bytes16Type Bytes16 to convert

Returns

Uint8Array<ArrayBufferLike> Raw bytes

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const raw = Bytes16.toUint8Array(bytes);

zero()

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

Returns

Bytes16Type Zero-filled Bytes16

See

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

Since

0.0.0

Example

import * as Bytes16 from './primitives/Bytes/Bytes16/index.js';
const zeros = Bytes16.zero();

References

Bytes16Type

Re-exports Bytes16Type