Skip to content

Contracts

The list of contracts to index for this indexer.

name

This is the name of the contract to index, it will use this name on the database on tables it generates, alongside on generated rust code if you are using the rust project.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
   - name: RocketPoolETH

details

The details for the contract mapping to the network and contract address.

network

The network name to listen for events on, this should match the network name in the networks section of the YAML.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum

address

The contract address to listen for events on.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"

To listen to many contract addresses you can provide an array of addresses.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address:
          - "0xae78736cd615f374d3085123a210448e74fc6393"
          - "0x2FD5c1659A82E87217DF254f3D4b71A22aE43eE1"

filter

If you wish to filter based on events only for example you want all transfer events from all contracts you can use the filter.

event_name

The event name to filter on, it must match the ABI event name.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: ERC20Transfer
    details:
      - network: ethereum
        filter: 
          event_name: Transfer

Index more then 1 filter for the contract

You can just pass in an array of events names to index on the filter.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: ERC20
    details:
      - network: ethereum
        filter: 
          - event_name: Transfer
          - event_name: Approval

indexed_1, indexed_2, indexed_3

Indexed means that these values will be stored in the topics field rather than the data field when the event gets fired off and you can filter these out on the JSONRPC side so you only get the events you want.

In EVM you can have up to 3 indexed fields to filter on. The indexed 1,2,3 are based on the order they emitted in the event. So if you have 3 indexed fields in the event you can filter on all 3 or 2 or 1 of them in any direction. Indexed fields are arrays so you can filter many values in the indexed fields, the arrays are OR not AND filtering.

example ABI:

{
    "anonymous":false,
    "inputs":[
      {
        "indexed":true, 
        "internalType":"address",
        "name":"owner",
        "type":"address"
      },
      {
        "indexed":true, 
        "internalType":"address",
        "name":"spender",
        "type":"address"
      },
      {
        "indexed":false, 
        "internalType":"uint256",
        "name":"value",
        "type":"uint256"
      }
    ],
    "name":"Approval", 
    "type":"event"
}

So this ABI says that the inputs owner and spender are indexed and can be filtered on. value is not indexed so you can not filter on it.

For example if you wanted to get all the approvals for rETH for owner 0xd87b8e0db0cf9cbf9963c035a6ad72d614e37fd5 and 0x0338ce5020c447f7e668dc2ef778025ce398266b you could set the indexed filters like so:

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
   - name: RocketPoolETH
     details:
       - network: ethereum
         address: "0xae78736cd615f374d3085123a210448e74fc6393"
         indexed_filters: 
           - event_name: Approval
             indexed_1:
               - "0xd87b8e0db0cf9cbf9963c035a6ad72d614e37fd5"
               - "0x0338ce5020c447f7e668dc2ef778025ce398266b"

Another example using filters is if you wanted to get all the approvals for any token for owner 0xd87b8e0db0cf9cbf9963c035a6ad72d614e37fd5 and 0x0338ce5020c447f7e668dc2ef778025ce398266b you could set the indexed filters like so:

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
   - name: RocketPoolETH
     details:
       - network: ethereum
         filter:
            event_name: Approval
         indexed_filters: 
           - event_name: Approval
             indexed_1:
               - 0xd87b8e0db0cf9cbf9963c035a6ad72d614e37fd5
               - 0x0338ce5020c447f7e668dc2ef778025ce398266b

start_block

The block to start indexing from, you can use the deployed block if you wish to get everything.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000

end_block

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056

Multiple Networks

You can have multiple networks for the same contract, this is useful if you have a contract that is deployed on multiple networks.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks: 
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
  - name: base
    chain_id: 8453
    rpc: https://base.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details: 
    - network: ethereum
      address: "0xae78736cd615f374d3085123a210448e74fc6393"
      start_block: 18600000
      end_block: 18718056
    - network: base
      address: "0xba25348cd615f374d3085123a210448e74fa3333"
      start_block: 18118056
      end_block: 18918056

abi

The ABI of the contract pointing to the JSON file in the repository. It can be a relative path or a full path.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json

Many ABIs

If you need to use many ABIs in the single contract you can pass in an array this is useful if you have a contract which has several different implementations ABIs.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
  - name: ethereum
    chain_id: 1
    rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: 
      - ./abis/RocketTokenRETH.abi.json
      - ./abis/RocketTokenRETH2.abi.json

include_events

The events you wish to include in the indexer.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
  chain_id: 1
  rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json
    include_events:  
      - Transfer
      - Approval

index_event_in_order

rindexer was built to be as fast as it can so any blocking processes holds indexing up, the more concurrency the better. Any events which you wish to index in the order the events were emitted on that event in the contract can be put in this list.

The more you put in here the slower the indexer will be as it will have to wait for the previous events to be indexed before it can index the next events.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
  chain_id: 1
  rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json
    include_events:
      - Transfer
      - Approval
    index_event_in_order: 
      - Transfer
      - Approval

dependency_events

rindexer was built to be as fast as it can so any blocking processes holds indexing up, the more concurrency the better. Any events which depend on each other can be put in the dependency_events list, this will mean that they will be processes in the order they are in the list.

  • events = process these events
  • then = after you processed the events above process these events

If you do not put an event in the dependency_events events then it will be deemed a non-blocking event and will be processed as soon as it can.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
  chain_id: 1
  rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json
    include_events:
      - Transfer
      - Approval
    dependency_events: 
      events:
        - Transfer
      then:
        events:
          - Approval

Cross Contract Dependency Events

You can also define dependency events blocking across contracts, this is useful if you have many contracts which emit data but are dependent on each other.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
  chain_id: 1
  rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: WrappedRocketPoolETH
    details:
      - network: ethereum
        address: 0x2FD5c1659A82E87217DF254f3D4b71A22aE43eE8
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/WrappedRocketTokenRETH.abi.json
    include_events: 
    - Approval
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json
    include_events:
      - Transfer
    dependency_events: 
      events:
        - Transfer
      then:
        events:
          - contract_name: WrappedRocketPoolETH
            event_name: Approval

So now WrappedRocketPoolETH > Approval will not be processed until RocketPoolETH > Transfer is processed.

reorg_safe_distance

Reorgs can happen on the chain, this is when a block is removed from the chain and replaced with another block. This can cause issues with the indexer indexed state if you turn reorg_safe_distance on it will keep a safe distance from the live latest block to avoid any reorg issues.

Note if you are doing live indexing you will need to handle more advanced reorgs, support for advanced reorgs is in the backlog for rindexer.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
  chain_id: 1
  rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json
    include_events:
      - Transfer
      - Approval
    reorg_safe_distance: true

generate_csv

If you wish to generate a CSV file of the indexed data you can turn this on. This will be ignored if you do not have the CSV storage enabled. By default if this is not supplied and the CSV storage is enabled it will generate a CSV file.

rindexer.yaml
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
  chain_id: 1
  rpc: https://mainnet.gateway.tenderly.co
storage:
  postgres:
    enabled: true
contracts: 
  - name: RocketPoolETH
    details:
      - network: ethereum
        address: "0xae78736cd615f374d3085123a210448e74fc6393"
        start_block: 18600000
        end_block: 18718056
    abi: ./abis/RocketTokenRETH.abi.json
    include_events:
      - Transfer
      - Approval
    generate_csv: true

streams

You can configure streams to stream the data to other services, this is useful if you want to use other services to index the data. You can read more about it here.

chat

You can configure chat to send messages You can read more about it here.