/ Docs
7.5
/
Table of Contents

EVM node

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

DipDup can connect to any EVM-compatible node via JSON-RPC. It can be used as a "last mile" datasource for EVM indexes (data that is not in Subsquid Network yet) or as a standalone datasource for handlers and hooks.

The example below shows how to connect to Alchemy nodes for Ethereum mainnet indexes. You can also use your own node, but make sure it has all the necessary data (e.g. archive node).

dipdup.yaml
datasources:
  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:-''}

If you want to use the node as a last-mile datasource for EVM indexes, you should link it to the evm.subsquid definition.

dipdup.yaml
datasources:
  subsquid:
    kind: evm.subsquid
    url: ${SUBSQUID_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
    node: evm_node

node field could also be a list of datasources; DipDup will use the random one for each request.

web3 client

web3.py is a popular Python library for interacting with Ethereum nodes. Every node datasource has a web3 client instance attached to it. You can use it in handlers and hooks to fetch data from the node and perform other actions.

Warning
Don't initialize web3 clients manually! It will break the connection pooling, lock the event loop, and kill your dog.

To access the client, use web3 property of the datasource. The underlying web3 client is asynchronous, so you should use await keyword to call its methods.

web3: AsyncWeb3 = ctx.get_evm_node_datasource('evm_node').web3
contract = self.web3.eth.contract(...)
symbol = await contract.functions.symbol().call()

Each datasource has its own web3 client instance, so you can use it safely in parallel. web3 clients respect http configuration from the datasource config when making requests.

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