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

primitives/CallTrace

Type Aliases

CallTraceType

CallTraceType = object
Defined in: src/primitives/CallTrace/CallTraceType.ts:12 Call tree structure from callTracer Represents a single call (or create) and its nested subcalls

See

https://voltaire.tevm.sh/primitives/call-trace for CallTrace documentation

Since

0.0.0

Properties

[brand]
readonly [brand]: "CallTrace"
Defined in: src/primitives/CallTrace/CallTraceType.ts:13
calls?
readonly optional calls: readonly CallTraceType[]
Defined in: src/primitives/CallTrace/CallTraceType.ts:42 Nested calls made by this call
error?
readonly optional error: string
Defined in: src/primitives/CallTrace/CallTraceType.ts:38 Error message if call failed
from
readonly from: AddressType
Defined in: src/primitives/CallTrace/CallTraceType.ts:24 Caller address
gas
readonly gas: Type
Defined in: src/primitives/CallTrace/CallTraceType.ts:30 Gas provided to this call
gasUsed
readonly gasUsed: Type
Defined in: src/primitives/CallTrace/CallTraceType.ts:32 Gas actually used by this call
input
readonly input: Uint8Array
Defined in: src/primitives/CallTrace/CallTraceType.ts:34 Input data (calldata or init code)
output
readonly output: Uint8Array
Defined in: src/primitives/CallTrace/CallTraceType.ts:36 Return data or deployed code
revertReason?
readonly optional revertReason: string
Defined in: src/primitives/CallTrace/CallTraceType.ts:40 Decoded revert reason (from Error(string) or Panic(uint256))
to?
readonly optional to: AddressType
Defined in: src/primitives/CallTrace/CallTraceType.ts:26 Callee address (undefined for CREATE/CREATE2 before completion)
type
readonly type: "CALL" | "STATICCALL" | "DELEGATECALL" | "CALLCODE" | "CREATE" | "CREATE2" | "SELFDESTRUCT"
Defined in: src/primitives/CallTrace/CallTraceType.ts:15 Call type
value?
readonly optional value: Type
Defined in: src/primitives/CallTrace/CallTraceType.ts:28 Call value in wei

Functions

_flatten()

_flatten(trace): CallTraceType[]
Defined in: src/primitives/CallTrace/flatten.js:14 Flattens a call tree into a linear list of all calls Useful for analyzing all calls in execution order

Parameters

trace
CallTraceType Root call trace

Returns

CallTraceType[] Flat array of all calls (including root)

Example

import { flatten } from './flatten.js';
const allCalls = flatten(rootTrace);
const failedCalls = allCalls.filter(call => call.error);

_from()

_from(data): CallTraceType
Defined in: src/primitives/CallTrace/from.js:31 Creates a CallTrace from raw data

Parameters

data
CallTrace data
calls?
readonly CallTraceType[] Nested calls
error?
string Error message
from
AddressType Caller address
gas
Type Gas provided
gasUsed
Type Gas used
input
Uint8Array<ArrayBufferLike> Input data
output
Uint8Array<ArrayBufferLike> Output data
revertReason?
string Decoded revert reason
to?
AddressType Callee address
type
"CALL" | "STATICCALL" | "DELEGATECALL" | "CALLCODE" | "CREATE" | "CREATE2" | "SELFDESTRUCT" Call type
value?
Type Call value

Returns

CallTraceType CallTrace instance

Example

import { from } from './from.js';
const trace = from({
  type: "CALL",
  from: fromAddress,
  to: toAddress,
  gas: 100000n,
  gasUsed: 50000n,
  input: new Uint8Array(),
  output: new Uint8Array()
});

_getCalls()

_getCalls(trace): readonly CallTraceType[]
Defined in: src/primitives/CallTrace/getCalls.js:13 Gets nested calls from a CallTrace

Parameters

trace
CallTraceType CallTrace to extract calls from

Returns

readonly CallTraceType[] Nested calls (empty array if none)

Example

import { getCalls } from './getCalls.js';
const nestedCalls = getCalls(trace);
console.log(`${nestedCalls.length} nested calls`);

_hasError()

_hasError(trace): boolean
Defined in: src/primitives/CallTrace/hasError.js:14 Checks if a CallTrace has an error

Parameters

trace
CallTraceType CallTrace to check

Returns

boolean True if call failed

Example

import { hasError } from './hasError.js';
if (hasError(trace)) {
  console.error(`Call failed: ${trace.error}`);
}

flatten()

flatten(trace): CallTraceType[]
Defined in: src/primitives/CallTrace/index.ts:73 Flattens a call tree into a linear list

Parameters

trace
CallTraceType Root call trace

Returns

CallTraceType[] Flat array of all calls

Example

import { CallTrace } from './primitives/CallTrace/index.js';
const allCalls = CallTrace.flatten(trace);

from()

from(data): CallTraceType
Defined in: src/primitives/CallTrace/index.ts:26 Creates a CallTrace from raw data

Parameters

data
Omit<CallTraceType, brand> CallTrace data

Returns

CallTraceType CallTrace instance

See

https://voltaire.tevm.sh/primitives/call-trace for CallTrace documentation

Since

0.0.0

Example

import { CallTrace } from './primitives/CallTrace/index.js';
const trace = CallTrace.from({ type: "CALL", from, to, gas: 100000n, gasUsed: 50000n, input, output });

getCalls()

getCalls(trace): readonly CallTraceType[]
Defined in: src/primitives/CallTrace/index.ts:43 Gets nested calls from a CallTrace

Parameters

trace
CallTraceType CallTrace to extract calls from

Returns

readonly CallTraceType[] Nested calls

Example

import { CallTrace } from './primitives/CallTrace/index.js';
const calls = CallTrace.getCalls(trace);

hasError()

hasError(trace): boolean
Defined in: src/primitives/CallTrace/index.ts:58 Checks if a CallTrace has an error

Parameters

trace
CallTraceType CallTrace to check

Returns

boolean True if call failed

Example

import { CallTrace } from './primitives/CallTrace/index.js';
if (CallTrace.hasError(trace)) console.error(trace.error);