Skip to main content

addTransaction(options)

Get some or all transactions on the network. options has the following structure:
Item filters (where):
  • from and to: the sets of addresses of tx senders and receivers. Omit to subscribe to transactions from/to any address.
  • sighash: first four bytes of the Keccak hash (SHA3) of the canonical representation of the function signature. Omit to subscribe to any transaction.
  • type: transaction type numbers, such as 0, 1, 2, 3, or 4. Type 4 is used by EIP-7702 authorization-list transactions.
Filter values are matched as exact strings by the Portal — always pass addresses and sighashes as lowercase hex strings. @subsquid/evm-stream does not normalize the case for you.
Enabling the logs, traces and/or stateDiffs flags of include will cause the data source to retrieve event logs, traces and/or state diffs that occurred as a result of each selected transaction. The data is added to the appropriate flat iterables within the block data; call augmentBlock() from @subsquid/evm-objects to navigate between the related items conveniently (e.g. transaction.logs). range overrides the global setBlockRange() for this particular request. Note that transactions can also be requested by addLog(), addTrace() and addStateDiff() as related data. Selection of the exact fields to be retrieved for each transaction and the optional related data items is done with the setFields() method documented on the Field selection page. There are no default fields — request everything your handler reads. Some examples are available below.
Typescript ABI modules generated by squid-evm-typegen provide function sighashes as constants, e.g.

Examples

  1. Request all EVM calls to the contract 0x6a2d262D56735DbA19Dd70682B39F6bE9a931D98:
  1. Request all transactions matching sighash of transfer(address,uint256):
  1. Request all transfer(address,uint256) calls to the specified addresses, from block 6_000_000 onwards, and fetch their inputs. Also retrieve all logs emitted by these calls.
  1. Mine all transactions to and from Vitalik Buterin’s address vitalik.eth. Fetch the involved addresses, ETH value and hash for each transaction. Get execution traces for outgoing transactions — request the trace fields you need with setFields() as described in the traces section of Field selection.