substrate.events
index
This index allows processing events emitted by Substrate pallets. You can define a handler for each module/name pair. Only necessary events are processed.
Below is a basic indexer for AssetHub transfers.
To create a project based on this template, run dipdup new -t demo_substrate_events
.
spec_version: 3.0
package: demo_substrate_events
runtimes:
assethub:
kind: substrate
type_registry: statemint
datasources:
subsquid:
kind: substrate.subsquid
url: https://v2.archive.subsquid.io/network/asset-hub-polkadot
subscan:
kind: substrate.subscan
url: https://assethub-polkadot.api.subscan.io/api
node:
kind: substrate.node
url: https://statemint.api.onfinality.io/rpc?apikey=${NODE_API_KEY:-''}
ws_url: wss://statemint.api.onfinality.io/ws?apikey=${NODE_API_KEY:-''}
indexes:
assethub_transfers:
kind: substrate.events
runtime: assethub
datasources:
- subsquid
- subscan
- node
handlers:
- callback: on_transfer
name: Assets.Transferred
Datasources
DipDup indexes for Substrate networks use Subsquid Network as a main source of historical data. Substrate nodes are not required for DipDup to operate, but they can be used to get the latest data (not yet in Subsquid Network) and realtime updates. See substrate.subsquid and substrate.node pages for more info on how to configure both datasources.
For testing purposes, you can use EVM node as a single datasource, but indexing will be significantly slower. For production, it's recommended to use Subsquid Network as the main datasource and EVM node(s) as a secondary one. If there are multiple substrate.node
datasources attached to index, DipDup will use random one for each request.