Skip to content

thecotne/GoL2-Indexer

Repository files navigation

GoL2 Indexer

Quick start

  • pnpm dbmate up - create the database and run migrations
  • pnpm build - build all the projects
  • pnpm dev - start all the projects
  • pnpm debug - start all the projects with debug logs
  • pnpm prod - start all the projects in production mode
  • pnpm pgcli - connect to the database with pgcli
  • pnpm check - check the code
  • pnpm fix - check and fromat the code
  • pnpm kanel - generate types from the database
  • pnpm apps - run a script in all the projects (e.g. pnpm apps build)
  • pnpm apps:web - run a script in the web project (e.g. pnpm apps:web build)
  • pnpm apps:indexer - run a script in the indexer project (e.g. pnpm apps:indexer build)

Docker Compose commands

  • docker compose build - build all the images
    • docker compose build indexer - build the indexer image
    • docker compose build web - build the web image
    • docker compose build migrations - build the migrations image
  • docker compose up - start all the services
    • docker compose up -d - start all the services in the background
    • docker compose up db -d - start the database in the background
  • dpcker compose rm - remove all stopped services
    • docker compose rm --stop - stop and remove all the services

setup-*.sh scripts

  • source ./setup-install.sh - install nvm, node and pnpm.
  • source ./setup-update.sh - install up-to-date versions of nvm, node and pnpm.

Env variables

Required Env Variables

  • DATABASE_URL - Database connection string
  • INDEXER_CONFIG - The indexer configuration
    • STARKNET_NETWORK_NAME CONTRACT_BLOCK_NUMBER CONTRACT_ADDRESS for each contract
      • STARKNET_NETWORK_NAME - The StarkNet network name (SN_GOERLI or SN_MAIN)
      • CONTRACT_BLOCK_NUMBER - The block number at which the contract was deployed
      • CONTRACT_ADDRESS - The contract address
    • Example:
      • SN_GOERLI 942318 0x05bd17bba6b3cb9740bcc0f20f93ecf443250c4f09d94e4ab32d3bdffc7ebba2
      • SN_MAIN 526494 0x079294c688eb80e025f298b1ab2d30dd7a4a316ed592ac2fc124710564e4e911
      • SN_GOERLI 267275 0x06dc4bd1212e67fd05b456a34b24a060c45aad08ab95843c42af31f86c7bd093
      • SN_MAIN 4982 0x06a05844a03bb9e744479e3298f54705a35966ab04140d3d8dd797c1f6dc49d0

Optional Env Variables

  • DBMATE_MIGRATIONS_DIR - The directory where the migrations are located (default: db/migrations)
  • DBMATE_SCHEMA_FILE - The file where the schema is located (default: db/schema.sql)
  • INFURA_API_KEY - The Infura API key (nullable)
  • INDEXER_DELAY - The delay between indexing (in milliseconds) (default: 3000)
  • LOG_LEVEL - The log level (trace, debug, info, warn, error, fatal) (default: info)

Tools and libraries used

  • Biome - Format, lint, and more in a fraction of a second.
  • dbmate - A lightweight, framework-agnostic database migration tool.
  • Docker Compose - Define and run multi-container applications with Docker.
  • Docker - Build, Share, and Run Any App, Anywhere.
  • dotenv-cli - A cli to load dotenv files.
  • dotenv - Loads environment variables from .env for nodejs projects.
  • Kanel - Generate Typescript types from Postgres.
  • Kysely extension for Kanel - Generate Kysely types from Postgres.
  • Kysely - The type-safe SQL query builder for TypeScript.
  • Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions.
  • node-postgres- PostgreSQL client for node.js.
  • Node.js - JavaScript runtime.
  • Pgcli - A command line interface for Postgres with auto-completion and syntax highlighting.
  • pkgroll - Next-gen package bundler for TypeScript & ESM.
  • pnpm - Fast, disk space efficient package manager.
  • PostCSS - A tool for transforming CSS with JavaScript plugins.
  • PostgreSQL - The world's most advanced open source database.
  • react - A JavaScript library for building user interfaces.
  • remix-run - The full-stack web framework for the modern web.
  • shadcn-ui - Beautifully designed components that you can copy and paste into your apps.
  • Starknet.js - JavaScript library for Starknet
  • Tailwind CSS - A utility-first CSS framework for rapid UI development.
  • TanStack Table - Headless UI for building powerful tables & datagrids.
  • tsx - TypeScript Execute: Node.js enhanced to run TypeScript & ESM
  • TypeScript - Typed JavaScript at Any Scale.
  • Vite - Next generation frontend tooling. It's fast!
  • winston - A logger for just about everything.
  • znv - Type-safe environment parsing and validation for Node.js with Zod schemas.
  • Zod - TypeScript-first schema validation with static type inference.

Related projects