/ Docs
7.0
/
Table of Contents

EVM node

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 Archives yet) or as a standalone datasource for handlers and hooks.

Examples below show how to connect to Infura and 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:
  mainnet_alchemy_node:
    kind: evm.node
    url: https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}
    ws_url: wss://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}

EVM node datasources could linked to specific Subsquid ones instead of being used directly in indexes.

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

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('mainnet_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.

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