Skip to content

Indexing Your EVM ContainerChain with Subsquid

Introduction

Subsquid is a data network that allows rapid and cost-efficient retrieval of blockchain data from 100+ chains using Subsquid’s decentralized data lake and open-source SDK. In simple terms, Subsquid can be thought of as an ETL (extract, transform, and load) tool with a GraphQL server included. It enables comprehensive filtering, pagination, and even full-text search capabilities. Subsquid has native and full support for both EVM and Substrate data, even within the same project.

This quick-start guide will show you how to create a Subsquid project and configure it to index data on your Tanssi EVM ContainerChain. For a more comprehensive end-to-end tutorial, be sure to check out Using Subsquid to Index Your ContainerChain.

Checking Prerequisites

For the examples in this guide, you will need to have the following:

Index EVM Data on Your ContainerChain

To get started indexing EVM data on your Tanssi EVM, you'll need to create a Subsquid project and configure it for your ContainerChain by taking the following steps:

  1. You can create a Subsquid project for EVM data by using the generic EVM template or you can use the ABI template for indexing data related to a specific contract:

    sqd init INSERT_SQUID_NAME --template evm
    
    sqd init INSERT_SQUID_NAME --template abi
    

    For more information on getting started with both of these templates, please check out the following Subsquid docs:

  2. Navigate into the root directory of your Squid project and install dependencies by running:

    npm ci
    
  3. Modify the src/processor.ts file to set the data source to the RPC URL of your ContainerChain. Remove the archive: lookupArchive('eth-mainnet') line as a Squid archive will not be used. Here, the RPC URL of the demo EVM ContainerChain is specified. The Squid project will use the RPC endpoint to ingest the relevant data

      const processor = new EvmBatchProcessor();
      processor.setDataSource({
        chain: 'https://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network',
      })
    
  4. Launch Postgres by running:

    sqd up
    
  5. Inspect and run the processor:

    sqd process
    
  6. Open a separate terminal window in the same directory, then start the GraphQL server:

    sqd serve
    
  7. You can now run queries, such as the sample query below, against your Squid on the GraphQL playground at http://localhost:4350/graphql. If you've modified the template EVM squid to index different data, you'll need to modify this query accordingly

    query MyQuery {
      burns(orderBy: value_DESC) {
        address
        block
        id
        txHash
        value
      }
    }
    

And that's all you have to do to configure your Subsquid project to index EVM data on your Tanssi EVM ContainerChain! Now you can update the schema.graphql, src/main.ts, and src/processor.ts files to index the data you need for your project!

If you're interested in a more comprehensive step-by-step tutorial to get started indexing data for your ContainerChain, you can check out the Using Subsquid to Index Your ContainerChain tutorial!

The information presented herein has been provided by third parties and is made available solely for general information purposes. Tanssi does not endorse any project listed and described on the Tanssi Doc Website (https://docs.tanssi.network/). Tanssi Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Tanssi Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Tanssi Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Tanssi Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Tanssi Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
Last update: January 16, 2024
| Created: December 1, 2023