Skip to content

okp4/subql-okp4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

okp4 / subquery banner

SubQL-OKP4

πŸ” Subquery indexer for the OKP4 protocol.

release lint build test conventional commits contributor covenant typescript prettier license cc-by-sa-4.0

This repository is home to the OKP4 SubQuery Indexer, a tool that provides chain data from the OKP4 protocol via a GraphQL API. The project is based on SubQuery, an open-source tool that helps create fast and reliable APIs for blockchain applications.

Explore

The following services are available:

ChainID Service Endpoint
okp4-nemeton-1 Playground https://explorer.subquery.network/subquery/okp4/nemeton-1
okp4-nemeton-1 GraphQL https://api.subquery.network/sq/okp4/nemeton-1

Install

Prerequisites

Be sure to have the following properly installed:

Build

🚚 Install the dependencies:

yarn

Generate the types:

yarn prepack

Build Docker

🐳 Build the docker image:

docker build -t subql-okp4 .

Run it:

docker run -ti --rm --name my-indexer \
  -e DB_HOST=postgres \
  -e DB_PORT=5432 \
  -e DB_DATABASE=subql \
  -e DB_USER=subql \
  -e DB_PASS=secret \
  subql-okp4

Provide an alternate configuration:

docker run -ti --rm --name my-indexer \
  -e DB_HOST=postgres \
  -e DB_PORT=5432 \
  -e DB_DATABASE=subql \
  -e DB_USER=subql \
  -e DB_PASS=secret \
  -v /path/to/new-conf.yaml:/srv/subql/project.yaml \
  subql-okp4

Give additional arguments to the subql node:

docker run -ti --rm --name my-indexer \
  -e DB_HOST=postgres \
  -e DB_PORT=5432 \
  -e DB_DATABASE=subql \
  -e DB_USER=subql \
  -e DB_PASS=secret \
  subql-okp4 --batch-size=32 --log-level=debug

NOTE: To run the container in detached mode replace -it --rm by -d in the above commands.

Usage

Run

πŸš€ Run the project with the default stack:

yarn start:docker

Query

Open http://localhost:3000/ on your browser, and try the following query:

query {
  _metadata {
    chain
    lastProcessedHeight
    targetHeight
  }
}

You should get the following result:

{
  "data": {
    "_metadata": {
      "chain": "okp4-nemeton-1",
      "lastProcessedHeight": 2928706,
      "targetHeight": 2928706
    }
  }
}

Database

During development, it can be useful to access the database directly to inspect and understand the data indexed. The database is a PostgreSQL database, and it is run in a Docker container by the docker-compose command. Note that the database is contained in a Docker volume, so it will persist between runs.

CLI

You can access the PostgreSQL database via the following command:

psql -h localhost -p 5432 -U subql -d subql

The tables are in the app schema.

subql=> SET schema 'app';
SET
subql=> \dt
              List of relations
 Schema |        Name         | Type  | Owner
--------+---------------------+-------+-------
 app    | _metadata           | table | subql
 app    | blocks              | table | subql
 app    | messages            | table | subql
 app    | objectarium_objects | table | subql
 app    | transactions        | table | subql

Metabase

Since the project uses PostgreSQL to index the data, you can use Metabase to explore the database and create dashboards.

The docker-compose comes with a profile for Metabase. To start it, run:

docker-compose --profile metabase up

Then, open http://localhost:3001/ on your browser, and connect to the database with the information you can find in the .env file.

You want to get involved? 😍

Please check out OKP4 health files :

Useful Resources