Skip to content

About

Quantus blockchain indexer

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Substrate Indexer Setup Guide

This guide will help you set up and run a Subsquid-based indexer for a Substrate chain. The indexer tracks balance transfers and can be extended to track other events and calls.

Prerequisites

  • Node.js (v16 or later)
  • Docker

Setup

  1. Install dependencies:
npm install

Install sqd command line

npm install -g @subsquid/cli
  1. Create a .env file in the root directory with your RPC endpoint:
RPC_ENDPOINT=ws://localhost:9944  # For local node
# or
RPC_ENDPOINT=wss://your-testnet-endpoint  # For testnet
  1. Generate types and code for your chain:
sqd typegen
sqd codegen
sqd build

Running the Indexer

InitialSchema1790849787837 replaces InitialSchema1790651935090. TypeORM records applied migrations by name, so a database from the previous migration still looks pending. sqd migration:apply and sqd run refuse to continue while indexer tables are already present. Drop that database and reindex. The processor rebuilds chain totals from chain history.

Clean reindex (required for a database created by an earlier migration):

sqd down
sqd up
sqd migration:apply
sqd run

sqd down removes the local Postgres container. docker-compose-dev.yml does not mount a data volume, so the next sqd up is an empty database.

Resume when InitialSchema1790849787837 is already applied:

sqd up
sqd run

Start the processor and GraphQL API:

sqd run

If you only want to start the processor but not the rest of the system, use this instead

sqd process

Development

  • The processor configuration is in src/processor.ts
  • The GraphQL schema is in schema.graphql
  • The database migrations are in db/migrations

Current Features

  • Tracks balance transfers
  • Stores transfer amounts, fees, and account information
  • Provides GraphQL API for querying the indexed data

Reversible Transfers

This indexer also tracks the full lifecycle of reversible transfers:

  • Scheduled: When a new reversible transfer is created.
  • Executed: When a scheduled transfer is successfully completed.
  • Cancelled: When a scheduled transfer is cancelled before execution.

The indexer creates or updates ReversibleTransfer entities in the database and creates a single Event entity when a transfer is first scheduled.

Querying Data

The GraphQL server provides a flexible API for querying the indexed data. Here are a few examples:

Extending

To add new events or calls to track:

  1. Update the processor configuration in src/processor.ts
  2. Update the GraphQL schema in schema.graphql
  3. Generate new migrations:
sqd migration:generate

Troubleshooting

If you encounter issues:

  1. Make sure Docker is running
  2. Check that your RPC endpoint is correct in .env
  3. Drop the database and reindex:
sqd down
sqd up
sqd migration:apply
sqd run

In case we need to redo this - how to create a new subsquid project

  1. Install Subsquid CLI globally:
npm install -g @subsquid/cli
  1. Initialize a new Subsquid project:
sqd init substrate-indexer --template substrate
cd substrate-indexer

Additional Resources

For more detailed information about the project structure and advanced features, please refer to the original README in the substrate-indexer directory.

License

[Add your license information here]

About

Quantus blockchain indexer

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages