Skip to content

subsquid-labs/squid-substrate-templates

Repository files navigation

Templates for Substrate squids

This repository is a collection of simple Subsquid-based indexers ("squids") for scraping blockchain data from Substrate-based chains such as Polkadot, Kusama, Moonbeam, Astar, Shibuya etc. They are useful as starting points for new projects indexing the following:

  • substrate - for all projects involving Substrate
  • ink - Ink!-based WASM contracts, supported e.g. by Astar and Shibuya networks
  • frontier-evm - chains with Frontier EVM support (Moonbeam, Moonriver, Shiden, Astar)

To begin using these templates, install the sqd excutable:

npm install -g @subsquid/cli@latest

Next, fetch the chosen template to a new project folder using sqd init:

sqd init <new-project-name> -t <substrate|ink|frontier-evm>

You now have a copy of the chosen squid template sitting at the <new-project-name> folder.

Starting the squid

All Substrate squid templates are complete simple squids. They can run locally immediately upon being downloaded, provided that sqd and Docker are available.

The "processor" process is present in all squids. It downloads pre-filtered blockchain data from Subsquid Archives, applies any necessary transformations and saves the result in an application-appropriate storage. All template squids store their data to a Postgresql database and provide a way to access it via a GraphQL API.

To start the processor, run

cd <new-project-name>
npm ci
sqd build
sqd up # starts a Postgres database in a Docker container
sqd process

Processor should now be running in foreground, printing messages like

01:02:37 INFO  sqd:processor 234354 / 16519081, rate: 17547 blocks/sec, mapping: 2420 blocks/sec, 2945 items/sec, ingest: 794 blocks/sec, eta: 16m

The extracted data will begin accumulating in the database available at localhost:23798 (consult the template's .env file for login and password). If you want to access it via GraphQL, run

sqd serve

in a separate terminal in the <new-project-name> folder. Graphical query builder will be available at http://localhost:4350/graphql.

Further reading

About

Squid templates for Substrate networks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published