No description
  • TypeScript 100%
Find a file
Plastic Digits 3d33da6fd0
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Bump lockfile HIGH/CRITICAL deps so Trivy can pass.
ethers/express/rate-limit plus overrides for ip-address, path-to-regexp, and ws.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-02 12:01:08 +00:00
src Add cmc endpoints 2025-10-07 19:23:27 +09:00
.gitignore Initial commit 2025-09-10 16:23:26 +09:00
.nvmrc Initial commit 2025-09-10 16:23:26 +09:00
.opengrep.yml Fix OpenGrep placeholder rule pattern. 2026-09-02 11:33:11 +00:00
.woodpecker.yaml Run TypeScript build before Trivy so compile evidence is not skipped. 2026-09-02 11:43:42 +00:00
package-lock.json Bump lockfile HIGH/CRITICAL deps so Trivy can pass. 2026-09-02 12:01:08 +00:00
package.json Bump lockfile HIGH/CRITICAL deps so Trivy can pass. 2026-09-02 12:01:08 +00:00
README.md Update default rate limiting 2025-09-10 16:51:31 +09:00
render.yaml Add render.yaml for render deployment 2025-09-10 16:31:55 +09:00
tsconfig.json Initial commit 2025-09-10 16:23:26 +09:00

Listing API

Express API that exposes ERC20 token supply endpoints (CoinGecko-compatible) with simple rate limiting and inmemory caching.

Quick start

# Use project Node version
nvm use

# Install dependencies
npm ci

# Run in dev (ts-node)
PORT=3000 npm run dev

# Build TypeScript → dist/
npm run build

# Run built server
PORT=3000 npm start

Environment

  • PORT: HTTP port (default 3000).
  • RPC endpoints and chains are configured in src/config/chains.ts.
  • Token registry is defined in src/config/tokens.ts.

Rate limiting and caching

  • Rate limit (configurable): defaults to 60 requests per 30 minutes per IP.
    • RATE_LIMIT_WINDOW_MS: window size in ms (default: 1800000)
    • RATE_LIMIT_MAX: max requests per IP per window (default: 60)
  • Inmemory cache TTL: 60 seconds per token per chain.

Routes

  • GET /health

    • Healthcheck.
    • Response: { "status": "ok" }
  • GET /chains

    • Lists supported chains.
    • Response: { "chains": { "bsc": { id, name, rpcUrls, ... } } }
  • GET /tokens

    • Lists configured tokens.
    • Response: { "tokens": [ { symbol, address, chainId, decimals? }, ... ] }
  • GET /supply/:symbol

    • Legacy detailed object under data.
    • Response:
      {
        "data": {
          "chainId": "bsc",
          "tokenAddress": "0x...",
          "symbol": "CL8Y",
          "decimals": 18,
          "totalSupplyRaw": "...",
          "burnedZeroRaw": "...",
          "burnedDeadRaw": "...",
          "totalSupplyAdjustedRaw": "...",
          "circulatingSupplyRaw": "..."
        }
      }
      
  • GET /api/v1/supply/:symbol

    • CoinGeckofriendly detailed object.
    • Response:
      {
        "symbol": "CL8Y",
        "address": "0x...",
        "chain": "bsc",
        "decimals": 18,
        "total_supply": "...",
        "burned_zero": "...",
        "burned_dead": "...",
        "total_supply_adjusted": "...",
        "circulating_supply": "..."
      }
      
  • GET /api/v3/supply/:symbol

    • CoinGecko minimal format. result is a decimal string of circulating supply.
    • Response: { "result": "123456.789" }
  • GET /api/v3/supply/total/:symbol

    • Minimal total (adjusted) supply.
    • Response: { "result": "123456.789" }
  • GET /api/v3/supply/circulating/:symbol

    • Minimal circulating supply (same as /api/v3/supply/:symbol).
    • Response: { "result": "123456.789" }

Notes:

  • :symbol is caseinsensitive and must exist in src/config/tokens.ts (e.g., CL8Y, CZB).
  • 404 if token is not found, 500 for unexpected errors.

Examples

# Health
curl -s http://localhost:3000/health

# List tokens
curl -s http://localhost:3000/tokens | jq

# Minimal circulating supply
curl -s http://localhost:3000/api/v3/supply/CL8Y | jq

# Detailed payload
curl -s http://localhost:3000/api/v1/supply/CZB | jq

Configure tokens and chains

  • Add or edit tokens in src/config/tokens.ts:
    { symbol: "TKN", address: "0x...", chainId: "bsc", decimals: 18 }
    
  • Chains live in src/config/chains.ts. Default chain key is bsc.

Deployment

  • Production entrypoint is dist/server.js (script: npm start).
  • A Render configuration is provided in render.yaml if deploying to Render.