Avalanche Quick Start

SubQuery TeamAbout 6 min

Avalanche Quick Start

In this Quick start guide, we're going to start with a simple Avalanche starter project and then finish by indexing some actual real data. This is an excellent basis to start with when developing your own SubQuery Project.

If your are looking for guides for Substrate/Polkadot, you can read the Substrate/Polkadot specific quick start guide.

At the end of this guide, you'll have a working SubQuery project running on a SubQuery node with a GraphQL endpoint that you can query data from.

If you haven't already, we suggest that you familiarise yourself with the terminology used in SubQuery.

The goal of this quick start guide is to index all Pangolin token Approve logs, it should only take 10-15 minutes

Preparation

Local Development Environment

Install the SubQuery CLI

Install SubQuery CLI globally on your terminal by using NPM:

# NPM
npm install -g @subql/cli

Please note that we DO NOT encourage the use of yarn global for installing @subql/cli due to its poor dependency management which may lead to an errors down the line.

You can then run help to see available commands and usage provide by CLI

subql help

Initialise the SubQuery Starter Project

Inside the directory in which you want to create a SubQuery project, simply run the following command to get started.

subql init

You'll be asked certain questions as the SubQuery project is initalised:

  • Project Name: A name for your SubQuery project
  • Network Family: The layer-1 blockchain network family that this SubQuery project will be developed to index, use the arrow keys on your keyboard to select from the options, for this guide we will use "Avalanche"
  • Network: The specific network that this SubQuery project will be developed to index, use the arrow keys on your keyboard to select from the options, for this guide we will use "Avalanche"
  • Template: Select a SubQuery project template that will provide a starting point to begin development, we suggest selecting the "Starter project"
  • Git repository (Optional): Provide a Git URL to a repo that this SubQuery project will be hosted in (when hosted in SubQuery Explorer)
  • RPC endpoint (Required): Provide a HTTPS URL to a running RPC endpoint that will be used by default for this project. This RPC node must be an archive node (have the full chain state). For this guide we will use the default value "avalanche.api.onfinality.io"
  • Authors (Required): Enter the owner of this SubQuery project here (e.g. your name!)
  • Description (Optional): You can provide a short paragraph about your project that describe what data it contains and what users can do with it
  • Version (Required): Enter a custom version number or use the default (1.0.0)
  • License (Required): Provide the software license for this project or accept the default (Apache-2.0)

After the initialisation process is complete, you should see a folder with your project name has been created inside the directory. The contents of this directoy should be identical to what's listed in the Directory Structure.

Last, under the project directory, run following command to install the new project's dependencies.

::: code-tabs @tab:active yarn shell cd PROJECT_NAME yarn install