Learn how to access onchain metadata with FunctionContext, EventContext, and other context objects in your Listeners.
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.
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.
Copy
Ask AI
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.
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.
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.
Property
Type
Description
hash()
bytes32
The unique hash of the top-level transaction.
isSuccessful()
bool
Returns true if the top-level transaction succeeded without reverting.
chainId
uint256
The chain ID where the transaction was executed. Equivalent to block.chainid.
transactionIndex()
uint64
Index of the top-level transaction within its block. Useful for deterministic ordering with logIndex().
Describes the current execution frame within the transaction. This is accessed via ctx.txn.call from all context types that expose a TransactionContext.
Property
Type
Description
callee()
address
The address of the contract whose code is currently executing.
caller()
address
The address that invoked the current call (EOA or another contract).
value()
uint256
The amount of wei sent with the current call.
callData()
bytes
The raw calldata for the current call frame.
callDepth()
uint256
The depth of the current call in the execution stack.
callType()
CallType
The opcode used for the call: CALL, DELEGATECALL, STATICCALL, CREATE, etc.
delegator()
address
In a DELEGATECALL, the proxy contract address.
delegatee()
address
In a DELEGATECALL, the implementation contract address.
verificationSource
ContractVerificationSource
How the contract was verified: Unspecified, ABI, or Bytecode.
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.
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.
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.
The SimFunctions object is available via ctx.sim on FunctionContext, EventContext, PreFunctionContext, RawCallContext, RawPreCallContext, and RawLogContext.
Function
Signature
Returns
Description
getDeployer
function(address target)
address
Returns the deployer of the given contract target. Useful for attribution, filtering, and safety heuristics on newly deployed tokens.