Skip to content
/ indexer Public

Indexing solution, using Subsquid, for the Enjin Blockchain (Relaychain and Matrixchain).

License

Notifications You must be signed in to change notification settings

enjin/indexer

Repository files navigation

Enjin Indexer: Relaychain & Matrixchain

Enjin Logo

GitHub Actions Workflow Status GitHub package.json dynamic Discord GitHub Org's stars YouTube Enjin Blog


Introduction

The Enjin Blockchain Indexer is a Squid Indexer that serves processed blockchain data for other applications and dApps that require a more performant approach to retrieve the data as well as filtering, sorting, and relationships.

What is a Squid?

A squid is a project that extracts and transforms on-chain data to present it as a GraphQL API. Squids are developed using the Subsquid SDK, which provides extensive tooling to define data schemas, data transformation rules, and the shape of the resulting API.

We recommend that you read SubSquid docs to understand how it works: https://docs.subsquid.io/

Prerequisites

  • Node 20.x
  • PNPM 8.x
  • PostgreSQL 16.x
  • Redis 7.x

Or you can use Docker with the provided docker-compose file to start all services.

Quick-start (using Docker)

  1. Clone the repository
  2. Run docker compose up -d
  3. Access the GraphiQL Playground at http://localhost:4000/graphql

Architecture

The indexer is composed of four containers

  1. indexer_db — a postgres database that stores the processed data;
  2. indexer_redis — a redis instance used for cache and queue;
  3. indexer_processor — the worker that transforms and saves the blockchain data;
  4. indexer_graphql — the GraphQL API that exposes the processed data;
  5. indexer_worker — the queue worker that processes the metadata of assets.

Metadata

The chain metadata is used to generate the interface classes through typegen. To scan the blockchain and get all the metadata ever used, you can use the following command:

pnpm run metadata:fetch

This indexer works with all Enjin networks, so make sure you always save the metadata from all of them before generating the typegen.

Typegen

The typegen tool is used for generating TypeScript interface classes for Substrate events, calls, and storage. To generate it, first you should merge both metadata from Enjin Matrixchain and Canary Matrixchain into a single file. Then you can use the following command:

pnpm run metadata:typegen

Codegen

The codegen tool is used for generating the model classes based on the GraphQL schema. If you edit the schema.graphql you should regenerate it by running:

pnpm run schema:codegen

Migrations

When the schema is changed, we need to make a new migration. For development purposes the simplest way is to drop the database and generate the migrations from scratch. To do that, after you are finished editing the schema.graphql file and have generated all model files. You might run:

pnpm run db:generate
pnpm run db:migrate

About

Indexing solution, using Subsquid, for the Enjin Blockchain (Relaychain and Matrixchain).

Topics

Resources

License

Stars

Watchers

Forks

Contributors 13