# Install @subsquid/cli - the `sqd` command globally
npm i -g @subsquid/cli
# Install dependencies
npm ci
sqd typegen
yarn codegen && yarn migration:generate
yarn setup && yarn process:lrt
sqd serve
With sqd serve
a GraphiQL playground will be available at localhost:4350/graphql.
BLOCK_FROM=18421105 yarn process:lrt # Start processing at block 18421105
BLOCK_TO=18421105 yarn process:lrt # Process up to block 18421105
Start development by defining the schema of the target database via schema.graphql
.
Schema definition consists of regular graphql type declarations annotated with custom directives.
Full description of schema.graphql
dialect is available here.
Mapping developers use TypeORM EntityManager
to interact with target database during data processing. All necessary entity classes are
generated by the squid framework from schema.graphql
. This is done by running yarn codegen
command.
All database changes are applied through migration files located at db/migrations
.
There is only ever one migration.
yarn migration:generate
See docs on database migrations for more details.
It is necessary to import the respective ABI definition to decode EVM logs. One way to generate a type-safe facade class
to decode EVM logs is by placing the relevant JSON ABIs to ./abi
, then using squid-evm-typegen(1)
via an sqd
script:
sqd typegen
See more details on the squid-evm-typegen
doc page.
Squid tools assume a certain project layout:
- All compiled js files must reside in
lib
and all TypeScript sources insrc
. The layout oflib
must reflectsrc
. - All TypeORM classes must be exported by
src/model/index.ts
(lib/model
module). - Database schema must be defined in
schema.graphql
. - Database migrations must reside in
db/migrations
and must be plain js files. sqd(1)
andsquid-*(1)
executables consult.env
file for environment variables.
- Visit Squid deploy dashboard
- Auth with
sqd auth -k sqd_XXX
(key is on squid deploy page) - Update
squid.yaml
to set the correct version - Run
sqd deploy .
- Make branch for new version (eg v9) and push to origin
- Switch back to main branch