- files added to or deleted from storage worker reports;
- storage orders placed by accounts;
- storage groups joined by accounts.
Prerequisites
- Node.js 20 or newer
- Docker with Docker Compose
- An SQD Network API key
1
Scaffold the project with the latest CLI
Install the latest Squid CLI, then create a project from the Substrate template:Install the template dependencies and update the packages used in this tutorial to their latest releases:
2
Configure gateway and RPC access
Add your SQD Network API key and the Crust RPC URL to The API key authenticates requests to the v2 SQD gateway. The processor uses the RPC endpoint to obtain chain metadata.
.env:3
Define the entities
Replace Generate the TypeORM entity classes:
schema.graphql with the following schema:schema.graphql
4
Generate current Crust event types
Replace Run Substrate typegen:The generated wrappers reflect the actual Crust runtime types for each event.
typegen.json with this configuration:typegen.json
5
Configure the processor
Replace Selecting
src/processor.ts with the following code:src/processor.ts
call.args is required because the added and deleted file lists belong to the Swork.report_works call. The bounded range contains all three requested event types.To follow the chain continuously, remove the upper
to bound and
.setRpcDataIngestionSettings({disabled: true}). Keep a reliable RPC endpoint
configured for real-time ingestion.6
Decode and persist each event
Replace The generated byte values, including
src/main.ts with this batch handler:src/main.ts
fileCid, are already hex strings. They do not need another toHex() conversion.7
Build and prepare PostgreSQL
Build the project, start PostgreSQL, replace the template migration, and apply the new migration:
8
Run and verify the processor
Start the processor:The processor exits after block
589350. Query the stored row counts:This range produces 181 accounts, 178 group joins, 6 storage orders, and 1
work report containing a file change.
9
Query the GraphQL API