Hype Indexer
NEAR QueryAPI is currently under development. Users who want to test-drive this solution need to be added to the allowlist before creating or forking QueryAPI indexers.
You can request access through this link.
Overview
This indexer creates a new row in a pre-defined posts
or comments
table created by the user in the GraphQL database for every new post or comment found on the blockchain that contains either "PEPE" or "DOGE" in the contents. This is a simple example that shows how to specify two tables, filter blockchain transaction data for a specific type of transaction and its contents, and save the data to the database.
This indexer can be found by following this link.
Defining the Database Schema
The first step to creating an indexer is to define the database schema. This is done by editing the schema.sql
file in the code editor. The schema for this indexer looks like this:
CREATE TABLE
"posts" (
"id" TEXT NOT NULL,
"account_id" VARCHAR NOT NULL,
"block_height" DECIMAL(58, 0) NOT NULL,
"block_timestamp" DECIMAL(20, 0) NOT NULL,
"receipt_id" VARCHAR NOT NULL,
"content" TEXT NOT NULL,
CONSTRAINT "posts_pkey" PRIMARY KEY ("id")
);
CREATE TABLE
"comments" (
"id" SERIAL NOT NULL,
"post_id" TEXT NOT NULL,
"account_id" VARCHAR NOT NULL,
"block_height" DECIMAL(58, 0) NOT NULL,
"block_timestamp" DECIMAL(20, 0) NOT NULL,
"receipt_id" VARCHAR NOT NULL,
"content" TEXT NOT NULL,
CONSTRAINT "comments_pkey" PRIMARY KEY ("id")
);
This schema defines two tables: posts
and comments
. The posts
table has columns:
id
: a unique identifier for each row in the tableaccount_id
: the account ID of the user who created the postblock_height
: the height of the block in which the post was createdblock_timestamp
: the timestamp of the block in which the post was createdreceipt_id
: the receipt ID of the transaction that created the postcontent
: the content of the post
The comments
table has columns:
id
: a unique identifier for each row in the tablepost_id
: the ID of the post that the comment was made onaccount_id
: the account ID of the user who created the commentblock_height
: the height of the block in which the comment was createdblock_timestamp
: the timestamp of the block in which the comment was createdreceipt_id
: the receipt ID of the transaction that created the commentcontent
: the content of the comment
Defining the indexing logic
The next step is to define the indexing logic. This is done by editing the indexingLogic.js
file in the code editor. The logic for this indexer can be divided into two parts:
- Filtering blockchain transactions for a specific type of transaction
- Saving the data from the filtered transactions to the database