Rent server onSponsored
Preparing
Use our script to install you need for further work:
wget -q -O subquery.sh https://api.nodes.guru/subquery.sh && chmod +x subquery.sh && sudo /bin/bash subquery.sh
After successful execution of the script will be installed:
- NodeJS
- NPM
- Yarn
- Docker
- Docker Compose
If you have any error, try to do the following:
- Open the docker-compose.yml
- Replace --local with --db-schema=app
Now all should works correctly.
Module 1
Execute the command:
cd $HOME
subql init --starter hello-world
All fields can be left as default (just press Enter), but you need to fill out the Authors field:
Execute the following commands:
cd hello-world
yarn install
yarn codegen
yarn build
docker-compose pull
docker-compose up -d
Now you have to wait for everything to load and for the node to synchronize a few blocks (usually a few minutes), then enter the command:
echo "http://"$(curl -s ifconfig.me)":3000"
Click on the link that appears in the console, you should open the GraphQL panel.
In the GraphQL panel enter the following query:
{
query {
starterEntities(first: 10) {
nodes {
field1
}
}
}
}
Send a request, the result should be something like this:
Upload your hello-world folder as a repository to GitHub, and provide a link to that repository in the form.
Stop the container:
cd $HOME/hello-world
docker-compose stop
Module 2
Exercise 1
Execute the following commands:
cd $HOME
git clone https://github.com/subquery/tutorials-account-balances.git
cd tutorials-account-balances
yarn
yarn codegen
yarn build
docker-compose pull
docker-compose up -d
Now you have to wait for everything to load and for the node to synchronize a few blocks (usually a few minutes), then enter the command:
echo "http://"$(curl -s ifconfig.me)":3000"
Click on the link that appears in the console, you should open the GraphQL panel.
In the GraphQL panel enter the following query:
query {
accounts(first:15, orderBy:BALANCE_ASC){
nodes{
account
balance
}
}
}
Send a request, the result should be something like this:
Upload your tutorials-account-balances folder as a repository to GitHub, and provide a link to that repository in the form.
Stop the container:
cd $HOME/tutorials-account-balances
docker-compose stop
Module 3
Exercise 1
Execute the following commands:
cd $HOME
git clone https://github.com/subquery/tutorials-account-transfers
cd tutorials-account-transfers
yarn
yarn codegen
yarn build
docker-compose pull
docker-compose up -d
Now you have to wait for everything to load and for the node to synchronize a few blocks (usually a few minutes), then enter the command:
echo "http://"$(curl -s ifconfig.me)":3000"
Click on the link that appears in the console, you should open the GraphQL panel.
In the GraphQL panel enter the following query:
query {
transfers(first: 5, orderBy:AMOUNT_DESC) {
nodes {
id
amount
blockNumber
to {
id
}
}
}
}
Send a request, the result should be something like this:
Stop the container:
cd $HOME/tutorials-account-transfers
docker-compose stop
Exercise 2
Execute the following commands:
cd $HOME
git clone https://github.com/subquery/tutorials-council-proposals
cd tutorials-council-proposals
yarn
yarn codegen
yarn build
docker-compose pull
docker-compose up -d
Now you have to wait for everything to load and for the node to synchronize a few blocks (usually a few minutes), then enter the command:
echo "http://"$(curl -s ifconfig.me)":3000"
Click on the link that appears in the console, you should open the GraphQL panel.
In the GraphQL panel enter the following query:
query {
councillors(first: 5, orderBy: NUMBER_OF_VOTES_DESC) {
nodes {
id
numberOfVotes
voteHistory(first: 3) {
totalCount
nodes {
approvedVote
}
}
}
}
}
Send a request, the result should be something like this:
Stop the container:
cd $HOME/tutorials-council-proposals
docker-compose stop
Exercise 3
Execute the following commands:
cd $HOME
git clone https://github.com/subquery/tutorials-account-transfer-reverse-lookups.git
cd tutorials-account-transfer-reverse-lookups
yarn
yarn codegen
yarn build
docker-compose pull
docker-compose up -d
Now you have to wait for everything to load and for the node to synchronize a few blocks (usually a few minutes), then enter the command:
echo "http://"$(curl -s ifconfig.me)":3000"
Click on the link that appears in the console, you should open the GraphQL panel.
In the GraphQL panel enter the following query:
query{
accounts(first:5){
nodes{
id
myToAddress{
nodes{
id
amount
}
}
}
}
}
Send a request, the result should be something like this:
Stop the container:
cd $HOME/tutorials-account-transfer-reverse-lookups
docker-compose stop
Module 4
Exercise 1
Execute the following commands:
cd $HOME
git clone https://github.com/subquery/tutorials-simple-aggregation.git
cd tutorials-simple-aggregation
yarn
yarn codegen
yarn build
docker-compose pull
docker-compose up -d
Now you have to wait for everything to load and for the node to synchronize a few blocks (usually a few minutes), then enter the command:
echo "http://"$(curl -s ifconfig.me)":3000"
Click on the link that appears in the console, you should open the GraphQL panel.
In the GraphQL panel enter the following query:
query {
sumRewards(first: 10) {
nodes {
id
accountReward
createdAt
blockheight
}
}
}
Send a request, the result should be something like this:
Send another request with a specific address:
query {
sumRewards(
first: 10
filter: {
id: { equalTo: "1122SWicp7esoyo1h2jjzKbSiQ4j18XP6fd98DSFgVjERQyC" }
}
) {
nodes {
id
accountReward
createdAt
blockheight
}
}
}
Send a request, the result should be something like this:
Stop the container:
cd $HOME/tutorials-simple-aggregation
docker-compose stop
Module 5
In this module, you need to deploy your project in the SubQuery Explorer.
Go here and login via GitHub:
In the GitHub repository input field, specify your repository from the first module:
Then go to the SubQuery Explorer:
Send a request:
Delete your project: