Indexing a Tanssi Network with SQD¶
Introduction¶
SQD is a data network that allows rapid and cost-efficient retrieval of blockchain data from 100+ chains using SQD's decentralized data lake and open-source SDK. In simple terms, SQD 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. SQD 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 Squid project and configure it to index data on a Tanssi-powered network. There is one section catered towards Substrate networks and another towards EVM networks. However, if you're building on an EVM network, you may also reference the Substrate section, if you also need to index Substrate data.
For a more comprehensive end-to-end tutorial for EVM networks, be sure to check out the Indexing ERC-20 Transfers on a Tanssi EVM Network tutorial.
Checking Prerequisites¶
For the examples in this guide, you will need to have the following:
Index a Tanssi Substrate Network¶
To get started indexing Substrate data on your Tanssi-powered network, you'll need to create a Squid project and configure it for your network by taking the following steps:
-
Create a Squid 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 Getting started: Substrate chains guide on SQD's documentation site.
-
Navigate into the root directory of your Squid project and install dependencies by running
npm ci
-
Modify the
src/processor.ts
file to set the data source to the RPC URL of your Tanssi network. Remove thearchive: lookupArchive
line as a Squid archive will not be used. Here, you'll need to specify the RPC URL of your Tanssi Substrate network, as the endpoint is used to ingest chain dataconst processor = new EvmBatchProcessor(); processor.setDataSource({ chain: 'INSERT_RPC_URL', })
-
Launch Postgres by running
sqd up
-
Inspect and run the processor
sqd process
-
Open a separate terminal window in the same directory, then start the GraphQL server
sqd serve
-
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 Squid project to index Substrate data on your Tanssi-powered Substrate network! 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!
Index a Tanssi EVM Network¶
To get started indexing EVM data on a Tanssi-powered EVM network, you'll need to create a Squid project and configure it for your network by taking the following steps:
-
You can create a Squid 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 SQD docs:
-
Navigate into the root directory of your Squid project and install dependencies by running
npm ci
-
Modify the
src/processor.ts
file to set the data source to the RPC URL of your Tanssi network. Remove thearchive: lookupArchive('eth-mainnet')
line as a Squid archive will not be used. Here, the RPC URL of the demo EVM network is specified. The Squid project will use the RPC endpoint to ingest the relevant dataconst processor = new EvmBatchProcessor(); processor.setDataSource({ chain: 'INSERT_RPC_URL', })
Note
To try this out on the demo EVM network, you can use the following RPC URL:
https://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network
-
Launch Postgres by running
sqd up
-
Inspect and run the processor
sqd process
-
Open a separate terminal window in the same directory, then start the GraphQL server
sqd serve
-
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 Substrate 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 Squid project to index EVM data on your Tanssi-powered EVM network! 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 Tanssi network, you can check out the Indexing ERC-20 Transfers on a Tanssi EVM Network tutorial!
| Created: March 11, 2024