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

const trace = await Effect.runPromise(CallTrace.from({
  type: 'CALL',
  from: '0x...',
  to: '0x...',
  gas: 21000n,
  gasUsed: 21000n,
  input: '0x',
  output: '0x'
}))

// Get direct child calls
const children = CallTrace.getCalls(trace)

// Flatten entire call tree
const all = CallTrace.flatten(trace)
const delegateCalls = all.filter(c => c.type === 'DELEGATECALL')

// Check for errors anywhere in tree
if (CallTrace.hasError(trace)) {
  console.log('Transaction reverted')
}

Functions

FunctionDescription
from(data)Parse raw trace data
getCalls(trace)Get immediate child calls
flatten(trace)Flatten call tree to array
hasError(trace)Check for errors in tree

Error Handling

const result = await Effect.runPromiseExit(CallTrace.from(invalid))
if (result._tag === 'Failure') {
  console.error(result.cause)
}