Using with AI
The fastest way to get an AI coding agent productive on a Pipes SDK project is to install the official Pipes SDK Agent Skill:- Portal MCP server: 31 tools for querying blocks, transactions, logs, instructions, and analytics across 110+ datasets.
- Documentation MCP server — search and retrieve these docs from inside the agent.
llms.txt (index) and llms-full.txt (full content) files are kept in sync with the site. See the AI Development overview for the full menu.
Scaffolding with Pipes CLI
Pipes CLI and Pipes UI publish the 1.0 line under the npm
beta tag, so the commands below pin @beta for those two packages. Without the pin, npm serves an older 1.0 alpha that does not accept the config shown here. @subsquid/pipes itself installs the 1.0 line by default, no tag needed.Prerequisites
- Node.js 22.15+
pnpm- Docker (for the bundled PostgreSQL container)
Initialize the project
Run the CLI in the directory where you want the project folder to land:pnpm for now), target database (ClickHouse or PostgreSQL), network type, default network, and one or more templates; each template then asks for its own parameters (e.g. contract deployments and block ranges). It then writes a runnable project and installs dependencies.
You can supply a JSON config instead of filling the prompts manually. Here’s the configuration for Orca Whirlpool swap instructions mentioned above:
--config also accepts a path to a JSON file. Each contract is described by one or more deployments (address + block range), and the root defaultNetwork applies to all of them.
The config schema is published at cdn.subsquid.io/schemas/pipes_cli_config.json; to print it locally run
pipes.config.json in the project folder. To change the generated code later, edit that file and re-run
.env.
Run the pipeline
The generated project includes adocker-compose.yml that brings up the target database and the pipeline together:
orca_whirlpool_swap table within a minute.
What was generated
The project layout:orca-example
migrations
src
contracts
utils
index.ts
index.ts
schemas.ts
.env
.gitignore
AGENTS.md
biome.json
docker-compose.yml
Dockerfile
drizzle.config.ts
package.json
pipes.config.json
pnpm-lock.yaml
pnpm-workspace.yaml
README.md
tsconfig.json
src/index.ts: the pipe, with its stream, decoder, and target.src/schemas.ts: Drizzle table definitions.src/contracts/: generated ABI bindings, one folder per program ID.src/utils/index.ts: theenrichEventshelper thatsrc/index.tsuses to turn decoded instructions into rows. It needs a one-line fix, described in the warning below.migrations/: SQL migrations generated by drizzle-kit.AGENTS.md: instructions for coding agents working on the project.docker-compose.yml: Postgres and an optional pipeline service.pipes.config.json: the resolved CLI config. Edit it and re-runinitto regenerate the project..env:DB_CONNECTION_STR, which points at the local Postgres.
src/index.ts. The decoder block defines what to extract + a light transform:
swap instructions on the Orca Whirlpool program. enrichEvents (from src/utils/) reshapes each decoded instruction into a row matching the Drizzle table. See the Pipe anatomy and Handling instructions guides for more info on solanaInstructionDecoder().
The generated code passes programId, which still works but is deprecated since 1.0.0-beta.9. In new code, pass the program’s typegen module as program instead. See the decoder reference.
The main() function wires the decoder to a drizzleTarget:
id is a per-pipeline identifier (the CLI generates a random one). Keep it stable so the target’s cursor survives restarts. See Pipe anatomy for how the pieces fit together.
Other examples
Token balances
Token balances
The
tokenBalances template indexes pre/post token balances directly from blocks, with no program ID needed. The generated pipe uses solanaQuery() instead of an instruction decoder.tokenBalances, plus the open-ended custom template shown at the top of the page.