Skip to content

CallFrame

The result of the callTracer: an execution as the tree of the calls it made. Each call is a frame, and a frame holds the frames of the calls it made itself.

import { Effect } from "effect";
import { Debug } from "@ethect/core/rpc";
import type { Hash } from "@ethect/core";
import type { CallFrame } from "@ethect/core/rpc";
// every address called, the top call first
const callees = (frame: CallFrame.CallFrame): ReadonlyArray<string> => [
...(frame.to === undefined ? [] : [frame.to]),
...(frame.calls ?? []).flatMap(callees),
];
const called = (hash: Hash.Hash) =>
Debug.traceTransaction(hash, { tracer: "callTracer" }).pipe(Effect.map(callees));
Schema Type Describes Used by
CallFrame.schema CallFrame.CallFrame one call, with the calls it made under calls the result of a Debug.trace* call with tracer: "callTracer"
CallFrame.logSchema CallFrame.Log a log a call emitted each entry of logs
CallFrame.configSchema CallFrame.Config the settings of the tracer the tracerConfig of the same call

CallFrame.Encoded is the type of a frame as it is on the wire, before decoding, with its quantities as hex strings. CallFrame.schema is typed with it because a recursive schema has to name both of its types.

CallFrame.CallFrame.

Field Type Notes
type string the opcode that made the call: "CALL", "STATICCALL", "DELEGATECALL", "CREATE" and the like
from Address the caller
to Address (optional) the account called, or the contract created
value bigint (optional) the wei sent with the call
gas bigint the gas the call was given
gasUsed bigint the gas it used
input Hex the calldata, or the init code of a creation
output Hex (optional) what the call returned: return data, revert data, or the code of a contract created
error string (optional) why the call failed, such as "execution reverted"
revertReason string (optional) the message it reverted with, when it had one
logs ReadonlyArray<CallFrame.Log> (optional) the logs this call emitted. Only with withLog.
calls ReadonlyArray<CallFrame> (optional) the frames of the calls this call made

CallFrame.Log.

Field Type Notes
address Address the contract that emitted the log
topics ReadonlyArray<Hash>
data Hex
position number (optional) how many calls the frame had made before the log
index number (optional) the place of the log among the logs of the transaction

CallFrame.Config, passed as tracerConfig.

Field Type Notes
onlyTopCall boolean (optional) leave out the calls the top one made: the frame has no calls
withLog boolean (optional) add to each frame the logs its call emitted
import { Debug } from "@ethect/core/rpc";
import type { Hash } from "@ethect/core";
const topWithLogs = (hash: Hash.Hash) =>
Debug.traceTransaction(hash, {
tracer: "callTracer",
tracerConfig: { withLog: true },
});
  • Absent, not empty. A frame whose call made no call has no calls key, and a frame whose call emitted no log has no logs key, even with withLog. Read them with frame.calls ?? [].
  • Logs sit on the frame that emitted them. With withLog, the log of an inner call is in the logs of the inner frame, not in those of the frames above it.
  • A failed call is still a frame. It has an error. A revert has "execution reverted" there and the revert data in output. revertReason is set only when the call reverted with a message: a revert with other data leaves it out.
  • A creation is a frame of type "CREATE". Its to is the new contract and its output is the code of that contract.
  • Quantities are bigint. gas, gasUsed and value arrive as hex quantities, unlike the gas figures of a StructLog.