This project purpose is to aggregate events from the Substrate-based blockchain and provide GraphQL API enpoint for accessing on chain historic data, events and calls. Project uses Subsquid squid technology, for more information see Subsquid documentation.
npm i -g @subsquid/cli@latest
sqd --version
sqd init <project-name> --template substrate
npm i
sqd up
model
files, v1
and events
: Workflow section, parts 1 and 3.sqd process
sqd serve
/graphql
endpoint on the port prompted by sqd serve
schema.graphql
file, instruction on defining entities may be found under this Subsquid documentation page.
To map changes from schema.graphql
to the codebase (files inside /model/generated
) call sqd codegen
method, delta between current state of database and state of the model
is represented by the migration file - new one must be generated after each change made to the model (using sqd migration:generate
command).commands.json
file/types
directory there are generated classes that represent access API for the Substate chain metadata:
to update those files after chain node change call generate .jsonl
file by running: squid-substrate-metadata-explorer --chain <url> --out <file>
where in <url>
write chain node url and in <file>
output destination and name of your .jsonl
file (by relation to the root project directory).
Next call sqd typegen <file>
.BatchContext.store
TypeormDatabase
member. General info about using TypeormDatabase
is available here.
For advanced query operations see this documentation page.Squid tools assume a certain project layout.
lib
and all TypeScript sources in src
.
The layout of lib
must reflect src
.src/model/index.ts
(lib/model
module).schema.graphql
.db/migrations
and must be plain js files.squid-*(1)
executables consult .env
file for a number of environment variables.See the full description in the documentation.