Skip to main content

Analytics and Data

Developers often need to run analytical queries on top of on-chain data — for example, to track historical changes and aggregate data from multiple accounts. Since blockchains are not designed for analytical workloads, you need to build an indexing pipeline and run off-chain analytical queries. Creating such pipelines from scratch can be resource-consuming, so we recommend using one of the tools mentioned on this page.

Dune Analytics

Dune Analytics is one of the leading platforms for running analytical queries and building dashboards. It comes with 100+ blockchain integrations, and TON is among them. Basically, one needs to be familiar with SQL language to write queries, but the Dune AI prompt engine allows users to start working with data even without SQL knowledge. Dune Analytics consumes data from the public TON Data Lake (see below) and comes with a variety of raw and decoded tables.

The raw tables include:

  • Blocks
  • Transactions
  • Messages - includes raw body and state init data.
  • Balances history - allows you to get a precise point-in-time balance for any account.
  • Jetton events - comes with transfers, burns and mints. Note that since mints are not covered by the TEP-74 standard, it is not possible to reconstruct balances based solely on jetton events, so balances history should be used.

Apart from raw tables, there are decoded tables that allow you to work with high-level structures in a unified manner:

  • NFT events - comprehensive source of NFT-related data including sales, transfers and mints.
  • DEX trades - includes a unified data model for DEX trades. The full list of supported DEXs is available here.
  • DEX pools - comes with the full history of DEX pool balances and TVL estimations.

Finally, two tables with off-chain metadata are available: Jetton metadata and NFT metadata.

Dune Analytics allows projects to build bespoke data marts for each protocol - it is widely used for EVMs with the help of ABIs. Since TON doesn't have ABIs and handles complex data structures, a special decoding framework has been created. It works on top of Spellbook - a powerful tool for building custom tables with dbt and Jinja macros. It helps decode important information from raw protocol message payloads. The following protocols are decoded using this framework and serve as examples:

In addition to decoding raw data, the Spellbook allows building custom materialized views. Some of them are widely used and maintained to be up to date:

  • ton.prices_daily - prices calculated based on all other tables. The prices include jettons traded on DEXs, LP tokens for DEXs and perpetuals, tsUSDe and other core assets. It is recommended to use this table if you need to build an estimation of assets denominated in TON or USD.
  • ton.accounts - materialized view with information about all accounts. It comes with the latest TON balance, interface (if any), funding information and other fields.
  • ton.latest_balances - helper table to get the latest balances for TON and Jettons.

Note that all tables mentioned above are updated daily.

If you're just starting to explore TON data on Dune, we recommend checking these articles first:

For inspiration to build your own dashboards, check out these examples:

The Public Data Lake

Dune integration runs on the public data lake from the TON-ETL project. The TON-ETL is built on top of the TON Center indexer and allows extraction of data from TON Node into data formats suitable for MPP (Massively Parallel Processing) engines (Presto, Apache Spark, etc.). You can deploy it on your own infrastructure or use publicly available data from the S3 bucket s3://aws-public-blockchain/v1.1/ton/. This dataset is part of the AWS Public Blockchain Data project and is optimized for use within the AWS big data stack. Examples of AWS Athena and AWS Bedrock integration can be found in this article. The TON-ETL extracts raw data and performs decoding to create a unified view of high-level on-chain activity. The most important part is decoding DEX activity. To add support for a new DEX, you need to prepare a PR on Github. The decoding implementation must solve the following tasks:

  • Decoding of swap events. The decoding code must check the authenticity of the swap (for example, you cannot rely on the opcode alone since anyone can generate messages with your opcode).
  • Extracting all swap-related fields: tokens sold and bought, amounts, query IDs, trader, router (if any), and pool.
  • Fetching pool reserves and LP token supply (if applicable).

If you are starting to implement decoding for your DEX, consider checking these existing PRs:

Real-time streams

In addition to bulk data export, TON-ETL provides real-time data streaming via Kafka. A public endpoint is available free of charge for non-profit projects. For projects that don't meet the non-profit criteria or require an in-house solution, you can deploy the infrastructure yourself by:

  1. Running your own TON node
  2. Launching ton-etl
  3. Setting up ton-index-worker

TON Labels

While data availability and integrations are essential, building insightful dashboards requires enriching data with address labels. The TON Labels project simplifies this process by providing a comprehensive taxonomy of addresses in TON Ecosystem. It covers active addresses across various categories including centralized exchanges (CEXs), decentralized applications (dApps), and DeFi protocols.

You can access the latest labels either directly from the build branch or through Dune Analytics using the dune.ton_foundation.dataset_labels table.

Other platforms

  • Chainbase offers a set of raw and decoded tables with TON data. It allows you to run SQL queries and fetch results via API.
  • TON Console provides analysts with Analytics Service.
  • TokenTerminal comes with high-level metrics across TON Ecosystem.
  • Artemis contains key metrics for TON and allows you to build customized charts.
Was this article useful?