Polkadot Quick Start

SubQuery Team約6分

Polkadot Quick Start

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

このガイドの最後には、SubQuery ノード上で動作する SubQuery プロジェクトを作成し、GraphQL エンドポイントからデータを照会できるようになります。

まだの方は、SubQuery で使われている用語に慣れることをお勧めします。

The goal of this quick start guide is to adapt the standard starter project to begin indexing all transfers from Polkadot, it should only take 10-15 minutes

準備

ローカル開発環境

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 errors down the line.

You can then run help to see available commands and usage provided by the 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 project 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 to select from the available options. For this guide, we will use "Substrate"
  • Network: The specific network that this SubQuery project will be developed to index. Use the arrow keys to select from the available options. For this guide, we will use "Polkadot"
  • Template project: Select a SubQuery template project that will provide a starting point to begin development. We suggest selecting the "subql-starter" project.
  • RPC endpoint: Provide an HTTPS URL to a running RPC endpoint that will be used by default for this project. You can quickly access public endpoints for different Polkadot networks, create your own private dedicated node using OnFinalityopen in new window or just use the default Polkadot endpoint. This RPC node must be an archive node (have the full chain state). For this guide, we will use the default value "https://polkadot.api.onfinality.io"
  • Git repository: Provide a Git URL to a repo that this SubQuery project will be hosted in (when hosted in SubQuery Explorer) or accept the provided default.
  • Authors: Enter the owner of this SubQuery project here (e.g. your name!) or accept the provided default.
  • Description: Provide a short paragraph about your project that describes what data it contains and what users can do with it or accept the provided default.
  • Version: Enter a custom version number or use the default (1.0.0)
  • License: Provide the software license for this project or accept the default (MIT)

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

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

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