Nodes

guruGuru
search

SubQuery - Setup Guide

Back to projectRU
Stuck? AsktelegramNodes Guru telegram community

Rent on

This guide looks at completing tasks rather than raising a node. These tasks are necessary to participate in the Ambassador Program.
To access the tasks register via link, the tasks will be available at portal. Submit your results to form. You can only send the first two modules at this time.

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

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:

Subquery-1

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:

Module_1_Exercise_0

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:

Module_2_Exercise_1

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:

Module_3_Exercise_1

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:

Module_3_Exercise_2

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:

Module_3_Exercise_3

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:

Subquery-5-1

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:

Subquery-5-2

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:

SubQuery-Module-5-1

SubQuery-Module-5-2

In the GitHub repository input field, specify your repository from the first module:

SubQuery-Module-5-3

SubQuery-Module-5-4

Then go to the SubQuery Explorer:

SubQuery-Module-5-6

Send a request:

SubQuery-Module-5-7

Delete your project:

SubQuery-Module-5-8
These are all the available tasks at the moment.