evm.transactions
index
This index allows indexing EVM transactions and matching them with handlers by content. You can define handlers for multiple sets of filters. Only necessary transactions 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_transactions
.
spec_version: 3.0
package: demo_evm_transactions
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_transactions:
kind: evm.transactions
datasources:
- subsquid
- etherscan
- evm_node
handlers:
- callback: on_transfer
to: eth_usdt
method: transfer
first_level: 4634748
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.
Filters
Transactions can be filtered by one or more of the following fields:
name | description | supported | typed |
---|---|---|---|
from.address | Sender address | 🟢 | 🔴 |
to.address | Destination address | 🟢 | 🟢¹ |
method | Invoked contract method | 🟢 | 🟢¹ |
¹ both contract address and method need to be specified
Typed and untyped arguments
You will get slightly different callback argument types depending on whether the pattern item is typed or not. If both "to" and "method" filters are specified, DipDup will generate a typeclass for particular input from contract ABI. Otherwise, you will have to handle untyped input data stored in EvmTransactionData
and EvmTransactionData
models.