Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/RuntimeCode

primitives/RuntimeCode

Type Aliases

RuntimeCodeType

RuntimeCodeType = Uint8Array & object
Defined in: src/primitives/RuntimeCode/RuntimeCodeType.ts:7 Branded RuntimeCode type Pure runtime bytecode without constructor or metadata

Type Declaration

[brand]
readonly [brand]: "RuntimeCode"

Functions

_equals()

_equals(a, b): boolean
Defined in: src/primitives/RuntimeCode/equals.js:15 Check if two RuntimeCode instances are equal

Parameters

a
RuntimeCodeType First RuntimeCode
b
RuntimeCodeType Second RuntimeCode

Returns

boolean true if equal

Example

import * as RuntimeCode from './primitives/RuntimeCode/index.js';
const code1 = RuntimeCode.from("0x6001");
const code2 = RuntimeCode.from("0x6001");
RuntimeCode._equals(code1, code2); // true

_toHex()

_toHex(data): HexType
Defined in: src/primitives/RuntimeCode/toHex.js:15 Convert RuntimeCode to hex string

Parameters

data
RuntimeCodeType RuntimeCode

Returns

HexType Hex string

Example

import * as RuntimeCode from './primitives/RuntimeCode/index.js';
const code = RuntimeCode.from("0x6001600155");
const hex = RuntimeCode._toHex(code);

equals()

equals(a, b): boolean
Defined in: src/primitives/RuntimeCode/index.ts:16

Parameters

a
string | Uint8Array<ArrayBufferLike> | RuntimeCodeType
b
string | Uint8Array<ArrayBufferLike> | RuntimeCodeType

Returns

boolean

from()

from(value): RuntimeCodeType
Defined in: src/primitives/RuntimeCode/from.js:18 Create RuntimeCode from various input types

Parameters

value
Hex string or Uint8Array string | Uint8Array<ArrayBufferLike>

Returns

RuntimeCodeType RuntimeCode

See

https://voltaire.tevm.sh/primitives/runtime-code for RuntimeCode documentation

Since

0.0.0

Throws

Example

import * as RuntimeCode from './primitives/RuntimeCode/index.js';
const code1 = RuntimeCode.from("0x6001600155");
const code2 = RuntimeCode.from(new Uint8Array([0x60, 0x01, 0x60, 0x01, 0x55]));

fromHex()

fromHex(hex): RuntimeCodeType
Defined in: src/primitives/RuntimeCode/fromHex.js:15 Create RuntimeCode from hex string

Parameters

hex
string Hex string

Returns

RuntimeCodeType RuntimeCode

Throws

If hex string is invalid

Example

import * as RuntimeCode from './primitives/RuntimeCode/index.js';
const code = RuntimeCode.fromHex("0x6001600155");

toHex()

toHex(value): HexType
Defined in: src/primitives/RuntimeCode/index.ts:23

Parameters

value
string | Uint8Array<ArrayBufferLike> | RuntimeCodeType

Returns

HexType