npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

create-substreams-sink-sql

v1.0.3

Published

Scaffold a Substreams SQL sink for PostgreSQL — zero custom code needed

Downloads

375

Readme

create-substreams-sink-sql

Scaffold a Substreams SQL sink for PostgreSQL in one command.

New to Substreams? Each scaffolded project includes a TUTORIAL.md covering concepts, setup, finding packages with substreams-search-mcp, multi-chain usage, and troubleshooting.

Usage

# Create a new project
npm init substreams-sink-sql my-sink

# Or use npx
npx create-substreams-sink-sql my-sink

# Or scaffold in current directory
npx create-substreams-sink-sql .

What You Get

my-sink/
├── substreams.yaml      # Sink config — imports .spkg, defines sink type
├── schema.sql           # PostgreSQL DDL — tables, indexes, types
├── docker-compose.yml   # Postgres 16 + pgweb for local dev
├── Makefile             # Automation: pack, setup, dev, run, reset
├── .env.example         # Configuration template
├── .gitignore
└── TUTORIAL.md          # Complete beginner's tutorial

Quick Start

npm init substreams-sink-sql my-sink
cd my-sink
cp .env.example .env     # Add your SUBSTREAMS_API_TOKEN
make up                  # Start Postgres + pgweb
make setup               # Create tables
make dev                 # Stream data
# Browse data at http://localhost:8081

How It Works

Substreams .spkg (db_out module)
  → substreams-sink-sql (StreamingFast CLI tool)
  → PostgreSQL
  → Query with any SQL client / pgweb UI

No custom sink code needed — substreams-sink-sql handles streaming, cursor management, reorg handling, and database writes.

Prerequisites

  1. substreams CLIInstall guide
  2. substreams-sink-sqlbrew install streamingfast/tap/substreams-sink-sql
  3. Docker — For running Postgres locally
  4. Substreams API token — Get one at app.pinax.network or app.streamingfast.io

Using Your Own Substreams

The template ships with substreams-eth-block-meta as an example. To use your own:

1. Update substreams.yaml

Change the imports section to point to your .spkg:

imports:
  spkg: https://spkg.io/your-org/your-substreams-v1.0.0.spkg

2. Write schema.sql

Create tables matching your Substreams db_out output:

CREATE TABLE IF NOT EXISTS erc20_transfers (
    block_num       INTEGER NOT NULL,
    tx_hash         TEXT NOT NULL,
    log_index       INTEGER NOT NULL,
    contract        TEXT NOT NULL,
    "from"          TEXT NOT NULL,
    "to"            TEXT NOT NULL,
    amount          NUMERIC NOT NULL,
    timestamp       TIMESTAMP NOT NULL,
    PRIMARY KEY (block_num, tx_hash, log_index)
);

3. Run it

make setup   # Apply new schema
make dev     # Stream data

Makefile Commands

| Command | Description | |---------|-------------| | make help | Show all available commands | | make up | Start Postgres + pgweb | | make down | Stop Docker services | | make pack | Pack manifest into .spkg | | make setup | Create system tables + apply schema.sql | | make dev | Run sink in dev mode (short block range) | | make run | Run sink in production mode (live streaming) | | make reset | Drop and recreate all tables | | make clean | Remove .spkg files |

Common Endpoints

| Chain | Endpoint | |-------|----------| | Ethereum | eth.substreams.pinax.network:443 | | Polygon | polygon.substreams.pinax.network:443 | | Arbitrum | arb-one.substreams.pinax.network:443 | | Base | base-mainnet.substreams.pinax.network:443 | | BSC | bsc.substreams.pinax.network:443 |

Full list: Chains & Endpoints

Find Substreams Packages

Browse available .spkg files at substreams.dev. Look for packages with a db_out module.

For AI-assisted discovery, install substreams-search-mcp — it lets tools like Claude search the Substreams registry directly. See the scaffolded TUTORIAL.md for setup instructions.

License

MIT