Files
2026-03-02 12:14:09 -08:00

2.2 KiB

Quick Start Guide

Prerequisites

  1. Node.js 20+
  2. PostgreSQL 14+ with TimescaleDB extension
  3. Access to RPC endpoints for ChainID 138 and 651940

Quick Setup (5 minutes)

1. Install Dependencies

cd smom-dbis-138/services/token-aggregation
npm install

2. Configure Environment

cp .env.example .env
# Edit .env with your values

Minimum required in .env:

DATABASE_URL=postgresql://user:password@localhost:5432/explorer_db
CHAIN_138_RPC_URL=https://rpc-http-pub.d-bis.org
CHAIN_651940_RPC_URL=https://mainnet-rpc.alltra.global

3. Run Database Migration

# Navigate to explorer backend and run migration
cd ../../explorer-monorepo/backend
# Run migration 0011_token_aggregation_schema.up.sql

4. Build and Start

cd ../../smom-dbis-138/services/token-aggregation
npm run build
npm start

5. Verify

# Health check
curl http://localhost:3000/health

# Test API
curl http://localhost:3000/api/v1/chains

Docker Quick Start

# Build and run
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Development Mode

npm run dev

API Examples

Get token details

curl "http://localhost:3000/api/v1/tokens/0x93E66202A11B1772E55407B32B44e5Cd8eda7f22?chainId=138"

Get token pools

curl "http://localhost:3000/api/v1/tokens/0x93E66202A11B1772E55407B32B44e5Cd8eda7f22/pools?chainId=138"

Get OHLCV data

curl "http://localhost:3000/api/v1/tokens/0x93E66202A11B1772E55407B32B44e5Cd8eda7f22/ohlcv?chainId=138&interval=1h"

Search tokens

curl "http://localhost:3000/api/v1/search?q=USDT&chainId=138"

Troubleshooting

Database Connection Issues

  • Verify DATABASE_URL is correct
  • Ensure PostgreSQL is running
  • Check TimescaleDB extension is enabled

RPC Connection Issues

  • Test RPC endpoints manually
  • Verify RPC URLs in .env

Indexing Not Working

  • Check logs for errors
  • Verify DEX factory addresses are configured
  • Ensure RPC endpoints have required APIs enabled

Next Steps

  1. Configure DEX factory addresses for your chains
  2. (Optional) Add external API keys for enrichment
  3. Monitor indexing progress in logs
  4. Integrate with your frontend/explorer