Run a local indexer

Install Indexer

Have yarn installed, docker, and docker-compose installed and running on your machine.

Installation process

git clone https://github.com/capsule-corp-ternoa/ternoa-subql.git
cd ternoa-subql
git checkout alphanet
yarn install
yarn codegen
yarn build

Every time the graphQl Schema changes, you need to run the yarn codegen command. Every time the code changes, you need to build it again with the yarn build command. Now everything is built, you can launch it with docker.

docker-compose pull
docker-compose up

docker-compose pull needs to be run to pull the last version and does not need to be run again unless you change any docker image.

After a few seconds, the indexing starts. You can see in the shell every block indexed. To check the blockchain data stored, run a query in your local graphql playground in a browser (default localhost:3000).

Common errors on containers start

Database connection failed

The subquery-node container tends to be ready before the Postgres one. No worries, it will automatically restart until the database is ready.

Outdated .data

Remember to delete the .data folder at root on the network changes. Also, make sure to use the correct network genesis hash in the project.yaml file.

Install Dictionary

Prerequisite: have yarn installed, docker, and docker-compose installed and running on your machine.

You can set up your own dictionary to define what data you want to record for the chain. The dictionary will be used by the indexer to get only blocks that match the defined filter (for example, you can index only NFTs-related transactions (extrinsic).

Check our repository here.

After a few seconds, the indexing starts. You can see in the shell every block indexed. To check the blockchain data stored, run a query in your local graphql playground in a browser (default localhost:3000).

Last updated