# Checkpoint indexer REST API

Exposes v2 hub reads for wallets and explorers, plus an **Etherscan V2-shaped shim** for Chain 138 (unsupported on [official Etherscan V2 chainlist](https://api.etherscan.io/v2/chainlist)).

See: `docs/04-configuration/etherscan/CHAIN138_ETHERSCAN_V2_UNSUPPORTED_NETWORK_FRAMEWORK.md`

## Endpoints (v1)

| Method | Path | Description |
|--------|------|-------------|
| GET | `/health` | Liveness |
| GET | `/v1/checkpoint/latest` | Latest batch header |
| GET | `/v1/checkpoint/:batchId` | Historical batch |
| GET | `/v1/tx/:txHash/attestation` | Inclusion in batch |
| GET | `/v1/account/:address` | Account summary + attested activity |
| GET | `/v1/account/:address/transactions` | Batch-indexed txs for address |
| GET | `/v1/account/:address/activity` | Attested activity rows |
| GET | `/v1/tx/:txHash/logs` | Receipt logs from batch payload |

## Endpoints (v2 — Etherscan supplement)

| Method | Path | Description |
|--------|------|-------------|
| GET | `/v2/chainlist-supplement` | Supplemental chainlist (chain 138 + mainnet attestation layer) |
| GET | `/v2/api?chainid=138&module=account&action=balance` | Chain 138 balance (RPC) |
| GET | `/v2/api?chainid=138&module=account&action=txlist` | Blockscout tx list proxy |
| GET | `/v2/api?chainid=138&module=chain138&action=participantactivity` | Attested activity from batch index |
| GET | `/v2/api?chainid=138&module=chain138&action=attestation&txhash=0x…` | Per-tx attestation |
| GET | `/v2/api?chainid=138&module=proxy&action=eth_blockNumber` | Chain 138 block number |
| GET | `/v2/api?chainid=1&module=chain138mirror&action=contracts` | Mainnet mirror/registry/hub map |
| GET | `/v2/api?chainid=1&module=chain138mirror&action=participantlogs` | Etherscan V2 log proxy (credited topic2, debited topic3) |
| GET | `/v2/api?chainid=1&module=chain138mirror&action=mirrorlogs` | v1 TransactionMirror logs |

Env: `ADDRESS_ACTIVITY_REGISTRY_MAINNET`, `ETHERSCAN_API_KEY` (for mainnet log proxy).

## Run

```bash
cd smom-dbis-138/services/checkpoint-indexer
pnpm install && pnpm build
CHAIN138_MAINNET_CHECKPOINT_PROXY=0x… pnpm start
```

From repo root: `bash scripts/deployment/start-checkpoint-services.sh` (builds aggregator + indexer).

Default port: `3099` (`CHECKPOINT_INDEXER_PORT`).

Public NPM path (when configured): `https://explorer.d-bis.org/checkpoint/v2/...` → indexer.
