Awesome
Project Setup
Prerequisites
- Node >=20
- Nvm
- Install SubSquid CLI:
npm i -g @subsquid/cli@latest
-
Install Docker Desktop
-
Install PgAdmin 4
-
Register on Dwellir to get a
CHAIN_RPC_ENDPOINT
URL (It supports most chains) -
Make a new
.env
file (Copy.env.example
)
Run the project
- Build:
sqd build
- Build the DB:
sqd up
- Run:
sqd process
TIPS
If you're using VSCode - Enable format on save with Prettier
On code change, to apply changes:
sqd build && sqd process
PgAdmin 4 Configuration
To connect locally to the DB when you register a new DB, you need to configure the following:
Name: DB_NAME
Host name/address: localhost
Port: DB_PORT
Password: DB_PASS
Development (Example - Subject to change)
Adding a new chain
- Go to chain/ and create a new folder with the chain name
- Create a metadata.json file with the pallets that will be used (Refer to template folder)
- Run
sqd typegen
- to generate class types for the chain - Go to chain/{chainName}/ and create a decoders folder inside with events and calls subfolders (Refer to the templates folder)
- Implement the pallet calls and events decoding in the corresponding folders (Refer to the templates folder)
Adding a new pallet (Example with current structure - subject to change)
- Figure out pallet flow
- Create a new schema and Update the main one
- Apply migration
- Import in registry.ts the Handlers
- Implement each pallet action in the indexer/actions folder (Could split the code in the actions folder)
- Update generateSchema.ts to support the new changes
Deployment to the cloud
When deploying changes to the cloud you need to use the deploy.sh
script The script uses the manifest.yaml
file of the chain you want to deploy to the cloud to do several things
- Dynamically generates the
schema.graphql
. - Generates a migration.
- Deploys the newly changed files to the cloud.
- After the deployment is done it removes the changed files, so that local development is not affected.
For more info check deploy.sh and the corresponding files.