@tevm/voltaire / primitives/InitCode
primitives/InitCode
Type Aliases
InitCodeType
InitCodeType =Defined in: src/primitives/InitCode/InitCodeType.ts:8 Branded InitCode type Contract creation bytecode (constructor + runtime code) Deployed during contract creation transactionUint8Array&object
Type Declaration
[brand]
readonly[brand]:"InitCode"
Functions
_equals()
_equals(Defined in: src/primitives/InitCode/equals.js:15 Check if two InitCode instances are equala,b):boolean
Parameters
a
InitCodeType
First InitCode
b
InitCodeType
Second InitCode
Returns
boolean
true if equal
Example
_estimateGas()
_estimateGas(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)code):bigint
Parameters
code
InitCodeType
InitCode
Returns
bigint
Estimated gas cost
Example
_extractRuntime()
_extractRuntime(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.code,offset):RuntimeCodeType
Parameters
code
InitCodeType
InitCode
offset
number
Byte offset where runtime code starts
Returns
RuntimeCodeType
RuntimeCode
Example
_toHex()
_toHex(Defined in: src/primitives/InitCode/toHex.js:15 Convert InitCode to hex stringdata):HexType
Parameters
data
InitCodeType
InitCode
Returns
HexType
Hex string
Example
equals()
equals(Defined in: src/primitives/InitCode/index.ts:18a,b):boolean
Parameters
a
string | Uint8Array<ArrayBufferLike> | InitCodeType
b
string | Uint8Array<ArrayBufferLike> | InitCodeType
Returns
boolean
estimateGas()
estimateGas(Defined in: src/primitives/InitCode/index.ts:38value):bigint
Parameters
value
string | Uint8Array<ArrayBufferLike> | InitCodeType
Returns
bigint
extractRuntime()
extractRuntime(Defined in: src/primitives/InitCode/index.ts:31value,offset):RuntimeCodeType
Parameters
value
string | Uint8Array<ArrayBufferLike> | InitCodeType
offset
number
Returns
RuntimeCodeType
from()
from(Defined in: src/primitives/InitCode/from.js:18 Create InitCode from various input typesvalue):InitCodeType
Parameters
value
Hex string or Uint8Arraystring | Uint8Array<ArrayBufferLike>
Returns
InitCodeType
InitCode
See
https://voltaire.tevm.sh/primitives/init-code for InitCode documentationSince
0.0.0Throws
Example
fromHex()
fromHex(Defined in: src/primitives/InitCode/fromHex.js:15 Create InitCode from hex stringhex):InitCodeType
Parameters
hex
string
Hex string
Returns
InitCodeType
InitCode
Throws
If hex string is invalidExample
toHex()
toHex(Defined in: src/primitives/InitCode/index.ts:25value):HexType
Parameters
value
string | Uint8Array<ArrayBufferLike> | InitCodeType
Returns
HexType
