Skip to content

Smart Contract Indexer (Subsquid) of AZERO.ID

License

Notifications You must be signed in to change notification settings

azero-id/indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AZERO.ID – Subsquid Indexer

License: GPL v3 Typescript Subsquid

This repository contains an indexer for the smart contracts of AZERO.ID.

Development

Warning

Subsquid strictly requires npm to be used as the package manager. pnpm is not supported.

Prerequisites

# Install Node.js 18 & Docker

# Install Squid CLI
npm i -g @subsquid/cli

# Install local dependencies
npm install

# Copy & fill environments
cp .env.example .env

Index Live Node

To index a live network (e.g. Aleph Zero Testnet), a remote Subsquid Archive is queried from its registry. Therefore, make sure to set up the .env file accordingly.

Important

All tasks need to be run in different terminal windows.

# Start database (`sqd up`)
npm run start:squid

# Build & start processor (`sqd process`)
npm run codegen
npm run start:processor

# Serve GraphQL API (`sqd serve`)
npm run serve

If needed, clear all existing docker images via docker rm -f $(docker ps -a -q).

Advanced: Index Local Node

Warning

Due to its instant finality, substrate-contracts-node is not working currently. Use aleph-node instead.

To index a locally running node, it's necessary to run our own Subsquid Archive locally. This means running all of the following components in parallel:

  • Subsquid Archive (only for local nodes)
  • Subsquid Squid DB for Processor
  • Subsquid Processor
  • Subsquid GraphQL API

Important

All tasks need to be run in different terminal windows.

# Start archive
npm run start:archive

# Start database (`sqd up`)
npm run start:squid

# Build & start processor (`sqd process`)
npm run codegen
npm run start:processor

# Serve GraphQL API (`sqd serve`)
npm run serve

Deployment

The Squid is deployed to Subsquid Cloud (hosted service) for each live network.

Network Endpoint Manifest File
Aleph Zero Testnet https://squid.subsquid.io/azns-testnet/graphql squid.azns-testnet.yaml
Aleph Zero Mainnet https://squid.subsquid.io/azns-mainnet/graphql squid.azns-mainnet.yaml

Important

Each time, the version needs to be bumped manually in the respective manifest-file.

# Prerequisite: Install & authenticate Squid CLI
sqd auth -k <DEPLOYMENT_KEY>

# Bump version in manifest-file

# Deploy Squid (e.g. for Aleph Zero Testnet)
npm run deploy squid.azns-testnet.yaml
# OR: sqd deploy . -o azero-id -m squid.azns-testnet.yaml

# After successful initialization, optionally assign
# new squid to the respectove production endpoint.
sqd prod azns-testnet@v42

Other Resources