Token indexing

This system is designed to index and monitor token movements on the Solana blockchain. It fetches transaction history, parses token-related instructions, and stores the information in a Firebase database. The system provides real-time updates and historical data for a specific token.

Monitor:

The main class that initializes and coordinates the indexing process:
  • Initializes the Database, Parser, Fetcher and Listener
  • There are two transaction entry points:
    • API server using Elysia that handles webhook requests, ie: transactions on real time
    • Initializes the monitoring process for a specific token by reading its history

Fetcher:

Responsible for retrieving transaction data from the mint to send them to the parser where the parsed events are stored. mintFromHistory is responsible for getting the mint from source and destination account on the transfer event (this instruction does not have this info in its context, as we only want to process the transfers of an specific mint, we need to check if this account is from our mint, in case this account does not longer exists the unique way to validate this is to read its history)

Parser:

Parses transaction data and extracts relevant token information.
  • Detects new token accounts
  • Computes token account balances and token supply
  • Saves events and updates balances/supply in the database

Webhook listener:

Receives new transactions, waits until they are confirmed, and sends them to the parser. You need to set up a server where this code is deployed and the webhook on your RPC provider.

Database:

Using firebase for simplicity, really easy to setup and to visualize data, I recommend using sqlite bun plugin for tokens with a lot of activity, for this iteration I used real time db from firebase but in the future will use that for sure.

Server Setup

  1. Install Docker on the server (Ubuntu):
      • Follow the official Docker installation guide for Ubuntu
  1. Create a docker-compose.yml file:
  1. Configure firewall and start Docker:

Updating the Docker Container

  1. On local machine:
  1. On server:

Troubleshooting

If you encounter issues with Docker installation on Ubuntu, follow these steps:
  1. Determine the correct Ubuntu codename:
  1. Update the /etc/apt/sources.list.d/docker.list file with the correct codename: