The Starter Package is an example that you can use as a starting point for developing your SubQuery project. A SubQuery package defines which data The SubQuery will index from the Substrate blockchain, and how it will store it.
-
Typescript are required to compile project and define types.
-
Both SubQuery CLI and generated Project have dependencies and require Node.
Install SubQuery CLI globally on your terminal by using NPM:
npm install -g @subql/cli
Run help to see available commands and usage provide by CLI
subql help
Inside the directory in which you want to create the SubQuery project, simply replace project-name
with your project name and run the command:
subql init --starter project-name
Then you should see a folder with your project name has been created inside the directory, you can use this as the start point of your project. And the files should be identical as in the Directory Structure.
Last, under the project directory, run following command to install all the dependency.
yarn install
To add a new network to your SubQuery project, follow these steps:
-
Create a Project YAML File:
- Create a new file named
project-{name}.yaml
in the root directory of your project. - This file will contain the configuration specific to the new network.
- Create a new file named
-
Set Network Data:
- In the newly created
project-{name}.yaml
file, set the network parameters such asendpoint
,genesisHash
, and other relevant details.
- In the newly created
-
Add Separate Mapping:
- Create a new mapping file in the src/mappings/ directory, named
{name}.ts
. - This file should include the necessary handlers and logic for the new network.
- Create a new mapping file in the src/mappings/ directory, named
-
Include Genesis, DIRECT_STAKING_TYPE, and RewardCurveConfig:
- In your new mapping file, ensure you define the
genesis
,DIRECT_STAKING_TYPE
, andrewardCurveConfig
specific to the new network.
- In your new mapping file, ensure you define the
-
Export in
src/index.ts
:- Update the src/index.ts file to export the new handlers from your
{name}.ts
mapping file.
- Update the src/index.ts file to export the new handlers from your
-
Add Network Types:
- If the new network requires custom types, add them to the
chainTypes
section in the appropriate configuration file. Do not forget to add new exports in package.json
- If the new network requires custom types, add them to the
-
Update
@subquery-multichain.yaml
:- Add the new project file to the
projects
array in subquery-multichain.yaml.
- Add the new project file to the
By following these steps, you can extend your SubQuery project to support additional networks.
In order to index your SubQuery project, it is mandatory to build your project first. Run this command under the project directory.
yarn codegen
In order to deploy your SubQuery project to our hosted service, it is mandatory to pack your configuration before upload.
Run pack command from root directory of your project will automatically generate a your-project-name.tgz
file.
yarn build
Under the project directory run following command:
docker-compose pull && docker-compose up
Open your browser and head to http://localhost:3000
.
Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query.
For the subql-starter
project, you can try to query with the following code to get a taste of how it works.
{
query {
starterEntities(first: 10) {
nodes {
field1
field2
field3
field4
}
}
}
}
SubQuery staking is available under the MIT license. See the LICENSE file for more info. © Novasama Technologies GmbH 2023