built by Citizen Web3 for ValidatorInfo
CDI is organized as a branch-based monorepo: each network indexer lives in its own branch, while companion services, such as API wrappers, live in dedicated branches next to the indexers.
| Network | Branch | Status | Purpose |
|---|---|---|---|
| Cosmos Hub | main |
β Production | Cosmos Hub indexer with Protobuf decoding, transaction parsing, PostgreSQL storage, and metrics |
| AtomOne | atomone-indexer |
β Production | AtomOne mainnet indexer with governance, IBC packets, staking, and PostgreSQL storage |
| Aztec Protocol | aztec |
β Production | Aztec indexer stack for explorer and analytics workloads |
| Logos | logos-indexer-v0.1.2 |
π§ Development | Logos testnet indexer with canonical-chain, finality, transaction, and explorer API data |
| Monero | monero-indexer |
π§ Development | Monero indexer for blocks, transactions, supply checkpoints, health, metrics, and explorer APIs |
| Polygon Miden | miden-indexer-v0.13.4 |
π§ Development | Polygon Miden indexer with HTTP API, observability, and PostgreSQL storage |
| Component | Branch | Status | Purpose |
|---|---|---|---|
| Cosmos Indexer API | cosmos-indexer-api |
API wrapper | Read-only Next.js API over the Cosmos Hub indexer PostgreSQL database |
| AtomOne Indexer API | atomone-indexer-api |
API wrapper | Read-only Next.js API over the AtomOne indexer PostgreSQL database |
Each branch contains network-specific configuration, schemas, and documentation. The instructions below are for the Cosmos Hub indexer in
main.
- Repository Map
- Cosmos Hub Indexer
- Features
- Architecture
- Requirements
- Installation
- Quick Start
- Configuration
- Usage
- Makefile Shortcuts
- Troubleshooting
- Development Notes
- Contributing
- License
The main branch contains the production Cosmos Hub implementation of Chain Data Indexer (CDI).
It extracts, processes, and stores Cosmos Hub blockchain data in PostgreSQL for block explorers, analytics platforms,
DeFi dashboards, compliance tools, and research projects.
- π§ Primary Use Case: Powering block explorers with rich, searchable blockchain data.
- π Extensible: Suitable for analytics, compliance, DeFi, R&D, and more.
- π Multi-Network: CDI also includes separate branches for AtomOne, Aztec, Logos, Monero, and Polygon Miden indexers.
Note: The features below are specific to the Cosmos Hub indexer. For other networks, please refer to the respective branch documentation.
- π High Performance: Efficiently processes large volumes of blocks and transactions.
- π Resumable Indexing: Smart resumption from the last indexed block to prevent data loss.
- π³ Dockerized: Simple deployment with Docker Compose.
- ποΈ PostgreSQL Integration: Robust, scalable storage with partitioning and indexing.
- π Advanced Decoding: Supports rich message/transaction type extraction.
- β‘ Real-time Capable: Block-by-block processing with adjustable concurrency.
- π Modular Branches: Each supported network can be developed and maintained independently.
- RPC Client: Interfaces with blockchain RPC endpoints.
- Message Decoder: Dynamically generates message type definitions for supported chains.
- Database Layer: Optimized PostgreSQL schema with automatic partitioning.
- Configuration System: Environment-based, validated configuration.
- Node.js (v22+ recommended or v22.18.0 LTS for the best experience)
- yarn
- Docker & docker-compose
git clone https://github.com/citizenweb3/indexer.git
cd indexeryarn install --frozen-lockfile-
Copy and configure your environment:
cp .env.example .env # Edit .env as needed -
Build and start all services:
docker compose --env-file .env up --build -d
-
View indexer logs:
docker compose logs -f indexer
By default, the indexer will resume from the last processed block (
RESUME=true) and use Postgres as the sink.
docker compose down -vdocker compose --env-file .env up -d dbAll configuration is managed through environment variables.
See .env.example for a complete list.
| Variable | Description | Example |
|---|---|---|
| PG_HOST | PostgreSQL host | localhost |
| PG_PORT | PostgreSQL port | 5432 |
| PG_USER | PostgreSQL user | blockchain |
| PG_PASSWORD | PostgreSQL password | password |
| PG_DATABASE | PostgreSQL database name | indexerdb |
| RPC_URL | Blockchain RPC endpoint | https://rpc.cosmoshub-4-archive.citizenweb3.com |
| SINK | Data sink type | postgres |
| RESUME | Resume from last indexed block | true |
| PG_BULK_MODE | Drop indexes + UNLOGGED partitions for fast backfill (auto-restored on follow) | true |
| HEALTH_PORT | TCP port for /health and /metrics endpoints |
3000 |
| HEALTH_STALE_SECONDS | Block-progress freshness threshold | 180 |
| METRICS_ENABLED | Expose Prometheus /metrics on HEALTH_PORT |
true |
| METRICS_SAMPLE_INTERVAL_MS | Sampler refresh interval (pg pool, decode pool, chain tip) | 5000 |
| LOG_FORMAT | pretty (default, human-readable) or json (Loki/ELK) |
pretty |
| NODE_OPTIONS | Node.js runtime options | --max-old-space-size=24576 |
For fresh bulk backfills on a new PostgreSQL volume, you can skip the heaviest secondary indexes during init and rebuild them after the range finishes.
Start a fixed backfill window with deferred heavy indexes:
INDEXER_RESTART_POLICY=no \
PG_DEFER_HEAVY_INDEXES=on \
RESUME=false \
FROM=9000000 \
TO=9002499 \
docker compose --env-file .env.production up --build -dAfter the range finishes, stop the indexer, bring the database back up if needed, and rebuild the skipped indexes:
docker compose --env-file .env.production up -d db
make rebuild-heavy-indexesThis mode does not change indexed row content. It only removes selected heavy secondary indexes from the write path during the backfill.
-
Install dependencies:
yarn install --frozen-lockfile
-
Create a
.envfile:cp .env.example .env # Edit as necessary -
Generate runtime artifacts:
npx tsx scripts/gen-known-msgs.ts
-
Run Postgres (via Docker):
make up
-
Start the indexer:
yarn start
Need more memory?
export NODE_OPTIONS=--max-old-space-size=24576
make upβ Start db via docker-composemake downβ Stop servicesmake resetβ Remove volumes and re-init DBmake logsβ Show DB logs (docker compose --env-file .env logs -f db)make psqlβ Execpsqlinside the Postgres containermake psql-file FILE=path/to/script.sqlβ Copy and run a SQL file inside the DB containermake rebuild-heavy-indexesβ Recreate heavy secondary indexes skipped by bulk backfill mode
- Indexer fails due to memory? Increase
NODE_OPTIONS. - Check your
.envfor correct DB and RPC settings. - Use
make resetto reinitialize your database if needed. - Container keeps exiting? Check
curl http://127.0.0.1:${HEALTH_PORT:-3000}/healthanddocker inspect cosmos-indexer-app --format '{{.State.Health.Status}}'. See the Monitoring & Maintenance section in DEPLOYMENT.md. - Need Prometheus metrics or log shipping?
curl http://127.0.0.1:${HEALTH_PORT:-3000}/metricsfor thecdi_*series, setLOG_FORMAT=jsonfor structured logs, and use the reference collector configs indocs/observability/(Grafana Alloy or classic Prometheus + Promtail). - RPC archive node temporarily unavailable? The indexer now waits and resumes
automatically (no crash loop) β see logs for
[rpc] startup: RPC unavailable/RPC is available again.
- Runs TypeScript directly via
tsxduring development. - No tests by default; please add smoke tests for core logic changes.
- See Makefile and Docker Compose files for advanced operations.
Contributions are welcome!
Open issues/PRs for improvements, bug fixes, or new features.
For significant changes, please open an issue to discuss your ideas first.
BE GOOD License for details.