Skip to content

Indexing Your Substrate 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 Substrate 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 Substrate Data on Your ContainerChain

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

  1. Create a Subsquid project based on the Substrate template by running:

    sqd init INSERT_SQUID_NAME --template substrate
    

    For more information on getting started with this template, please check out the Quickstart: Substrate chains guide on Subsquid's documentation site.

  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 line as a Squid archive will not be used. Here, you'll need to specify the RPC URL of your Tanssi Substrate ContainerChain, as the endpoint is used to ingest chain data

      const processor = new EvmBatchProcessor();
      processor.setDataSource({
        chain: 'https://fraa-dancebox-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 query your template Substrate Squid with the below sample query. If you've modified the template Substrate squid to index different data, you'll need to modify this query accordingly

    query MyQuery {
      accountsConnection(orderBy: id_ASC) {
        totalCount
      }
    }
    

And that's all you have to do to configure your Subsquid project to index Substrate data on your Tanssi Substrate ContainerChain! Now you can update the schema.graphql, src/main.ts, typegen.json, 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