toncenter / ton-indexer

TON Indexer system to store and serve blockchain data using SQL-database
https://toncenter.com/api/v3/
GNU General Public License v3.0
68 stars 33 forks source link

TON Indexer

[!NOTE]
This repository's master branch hosts the TON Indexer designed for direct reading from the TON Node database. If you are looking for an indexer that operates through tonlib + liteserver, please refer to the branch legacy.

[!NOTE] Be careful upgrading the indexer. Versions with different major and minor have different schemas and they are incompatible with each other.

TON Indexer stores blocks, transactions, messages, NFTs, Jettons and DNS domains in PostgreSQL database and provides convenient API.

TON node stores data in a key-value database RocksDB. While RocksDB excels in specific use cases, it isn't versatile enough for diverse queries. An SQL database is perfectly suitable for the storage and retrieval of data. TON Indexer reads data from RocksDB and inserts it into PostgreSQL. Masterchain blocks are used as an atomic unit of insertion to guarantee data integrity. Indexes allow the efficient fetching of required data from a database.

TON Indexer stack consists of:

  1. postgres: PostgreSQL server to store indexed data and perform queries.
  2. index-api: FastAPI server with convenient endpoints to access the database.
  3. event-classifier: trace classification service.
  4. index-worker: TON Index worker to read and parse data from TON node database. This service must be run on the machine with a working TON Node.

How to run

Requirements:

Do the following steps to setup TON Indexer:

NOTE: we recommend to setup indexer stack and index worker on separate servers. To install index worker to Systemd check this instruction.

Available parameters

Swagger

To test API, built-in swagger can be used. It is available after running docker compose at localhost:8081

FAQ

How to point TON Index worker to existing PostgreSQL instance

How to update code