NG
SubQuery

SubQuery

Setup Guide

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

If you have any error, try to do the following:

  1. Open the docker-compose.yml
  2. 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:

SubQuery-0

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:

SubQuery-2

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:

SubQuery-3

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:

SubQuery-4

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:

SubQuery-5

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-6

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-7

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-8

SubQuery-9

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

SubQuery-10

SubQuery-11

Then go to the SubQuery Explorer:

SubQuery-12

Send a request:

SubQuery-13

Delete your project:

SubQuery-14
These are all the available tasks at the moment.

Stuck? Ask!

By continuing to use our website, you consent to our use of cookies in accordance with our cookie policy