Skip to content

Latest commit

Β 

History

History
107 lines (80 loc) Β· 2.81 KB

File metadata and controls

107 lines (80 loc) Β· 2.81 KB

BaseIndexer – ERC-20 Token Transfer Indexer

BaseIndexer BaseIndexer is an advanced backend service that listens to the Ethereum blockchain and indexes ERC-20 token transfer events into a PostgreSQL database. What sets BaseIndexer apart is its built-in AI capability that allows users to control indexing behavior using simple natural language commandsβ€”no technical knowledge or query writing required.

πŸš€ Features

  • Indexes real-time ERC-20 Transfer events from the Ethereum blockchain

  • Stores from, to, and value fields into a PostgreSQL database

  • Supports natural language queries via AI for flexible indexing

  • Users can issue commands like:

    • Index transfers for this address

    • Only index the from and value fields

    • Index this particular address from block 2000000

No need to write raw queries or modify code to change indexing target

πŸ“ Folder Structure

backend/
β”œβ”€β”€ env.sample               # Sample environment variables
β”œβ”€β”€ node_modules/            # Installed dependencies
β”œβ”€β”€ package.json             # Project metadata and scripts
β”œβ”€β”€ package-lock.json        # Locked dependency versions
β”œβ”€β”€ tsconfig.json            # TypeScript configuration
β”œβ”€β”€ src/                     # Source code
β”‚   β”œβ”€β”€ config/              # DB and blockchain config (e.g., Sequelize, provider)
β”‚   β”œβ”€β”€ models/              # Sequelize models (e.g., Transfer.ts)
β”‚   β”œβ”€β”€ migrations/          # Sequelize migration files
β”‚   β”œβ”€β”€ services/            # Logic for indexing, saving to DB
β”‚   β”œβ”€β”€ utils/               # Helper functions
β”‚   └── index.ts             # App entry point


βš™οΈ Getting Started

1. Clone the Repository

git clone https://github.com/dimka90/indexer.git
cd backend
  1. Configure Environment Variables Copy the sample .env and configure it:
cp env.sample .env

Update .env with your credentials:

BASE_URL= # e.g. http://localhost:3000
INFURA_URL=https://mainnet.infura.io/v3/YOUR_INFURA_KEY
DB_HOST=localhost
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=BaseIndexer_db
DB_PORT=5432
OPEN_AI_KEY=
  1. Install Dependencies
npm install
  1. Create the Database Make sure PostgreSQL is running, then
create your database:
  1. Run Migrations Apply your database schema:
npx sequelize-cli db:migrate
  1. Start the Indexer
npm run start

πŸ”§ Technologies Used

  1. Node.js
  2. TypeScript
  3. PostgreSQL
  4. Sequelize ORM
  5. Web3.js
  6. dotenv

🌐 Live Demo

PROMPT EXAMPLE

Index this: 0xdac17f958d2ee523a2206206994597c13d831ec7