Skip to content

TON Blockchain: Quick Start To Data Analysis

TON | The Open Network

TON Logo

Materialised views

Most of original tables are quite low-level but for some common analytical tasks one needs more high-level data marts. To simplify it we created a set of materialised views for most common situations.

  1. dune.ton_foundation.result_opcode_from_forward_payload

If you need to filter Jetton events by the opcode, you can use this materialized view with parsed opcode value from forward_payload:

SELECT *
FROM ton.jetton_events JE
INNER JOIN dune.ton_foundation.result_opcode_from_forward_payload FP
    ON FP.forward_payload = JE.forward_payload
WHERE 1=1 
    AND FP.opcode = 2655528563
  1. dune.ton_foundation.result_dex_pools_latest

ton.dex_pools comes with full history of TVL changes in all pool, but in most situations we need latest values for TVL.

This materialised view is derived from ton.dex_pools table extracting the latest value for each pool. Also this table adds user friendly pool_name field.

  1. dune.ton_foundation.result_dex_pools_daily

Daily snapshots of Dex Pools TVL. Derived from ton.dex_pools table.

  1. dune.ton_foundation.result_ton_jettons_metadata_latest_values

Latest Jetton Metadata values (some jettons can change the metadata over time, some of them store it off chain). Original table ton.jetton_metadata provides full history of on-chain and off-chain changes for each jettons but for most use-cases we need only the latest values.

  1. dune.ton_foundation.result_first_contract_deployments

Then a smart contract with unique code_hash was deployed for the first time. Utility table for TON SmartContract development dashboard.

About TON Data on Dune

TON data on Dune is provided by TON Foundation via the Public Data Lake at AWS. The data lake combines raw data layer (based on ton-indexer by Toncenter) and decoding layer. Results of both layers are available in form of daily snapshots in AVRO format.

Before starting working with TON data we recommend to check the documentation about base concepts because TON architecture is quite different from other chains.

Uploaded datasets

Sometimes data is stored off-chain but it could be important for analysis. For some cases we don't need to store full dataset on-chain and we only need to store proof. It is the common pattern for compressed NFTs.

HamsterKombat used the same approach to store list of the wallets eligible for the on-chain airdrop. That list is available via API but amount of data is huge. Data is available using dune.ton_foundation.hamster_kombat_mintless_airdrop_list table.

TON Labels

Labels are crucial for data analysis. ton-labels is curated dataset with labels for TON addresses with additional metadata (organisation, website, tags, ...).

Some important facts and hints:

  1. All address are stored in raw format
  2. Note that for internal messages you can find two instances of the same message (with the same msg_hash):
  • direction=in - tx_hash in this message points to the transaction that was triggered by the message
  • direction=out - tx_hash in this message points to the transaction that created the message Also it is possible that block_time will be different for those messages and they could be even in different partitions (block_date). In most situations it is recommended to use direction=in filter.

The following tables are available on Dune:

Table NameDescription
ton.blocksinformation about blocks (seqno, timestamp, validator pub key, etc..)
ton.transactionsaccount transactions
ton.messagesmessages that initiate or initiated by transactions
ton.jetton_eventsTEP-64 jettons events (like ERC-20 tokens). More details here
ton.jetton_metadataon-chain and off-chain jetton metadata with history of changes. More details here
ton.dex_tradesdecoded DEX trades. More details here
ton.dex_poolsDEX pools history with TVL, fees values and raw reserves. More details here
ton.prices_dailyTON, jetton, LP and SLP tokens daily prices.