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

BrandedBytes1

Functions

Bytes1()

Bytes1(value): Bytes1Type
Defined in: src/primitives/Bytes/Bytes1/index.ts:31

Parameters

value
string | Uint8Array<ArrayBufferLike> | number[]

Returns

Bytes1Type

clone()

clone(bytes): Bytes1Type
Defined in: src/primitives/Bytes/Bytes1/clone.js:12 Clone Bytes1

Parameters

bytes
Bytes1Type Bytes1 to clone

Returns

Bytes1Type Cloned Bytes1

Example

const copy = Bytes1.clone(bytes);

compare()

compare(a, b): number
Defined in: src/primitives/Bytes/Bytes1/compare.js:13 Compare two Bytes1

Parameters

a
Bytes1Type First Bytes1
b
Bytes1Type Second Bytes1

Returns

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

Example

const cmp = Bytes1.compare(bytes1, bytes2);

equals()

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

Parameters

a
Bytes1Type First Bytes1
b
Bytes1Type Second Bytes1

Returns

boolean True if equal

Example

const equal = Bytes1.equals(bytes1, bytes2);

from()

from(value): Bytes1Type
Defined in: src/primitives/Bytes/Bytes1/from.js:17 Create Bytes1 from various input types with size validation

Parameters

value
Uint8Array, hex string, or UTF-8 string (must be exactly 1 byte) string | Uint8Array<ArrayBufferLike>

Returns

Bytes1Type Bytes1

Throws

If length is not 1 byte

Example

const b1 = Bytes1.from(new Uint8Array([0x12]));
const b2 = Bytes1.from("0x12");

fromHex()

fromHex(hex): Bytes1Type
Defined in: src/primitives/Bytes/Bytes1/fromHex.js:16 Create Bytes1 from hex string with size validation

Parameters

hex
string Hex string (must be exactly 2 hex chars + 0x prefix)

Returns

Bytes1Type Bytes1

Throws

If length is not 1 byte

Example

const bytes = Bytes1.fromHex("0x12");

fromNumber()

fromNumber(value): Bytes1Type
Defined in: src/primitives/Bytes/Bytes1/fromNumber.js:13 Create Bytes1 from number (0-255)

Parameters

value
number Number value (0-255)

Returns

Bytes1Type Bytes1

Throws

If value is out of range

Example

const bytes = Bytes1.fromNumber(42);

size()

size(_bytes): 1
Defined in: src/primitives/Bytes/Bytes1/size.js:12 Get size of Bytes1 (always 1)

Parameters

_bytes
Bytes1Type Bytes1

Returns

1 Size (always 1)

Example

const size = Bytes1.size(bytes); // 1

toBytes()

toBytes(bytes): BytesType
Defined in: src/primitives/Bytes/Bytes1/toBytes.js:12 Convert Bytes1 to generic Bytes

Parameters

bytes
Bytes1Type Bytes1 to convert

Returns

BytesType Generic Bytes

Example

const genericBytes = Bytes1.toBytes(bytes);

toHex()

toHex(bytes): HexType
Defined in: src/primitives/Bytes/Bytes1/toHex.js:12 Convert Bytes1 to hex string

Parameters

bytes
Bytes1Type Bytes1 to convert

Returns

HexType Hex string

Example

const hex = Bytes1.toHex(bytes);

toNumber()

toNumber(bytes): number
Defined in: src/primitives/Bytes/Bytes1/toNumber.js:12 Convert Bytes1 to number

Parameters

bytes
Bytes1Type Bytes1 to convert

Returns

number Number value

Example

const num = Bytes1.toNumber(bytes);

References

Bytes1Type

Re-exports Bytes1Type