Skip to main content
Every handler in a Sim IDX listener receives a context object (ctx) that provides metadata about the onchain transaction and the specific call that triggered your code. This guide covers the structure of all available context objects, the most common properties you’ll use, and a detailed reference for all available data.

FunctionContext vs. EventContext

While structurally identical, the context you receive depends on the type of trigger you are handling. The primary difference is visible in the handler’s function signature, which includes other typed parameters alongside the context.
function UniswapV3Pool$onSwapFunction(
    // For function triggers
    FunctionContext memory ctx,
    // Typed function arguments
    UniswapV3Pool$SwapFunctionInputs memory inputs,
    // Typed function return values
    UniswapV3Pool$SwapFunctionOutputs memory outputs
) external;
Both handlers use ctx.txn in the same way to access transaction and call metadata. The framework provides the additional inputs/outputs or params structs to give you typed access to the specific data from that function or event.
For more details on the underlying definitions, you can inspect the core Context.sol file directly in the listeners/lib/sim-idx-sol/src/Context.sol path of your project.

Core Metadata

Nearly every context object exposes txn: TransactionContext, which represents metadata for the top-level transaction under which your handler runs. Inside txn, the call: CallFrame describes the current execution frame (who is executing, who called, calldata, value, and call semantics). These two types power most real-world usage such as correlating by transaction hash, identifying the executing pool/contract, and attributing actions to the effective caller.

TransactionContext

Represents the top-level transaction metadata available to handlers. It is accessed as ctx.txn from both FunctionContext and EventContext, and from other contexts covered below.
PropertyTypeDescription
hash()bytes32The unique hash of the top-level transaction.
isSuccessful()boolReturns true if the top-level transaction succeeded without reverting.
chainIduint256The chain ID where the transaction was executed. Equivalent to block.chainid.
transactionIndex()uint64Index of the top-level transaction within its block. Useful for deterministic ordering with logIndex().
callCallFrameDetailed metadata about the current execution frame.

CallFrame

Describes the current execution frame within the transaction. This is accessed via ctx.txn.call from all context types that expose a TransactionContext.
PropertyTypeDescription
callee()addressThe address of the contract whose code is currently executing.
caller()addressThe address that invoked the current call (EOA or another contract).
value()uint256The amount of wei sent with the current call.
callData()bytesThe raw calldata for the current call frame.
callDepth()uint256The depth of the current call in the execution stack.
callType()CallTypeThe opcode used for the call: CALL, DELEGATECALL, STATICCALL, CREATE, etc.
delegator()addressIn a DELEGATECALL, the proxy contract address.
delegatee()addressIn a DELEGATECALL, the implementation contract address.
verificationSourceContractVerificationSourceHow the contract was verified: Unspecified, ABI, or Bytecode.

FunctionContext

Passed to post-execution function triggers, FunctionContext provides metadata about the transaction and the specific function call that was just executed. It contains a single property, txn, which is a TransactionContext.
PropertyTypeDescription
txnTransactionContextMetadata about the top-level transaction and current call frame.
globalIndex()uint120Globally monotonic 120-bit index that totally orders execution; encodes blockNumber, reorgIncarnation, txnIndex, shadowPc (see GlobalIndexLib helpers).
simSimFunctionsHelper utilities (e.g., getDeployer(address)), available as ctx.sim.
isInputDecodingSuccessfulboolTrue if function inputs decoded into typed inputs.
isOutputDecodingSuccessfulboolTrue if function return data decoded into typed outputs.

EventContext

Passed to event triggers, EventContext provides metadata about the transaction and the call that emitted the event. Its structure is identical to FunctionContext and provides access to the same TransactionContext and CallFrame properties detailed above.
PropertyTypeDescription
txnTransactionContextMetadata about the top-level transaction and current call frame.
globalIndex()uint120Globally monotonic 120-bit index that totally orders execution; encodes blockNumber, reorgIncarnation, txnIndex, shadowPc (see GlobalIndexLib helpers).
isDecodingSuccessfulboolWhether the event log decoded successfully into typed params.
logIndex()uint64Index of the current log within the block. Combine with transactionIndex() for canonical ordering.
simSimFunctionsHelper utilities (e.g., getDeployer(address)), available as ctx.sim.

PreFunctionContext

Passed to pre-execution function triggers, PreFunctionContext provides metadata before the target function is executed. Its structure is identical to FunctionContext and provides access to the same TransactionContext and CallFrame properties.
PropertyTypeDescription
txnTransactionContextMetadata about the top-level transaction and current call frame.
globalIndex()uint120Globally monotonic 120-bit index for pre-exec ordering; encodes blockNumber, reorgIncarnation, txnIndex, shadowPc (see GlobalIndexLib helpers).
isInputDecodingSuccessfulboolWhether the target function’s inputs decoded at pre-exec time.
simSimFunctionsHelper utilities (e.g., getDeployer(address)), available as ctx.sim.

RawCallContext

Used by Raw$OnCall global triggers, this context provides metadata for every function call on a chain.
PropertyTypeDescription
txnTransactionContextMetadata about the top-level transaction.
callData()bytesThe raw calldata for the current call.
returnData()bytesThe raw return data from the call.
globalIndex()uint120Globally monotonic 120-bit index for the current call; encodes blockNumber, reorgIncarnation, txnIndex, shadowPc (see GlobalIndexLib helpers).
simSimFunctionsHelper utilities (e.g., getDeployer(address)), available as ctx.sim.

RawPreCallContext

Used by Raw$OnPreCall global triggers, this context provides metadata for every upcoming function call on a chain before it executes.
PropertyTypeDescription
callData()bytesThe raw calldata for the upcoming call.
globalIndex()uint120Globally monotonic 120-bit index for the upcoming call; encodes blockNumber, reorgIncarnation, txnIndex, shadowPc (see GlobalIndexLib helpers).
simSimFunctionsHelper utilities (e.g., getDeployer(address)), available as ctx.sim.

RawLogContext

Used by Raw$OnLog global triggers, this context provides data for every event log emitted on a chain.
PropertyTypeDescription
txnTransactionContextMetadata about the top-level transaction.
topics()bytes32[]The indexed topics of the event log.
data()bytesThe un-indexed data of the event log.
globalIndex()uint120Globally monotonic 120-bit index for the current log; encodes blockNumber, reorgIncarnation, txnIndex, shadowPc (see GlobalIndexLib helpers).
logIndex()uint64Index of the current log within the block.
simSimFunctionsHelper utilities (e.g., getDeployer(address)), available as ctx.sim.

RawBlockContext

Used by Raw$OnBlock global triggers, this context provides a hook that runs once for every new block.
PropertyTypeDescription
blockNumberuint256The number of the current block.

SimFunctions

The SimFunctions object is available via ctx.sim on FunctionContext, EventContext, PreFunctionContext, RawCallContext, RawPreCallContext, and RawLogContext.
FunctionSignatureReturnsDescription
getDeployerfunction(address target)addressReturns the deployer of the given contract target. Useful for attribution, filtering, and safety heuristics on newly deployed tokens.