Prerequisites
- Node.js 20 or newer
- Git
- Docker with Compose
1
Install the Squid CLI
@subsquid/cli/<version>.2
Scaffold the current EVM template
evm alias is maintained by the CLI. It currently retrieves subsquid-labs/squid-evm-template.The project has this layout:hello-squid
abi
db
src
abi
main.ts
model
generated
index.ts
.env
.squidignore
commands.json
docker-compose.yml
package.json
schema.graphql
squid.yaml
tsconfig.json
src/main.ts: the data source and the batch handler.schema.graphql: the data model.sqd codegengenerates the TypeORM classes insrc/model/generated/from it.commands.json: the scripts behindsqd build,sqd up, andsqd down.squid.yaml: the manifest thatsqd run .starts.db/migrations/: database migrations, applied before the processor starts.abi/: the place for contract ABI JSON files.sqd typegengenerates TypeScript modules from them insrc/abi/.
3
Build the project
build in commands.json. The command generates JavaScript in lib/ and stops on TypeScript errors.4
Start PostgreSQL
.env.5
Run the processor and GraphQL server
squid.yaml.
The processor command applies pending database migrations before it starts.The template’s src/main.ts builds a data source with DataSourceBuilder from @subsquid/evm-stream, requesting transactions sent to the zero address:src/main.ts
run() call from @subsquid/batch-processor then drives the batch handler, which turns each transaction into a Burn entity and inserts the batch through ctx.store. The Portal stream covers real-time data as well, all the way to the unfinalized chain head — no additional endpoints are needed.6
Query indexed data
Open Stop the CLI with
http://localhost:4350/graphql and run:Ctrl+C. Remove the local database container with:What to change next
- Edit the
DataSourceBuilderconfiguration insrc/main.tsto select the transactions, logs, traces, or state diffs your application needs. Remember to extend the field selection with every field your handler reads. - Edit
schema.graphql, then runsqd codegenandsqd migration:generateafter model changes. - Indexing a network without a Portal dataset? Build the source with the EVM RPC source instead. For resilience to endpoint outages, combine Portal and RPC with the EVM fallback source — see High availability.
- Migrating an existing pre-Portal squid instead? Follow the Portal migration guide.