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

primitives/InitCode

Type Aliases

InitCodeType

InitCodeType = Uint8Array & object
Defined in: src/primitives/InitCode/InitCodeType.ts:8 Branded InitCode type Contract creation bytecode (constructor + runtime code) Deployed during contract creation transaction

Type Declaration

[brand]
readonly [brand]: "InitCode"

Functions

_equals()

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

Parameters

a
InitCodeType First InitCode
b
InitCodeType Second InitCode

Returns

boolean true if equal

Example


_estimateGas()

_estimateGas(code): bigint
Defined in: src/primitives/InitCode/estimateGas.js:16 Estimate gas cost for contract creation Gas cost = 21000 (base) + 200 * non-zero bytes + 4 * zero bytes + 32000 (creation)

Parameters

code
InitCodeType InitCode

Returns

bigint Estimated gas cost

Example


_extractRuntime()

_extractRuntime(code, offset): RuntimeCodeType
Defined in: src/primitives/InitCode/extractRuntime.js:18 Extract runtime code from init code at specified offset Init code contains constructor logic followed by runtime code. This extracts the runtime portion starting at the given offset.

Parameters

code
InitCodeType InitCode
offset
number Byte offset where runtime code starts

Returns

RuntimeCodeType RuntimeCode

Example


_toHex()

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

Parameters

data
InitCodeType InitCode

Returns

HexType Hex string

Example


equals()

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

Parameters

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

Returns

boolean

estimateGas()

estimateGas(value): bigint
Defined in: src/primitives/InitCode/index.ts:38

Parameters

value
string | Uint8Array<ArrayBufferLike> | InitCodeType

Returns

bigint

extractRuntime()

extractRuntime(value, offset): RuntimeCodeType
Defined in: src/primitives/InitCode/index.ts:31

Parameters

value
string | Uint8Array<ArrayBufferLike> | InitCodeType
offset
number

Returns

RuntimeCodeType

from()

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

Parameters

value
Hex string or Uint8Array string | Uint8Array<ArrayBufferLike>

Returns

InitCodeType InitCode

See

https://voltaire.tevm.sh/primitives/init-code for InitCode documentation

Since

0.0.0

Throws

Example


fromHex()

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

Parameters

hex
string Hex string

Returns

InitCodeType InitCode

Throws

If hex string is invalid

Example


toHex()

toHex(value): HexType
Defined in: src/primitives/InitCode/index.ts:25

Parameters

value
string | Uint8Array<ArrayBufferLike> | InitCodeType

Returns

HexType