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

primitives/OpStep

Type Aliases

OpStepType

OpStepType = object
Defined in: src/primitives/OpStep/OpStepType.ts:12 Single opcode execution step Represents the EVM state at a specific instruction

See

https://voltaire.tevm.sh/primitives/op-step for OpStep documentation

Since

0.0.0

Properties

[brand]
readonly [brand]: "OpStep"
Defined in: src/primitives/OpStep/OpStepType.ts:13
depth
readonly depth: number
Defined in: src/primitives/OpStep/OpStepType.ts:23 Call depth (0 for top-level call)
error?
readonly optional error: string
Defined in: src/primitives/OpStep/OpStepType.ts:31 Error message if step failed
gas
readonly gas: Type
Defined in: src/primitives/OpStep/OpStepType.ts:19 Remaining gas before executing this operation
gasCost
readonly gasCost: Type
Defined in: src/primitives/OpStep/OpStepType.ts:21 Gas cost for this operation
memory?
readonly optional memory: Uint8Array
Defined in: src/primitives/OpStep/OpStepType.ts:27 Memory state (raw bytes)
op
readonly op: BrandedOpcode
Defined in: src/primitives/OpStep/OpStepType.ts:17 Opcode number (0x00-0xFF)
pc
readonly pc: number
Defined in: src/primitives/OpStep/OpStepType.ts:15 Program counter (bytecode offset)
stack?
readonly optional stack: readonly Type[]
Defined in: src/primitives/OpStep/OpStepType.ts:25 Stack state (top to bottom)
storage?
readonly optional storage: Record<string, Type>
Defined in: src/primitives/OpStep/OpStepType.ts:29 Storage changes in this step (key -> value)

Functions

_from()

_from(data): OpStepType
Defined in: src/primitives/OpStep/from.js:21 Creates an OpStep from raw data

Parameters

data
OpStep data
depth
number Call depth
error?
string Error message
gas
Type Remaining gas
gasCost
Type Gas cost
memory?
Uint8Array<ArrayBufferLike> Memory state
op
BrandedOpcode Opcode
pc
number Program counter
stack?
readonly Type[] Stack state
storage?
Record<string, Type> Storage changes

Returns

OpStepType OpStep instance

Example

import { from } from './from.js';
const step = from({ pc: 0, op: 0x60, gas: 1000000n, gasCost: 3n, depth: 0 });

_hasError()

_hasError(step): boolean
Defined in: src/primitives/OpStep/hasError.js:14 Checks if an OpStep has an error

Parameters

step
OpStepType OpStep to check

Returns

boolean True if step has an error

Example

import { hasError } from './hasError.js';
if (hasError(step)) {
  console.error(`Error at PC ${step.pc}: ${step.error}`);
}

from()

from(data): OpStepType
Defined in: src/primitives/OpStep/index.ts:22 Creates an OpStep from raw data

Parameters

data
Omit<OpStepType, brand> OpStep data

Returns

OpStepType OpStep instance

See

https://voltaire.tevm.sh/primitives/op-step for OpStep documentation

Since

0.0.0

Example

import { OpStep } from './primitives/OpStep/index.js';
const step = OpStep.from({ pc: 0, op: 0x60, gas: 1000000n, gasCost: 3n, depth: 0 });

hasError()

hasError(step): boolean
Defined in: src/primitives/OpStep/index.ts:41 Checks if an OpStep has an error

Parameters

step
OpStepType OpStep to check

Returns

boolean True if step has an error

Example

import { OpStep } from './primitives/OpStep/index.js';
if (OpStep.hasError(step)) {
  console.error(`Error: ${step.error}`);
}