Skip to main content
import * as OpStep from 'voltaire-effect/primitives/OpStep'
import { Effect } from 'effect'

const step = Effect.runSync(OpStep.from({
  pc: 10,
  op: 0x01, // ADD
  gas: 50000n,
  gasCost: 3n,
  depth: 1,
  stack: [1n, 2n]
}))

console.log(`PC: ${step.pc}, Op: 0x${step.op.toString(16)}, Gas: ${step.gas}`)

Fields

FieldTypeDescription
pcnumberProgram counter
opnumberOpcode (numeric)
gasbigintRemaining gas
gasCostbigintCost of this op
depthnumberCall depth
stackbigint[]Stack state (optional)
memoryUint8ArrayMemory state (optional)
storageRecord<string, bigint>Storage state (optional)
errorstringError if step failed (optional)

Error Handling

const result = await Effect.runPromiseExit(OpStep.from({ pc: -1, ... }))
if (result._tag === 'Failure') {
  console.error(result.cause) // OpStepError
}