Skip to main content

SDK Overview

A squid is an indexing project built with Squid SDK to retrieve and process blockchain data from the SQD Network. The Squid SDK is a set of open-source TypeScript libraries that retrieve, decode, transform, and persist blockchain data.
All stages of the indexing pipeline—from data extraction to transformation to persistence—are performed on batches of blocks to maximize indexing speed.
The modular architecture of the SDK makes it possible to extend indexing projects (squids) with custom plugins and data targets.

Required squid components

Processor

A processor is the main component of your squid. The term refers to both:
  1. The main Node.js process of the squid
  2. The main object (processor) of this process, where processor.run() is the entry point
processor objects handle data retrieval and transformation; data persistence is handled by a separate object called Store.

For Substrate chains

Use SubstrateBatchProcessor via the @subsquid/substrate-processor NPM package for Substrate-based networks like Polkadot and Kusama.
Unlike EVM chains, Substrate chains require an RPC endpoint for metadata retrieval, in addition to the SQD Network gateway.

Store

A store is an object that processors use to persist their data. SQD offers three store classes:

TypeORM Store (PostgreSQL)

Use TypeormStore for saving data to PostgreSQL. Requires three packages:

File Store

Use file-store via @subsquid/file-store for saving data to filesystems. This is a modular system with a variety of extensions for various formats and destinations.

BigQuery Store

Use bigquery-store via @subsquid/bigquery-store for saving data to Google BigQuery.
You can mix and match any store class with any processor class.

Optional squid components

Typegen

A typegen is a tool for generating utility code for technology-specific operations such as decoding.

For Substrate chains

Use squid-substrate-typegen via @subsquid/substrate-typegen to generate type-safe interfaces for:
  • Substrate events
  • Extrinsics (calls)
  • Storage items
  • Runtime constants
Install typegen packages with --save-dev as they are only needed during development.

Types Bundle

For Substrate chains with metadata version below 14, you may need a types bundle to properly decode historical data.

GraphQL server

Squids that store their data in PostgreSQL can make it available as a GraphQL API via a variety of supported servers. See Serving GraphQL. SQD provides its own server called OpenReader via the @subsquid/graphql-server package. The server runs as a separate process with these features:

Squid CLI

Squid CLI is a utility for managing your squid development workflow:
  • Retrieve squid templates
  • Manage chains of commands commonly used in development
  • Run all squid processes at once
  • Deploy to SQD Cloud