Skip to content

subsquid-labs/starknet-example

Repository files navigation

starknet-example

This project shows how one can index USDC transfers on Starknet using Subsquid SDK.

About SDK

Subsquid SDK is a TypeScript ETL toolkit for blockchain data, that currently supports

  • Ethereum and everything Ethereum-like
  • Substrate-based chains
  • Solana
  • Tron
  • Fuel
  • Starknet

Subsquid SDK stands apart from the competition by

  • Being a toolkit (rather than an indexing app like TheGraph or Ponder)
  • Fast binary data codecs and type-safe access to decoded data
  • Native support for sourcing the data from Subsquid Network.

The latter is a key point, as Subsquid Network is a decentralized data lake and query engine, that allows to granularly select and stream subset of block data to lightweight clients while providing game changing performance over traditional RPC API.

Getting started

Prerequisites

  • Node.js (version 20.x and above)
  • Docker

Run indexer

# Install dependencies
npm i

# Compile the project
npx tsc

# Launch Postgres database to store the data
docker compose up -d

# Apply database migrations to create the target schema
npx squid-typeorm-migration apply

# Run indexer
node -r dotenv/config lib/main.js

# Checkout indexed swaps
docker exec "$(basename "$(pwd)")-db-1" psql -U postgres \
  -c "SELECT block, from, to, value FROM exchange ORDER BY id LIMIT 10"

For further details, please consult heavily commented main.ts.

For even more details, see Starknet Indexing Docs.

About

Starknet data indexing example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published