Skip to content

An indexer for multi-chain transaction history in Polkadot.

License

Notifications You must be signed in to change notification settings

TalismanSociety/txhistory-squid

Repository files navigation

txhistory-squid

Talisman

squid-link

An indexer for multi-chain transaction history in Polkadot.
Running on 🔥🦑.

Handy resources

How to set up a development environment

Requirements

  • node 16.x
  • docker
  • npm -- note that yarn package manager is not supported

Example commands below use make(1). Please, have a look at the commands in the Makefile if your platform doesn't support it. On Windows we recommend to use WSL.

# Install the project dependencies
npm ci

# Start the postgres database
make up

# Run the query and processor nodes (in dev mode)
make dev

Dev flow

1. Define database schema

Start development by defining the schema of the target database via schema.graphql. Schema definition consists of regular graphql type declarations annotated with custom directives. Full description of schema.graphql dialect is available here.

2. Generate TypeORM classes

Mapping developers use TypeORM entities to interact with the target database during data processing. All necessary entity classes are generated by the squid framework from schema.graphql. This is done by running make codegen command.

3. Generate database migration

All database changes are applied through migration files located at db/migrations. squid-typeorm-migration(1) tool provides several commands to drive the process. It is all TypeORM under the hood.

# Connect to database, analyze its state and generate migration to match the target schema.
# The target schema is derived from entity classes generated earlier.

# Create template file for custom database changes
make create-migration

# Apply database migrations from `db/migrations`
make migrate

Deploy the Squid

Subsquid offers a free hosted service for deploying your Squid. First, build and run the docker image locally and fix any errors or missing files in Dockerfile:

make dev

After the local run, obtain a deployment key by signing into Aquarium and run

npx sqd auth -k YOUR_DEPLOYMENT_KEY

Next, inspect the Squid CLI help to deploy and manage your squid:

npx sqd squid --help

For more information, consult the Deployment Guide.

License

txhistory-squid is GPL 3.0 licensed.