Open source Ponder based indexer
We provide an open source Ponder Indexer service that indexes and processes comments from the EVM-compatible blockchains. It provides REST API endpoints that allow clients to efficiently query and access the indexed comment data.
Overview
The ECP Indexer monitors CommentManager
contract events for comment-related activities and processes them into a queryable database. It supports the following features:
- Indexes comments from ECP smart contracts
- Processes comment metadata and content
- Maintains relationships between comments (replies, threads)
- Provides REST API endpoints for querying indexed comments
Free Hosted Indexer
We are running a free hosted version of this indexer at https://api.ethcomments.xyz. If you are an enterprise user of the API please consider self hosting - we may throttle this API.
Links
- API endpoints
- Restful API reference and playground
- OpenAPI spec
- GraphQL references and playground
- Source code
Self hosting the Indexer
Clone the repo from the Source code
Prerequisites
- Node.js + pnpm
- Access to an Ethereum node (e.g., Infura)
- PostgreSQL database - SQLite will be used if not provided
Installation
- Clone the repository
- Install dependencies:
pnpm install
- Set up environment variables in
.env.local
for local development:
cp .env.example .env.local
- Configure your database and Ethereum node connection in
.env.local
Start development server
pnpm run dev
Start production server
pnpm run start
Deployment on Railway
To deploy indexer to Railway, follow the below steps:
- Create a new Railway project and connect it to your GitHub repository.
- Create a new PostgreSQL database and connect it to the project via
DATABASE_URL
environment variable reference or connect it to your own PostgreSQL database. - Configure the following environment variables:
DATABASE_URL
: PostgreSQL connection stringPONDER_RPC_URL_[chain id]
: Ethereum node RPC URL for the chain you want to index, you can add multiple RPC URLs for different chains.PONDER_START_BLOCK_[chain id]
: Block number for indexer to start from (default to 0).
Nixpacks on Railway by default uses npm
to install dependencies. The ECP repo uses pnpm
instead. If you want dependency consistency, to make Railway respect the pnpm
lock files when installing dependencies, follow these steps (larger deployment size and longer deployment time):
- Configure the below environment variables to use
pnpm
:NIXPACKS_INSTALL_CMD
: set value topnpm install --frozen-lockfile
to use pnpm to install dependencies.NIXPACKS_BUILD_CMD
: set value topnpm run build
to tell nixpacks to use pnpm to build.NIXPACKS_START_CMD
: set value tocd apps/indexer/ && pnpm run start --schema $RAILWAY_DEPLOYMENT_ID
to start indexer.
If you don't mind dependency consistencies but prefer faster and smaller deployment, you can do the following:
- Select the Railway project and then click "Add Root Directory", set the root directory to
apps/indexer
. - Under deploy section, configure "Custom start command" to
npm run start --schema $RAILWAY_DEPLOYMENT_ID