This squid tracks the events of the Groups and Smart Contract Hub smart contracts on Aleph Zero and serves them via graphql API.
- Node.js
- Docker
- @subsquid/cli
npm i -g @subsquid/cli
# 1. Install dependencies
npm ci
# 2. Start a Postgres database container and detach
sqd up
# 3. Start the processor
sqd process
# 4. Start the graphql server in a new tab
sqd serve
# 5. Access via http://localhost:4350/graphql
Update squid.yaml and deploy as per this.
# add --hard-reset if you want to drop and re-create all the squid resources including the database.
sqd deploy --org btngroup ../squid-smart-contract-hub
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 sqd codegen
command.
All database changes are applied through migration files located at db/migrations
.
squid-typeorm-migration(1)
tool provides several commands to drive the process.
## drop create the database
sqd down
sqd up
## replace any old schemas with a new one made from the entities
sqd migration:generate
See docs on database migrations for more details.
npx squid-ink-typegen --abi abi/az_groups.json --output src/abi/az_groups.ts
npx squid-ink-typegen --abi abi/az_smart_contract_hub.json --output src/abi/az_smart_contract_hub.ts
npm run lint