Operation index allows you to query only operations related to your dapp and match them with handlers by content. A single contract call consists of implicit operation and, optionally, internal operations. For each of them, you can specify a handler that will be called when the operation group matches. As a result, you get something like an event log for your dapp.
Each operation handler contains two required fields:
callback— a name of async function with a particular signature; DipDup will search for it in
pattern— a non-empty list of items that need to be matched.
indexes: my_index: kind: tezos.tzkt.operations datasource: tzkt contracts: - some_contract handlers: - callback: on_call pattern: - destination: some_contract entrypoint: transfer
You can think of the operation pattern as a regular expression on a sequence of operations (both external and internal) with a global flag enabled (there can be multiple matches). Multiple operation parameters can be used for matching (source, destination, etc.).
You will get slightly different callback argument types depending on whether pattern item is typed or not. If so, DipDup will generate the dataclass for a particular entrypoint/storage, otherwise you will have to handle untyped parameters/storage updates stored in
|Origination of exact contract.||✅||✅|
|Originations of all contracts having the same code.||✅||✅|
|Special cases only. This filter is very slow and doesn't support strict typing. Usually, ||⚠||❌|
|Currently not supported.||❌||❌|
|Sent by exact address.||✅||N/A|
|Sent by any contract having this code hash||✅||N/A|
|Invoked contract address||✅||✅|
|Invoked contract code hash||✅||✅|
Pattern items have
optional field to continue matching even if this item is not found. It's usually unnecessary to match the entire operation content; you can skip external/internal calls that are not relevant. However, there is a limitation: optional items cannot be followed by operations ignored by the pattern.
pattern: # Implicit transaction - destination: some_contract entrypoint: mint # Internal transactions below - destination: another_contract entrypoint: transfer - source: some_contract type: transaction
DipDup will try to guess the list of used contracts by handlers' signatures. If you want to specify it explicitly, use
indexes: my_index: kind: tezos.tzkt.operations datasource: tzkt contracts: - foo - bar
By default, DipDup processes only transactions, but you can enable other operation types you want to process (currently,
migration are supported).
indexes: my_index: kind: tezos.tzkt.operations datasource: tzkt types: - transaction - origination - migration