π Subquery indexer for the OKP4 protocol.
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.
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 |
Be sure to have the following properly installed:
- Node.js
v18.18
(Hydrogen) - yarn
v1.22
- Docker
- subql-cli
v3.2.0
- Install SubQuery CLI globally on your terminal by using NPM (we don't recommend using Yarn to install global dependencies):npm install -g @subql/cli@3.2.0
π Install the dependencies:
yarn
Generate the types:
yarn prepack
π³ 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.
π Run the project with the default stack:
yarn start:docker
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
}
}
}
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.
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
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.
Please check out OKP4 health files :