Skip to content

subsquid-labs/pipes-sdk-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipes SDK examples directory

Pipes SDK is a highly customizable blockchain indexing library made by SQD. This repo is a collection of various examples of its usage.

Basics

At src/basics folder of this repo you'll find a sequence of examples highlighting core concepts and basic functionality of the Pipes SDK. Follow BASICS.md to learn more.

Advanced

src/advanced contains examples showcasing the less common features. It significantly overlaps with the examples folder of the Pipes SDK package repo which doubles as a collection of ad-hoc tests. Here are some topics covered:

These should run in the same manner as basic examples do: start with BASICS.md/Quickstart then run the example files with bun or ts-node.

Postgres examples (11 and 12)

Examples 11 and 12 demonstrate two approaches to storing both transformer state and final data in the same PostgreSQL database using drizzleTarget.

Start Postgres:

docker compose up -d test_postgres

This starts a Postgres 17 instance on localhost:5432 (user: postgres, password: postgres, database: postgres). Wait for the healthcheck to pass before running the examples.

Schema / migrations:

Both examples call onStart to run CREATE TABLE IF NOT EXISTS statements when the indexer first connects. This is sufficient for running the examples as-is.

For production use, replace the onStart DDL with drizzle-kit migrations:

npx drizzle-kit generate   # generate SQL migration files from your schema
npx drizzle-kit migrate    # apply pending migrations

Run example 11 (stateless — reads state from Postgres each batch):

DB_URL=postgresql://postgres:postgres@localhost:5432/postgres \
npx ts-node src/advanced/evm/11.stateful-transforms-postgres-stateless.example.ts

Run example 12 (in-memory — loads state once at startup, updates in RAM):

DB_URL=postgresql://postgres:postgres@localhost:5432/postgres \
npx ts-node src/advanced/evm/12.stateful-transforms-postgres-in-memory.example.ts

Both examples index the SQD token on Arbitrum One and maintain a token_balances table (running ERC-20 balance per address) and a transfer_counts table (number of outbound transfers per address). They are interchangeable — the on-disk schema is identical; only the in-process state management differs.

Templates

A collection of Pipes SDK project intended as starting points:

Miscellaneous

These are related to the indexers that SQD uses internally:

Releases

No releases published

Packages

 
 
 

Contributors