Event handler event

Event handler functions receive two arguments: event and context.

The event object contains the event params, the transaction that produced the event, and the block containing that transaction. These types very closely match the corresponding types from ethers.

Event

The event being processed. This is the object passed as the first argument to every event handler function.

interface ExampleEvent {
  name: string;
  params: {
    /* ExampleEvent-specific parameters */
  };
  log: Log;
  block: Block;
  transaction: Transaction;
}

Log

Generic information about the event log itself.

interface Log {
  logId: string; // `${log.blockHash}-${log.logIndex}`
  logSortKey: number;
 
  address: string;
  data: string;
  topics: string; // JSON.stringify-ed array of topic strings
 
  blockHash: string;
  blockNumber: number;
  logIndex: number;
 
  transactionHash: string;
  transactionIndex: number;
 
  removed: number; // boolean, 0 or 1
}

Block

The block containing the transaction that emitted the event log.

interface Block {
  hash: string;
  number: number;
  timestamp: number;
 
  gasLimit: string; // BigNumber
  gasUsed: string; // BigNumber
  baseFeePerGas: string; // BigNumber
 
  miner: string;
  extraData: string;
  size: number;
 
  parentHash: string;
  stateRoot: string;
  transactionsRoot: string;
  receiptsRoot: string;
  logsBloom: string;
  totalDifficulty: string; // BigNumber
}

Transaction

The transaction that emitted the event log.

interface Transaction {
  hash: string;
  nonce: number;
 
  from: string;
  to?: string; // null if contract creation
  value: string; // BigNumber
  input: string;
 
  gas: string; // BigNumber
  gasPrice: string; // BigNumber
  maxFeePerGas?: string; // BigNumber
  maxPriorityFeePerGas?: string; // BigNumber
 
  blockHash: string;
  blockNumber: number;
  transactionIndex: number;
  chainId: number;
}
Last updated on February 8, 2023