Table of Contents

evm.events index

Note
Examples below are for Ethereum mainnet. For other supported networks, see EVM Networks.

This index allows processing events emitted by Ethereum smart contracts. You can define a handler for each contract/name pair. Only necessary events are processed.

Below is a basic indexer for USDt token contract transfers.

To create a project based on this template, run dipdup new -t demo_evm_events.

dipdup.yaml
spec_version: 3.0
package: demo_evm_events

datasources:
  subsquid:
    kind: evm.subsquid
    url: ${SUBSQUID_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
  etherscan:
    kind: abi.etherscan
    url: ${ETHERSCAN_URL:-https://api.etherscan.io/api}
    api_key: ${ETHERSCAN_API_KEY:-''}
  evm_node:
    kind: evm.node
    url: ${NODE_URL:-https://eth-mainnet.g.alchemy.com/v2}/${NODE_API_KEY:-''}
    ws_url: ${NODE_WS_URL:-wss://eth-mainnet.g.alchemy.com/v2}/${NODE_API_KEY:-''}

contracts:
  eth_usdt:
    kind: evm
    address: 0xdac17f958d2ee523a2206206994597c13d831ec7
    typename: eth_usdt

indexes:
  eth_usdt_events:
    kind: evm.events
    datasources:
      - subsquid
      - etherscan
      - evm_node
    handlers:
      - callback: on_transfer
        contract: eth_usdt
        name: Transfer

Datasources

DipDup indexes for EVM networks use Subsquid Network as a main source of historical data. EVM 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 evm.subsquid and evm.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 evm.node datasources attached to index, DipDup will use random one for each request.

Help and tips -> Join our Discord
Ideas or suggestions -> Issue Tracker
GraphQL IDE -> Open Playground
Table of Contents