> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TON sources for Turbo pipelines

> Stream TON blocks, transactions, and messages into your own infrastructure with Turbo pipelines, with schemas and example pipelines.

## Overview

Goldsky provides curated TON (The Open Network) datasets covering blocks, transactions, and messages. Each dataset includes the masterchain block sequence number (`mc_block_seqno`) and `block_timestamp`, so you can join rows across datasets and order them by masterchain block.

## Available datasets

| Dataset | Version | Description |
| - | - | - |
| `ton.blocks` | 1.0.0 | One row per block: each masterchain block and every shard block it commits |
| `ton.transactions` | 1.0.0 | One row per transaction, with compute, action, storage, credit, and bounce phase details |
| `ton.messages` | 1.0.0 | One row per transaction, direction, and message |

> [!NOTE]
>
> The [Datasource explorer](https://app.goldsky.com/explore) always has the latest dataset versions. You can also list them with `goldsky dataset list`.

## Quick start

The fastest way to explore TON data is with a `blackhole` sink and `goldsky turbo inspect`:

```yaml theme={"dark"}
name: demo-ton-transactions-blackhole
resource_size: s

sources:
  ton_transactions:
    type: dataset
    dataset_name: ton.transactions
    version: 1.0.0
    start_at: latest

sinks:
  dev_sink:
    type: blackhole
    from: ton_transactions
```

```bash theme={"dark"}
goldsky turbo apply demo.yaml
goldsky turbo inspect demo-ton-transactions-blackhole
```

## Schema reference

In the tables below, `ts` is a timestamp and `coin` is a TON amount in nanotons (1 TON = 10<sup>9</sup> nanotons). Every dataset includes a `_gs_op` column that carries the row's change operation.

### `ton.blocks`

One row per block: each masterchain block and every shard block it commits.

| Column | Type | Nullable |
| - | - | - |
| `id` | Utf8 | no |
| `mc_block_seqno` | UInt32 | no |
| `block_timestamp` | ts | no |
| `workchain` | Int32 | no |
| `shard` | Int64 | no |
| `seqno` | UInt32 | no |
| `root_hash`, `file_hash` | Utf8 | no |
| `global_id` | Int32 | yes |
| `version` | UInt32 | yes |
| `after_merge`, `before_split`, `after_split`, `want_merge`, `want_split`, `key_block`, `vert_seqno_incr` | Boolean | yes |
| `flags` | Int32 | yes |
| `start_lt`, `end_lt` | UInt64 | no |
| `validator_list_hash_short` | Int32 | yes |
| `gen_catchain_seqno`, `min_ref_mc_seqno`, `prev_key_block_seqno`, `vert_seqno`, `master_ref_seqno` | UInt32 | yes |
| `rand_seed`, `created_by` | Utf8 | yes |
| `tx_count` | UInt32 | no |
| `prev_blocks` | `List<{workchain Int32, shard Int64, seqno UInt32}>` | no |
| `_gs_op` | Utf8 | no |

### `ton.transactions`

One row per transaction.

| Column | Type | Nullable |
| - | - | - |
| `id`, `hash` | Utf8 | no |
| `lt` | UInt64 | no |
| `account` | Utf8 | no |
| `workchain` | Int32 | no |
| `shard` | Int64 | no |
| `block_seqno`, `mc_block_seqno` | UInt32 | no |
| `block_timestamp` | ts | no |
| `trace_id`, `prev_trans_hash` | Utf8 | yes |
| `prev_trans_lt` | UInt64 | yes |
| `orig_status`, `end_status` | Utf8 | yes |
| `total_fees` | coin | yes |
| `descr` | Utf8 | no |
| `aborted`, `destroyed`, `credit_first`, `is_tock`, `installed` | Boolean | yes |
| `storage_fees_collected`, `storage_fees_due` | coin | yes |
| `storage_status_change` | Utf8 | yes |
| `credit_due_fees_collected`, `credit` | coin | yes |
| `compute_skipped` | Boolean | yes |
| `compute_skipped_reason` | Utf8 | yes |
| `compute_success`, `compute_msg_state_used`, `compute_account_activated` | Boolean | yes |
| `compute_gas_fees` | coin | yes |
| `compute_gas_used`, `compute_gas_limit`, `compute_gas_credit` | UInt64 | yes |
| `compute_mode`, `compute_exit_code`, `compute_exit_arg` | Int32 | yes |
| `compute_vm_steps` | UInt32 | yes |
| `compute_vm_init_state_hash`, `compute_vm_final_state_hash` | Utf8 | yes |
| `action_success`, `action_valid`, `action_no_funds` | Boolean | yes |
| `action_status_change` | Utf8 | yes |
| `action_total_fwd_fees`, `action_total_action_fees` | coin | yes |
| `action_result_code`, `action_result_arg` | Int32 | yes |
| `action_tot_actions`, `action_spec_actions`, `action_skipped_actions`, `action_msgs_created` | UInt32 | yes |
| `action_list_hash` | Utf8 | yes |
| `action_tot_msg_size_cells`, `action_tot_msg_size_bits` | UInt64 | yes |
| `bounce` | Utf8 | yes |
| `bounce_msg_size_cells`, `bounce_msg_size_bits` | UInt64 | yes |
| `bounce_req_fwd_fees`, `bounce_msg_fees`, `bounce_fwd_fees` | coin | yes |
| `account_state_hash_before` | Utf8 | yes |
| `account_state_balance_before` | coin | yes |
| `account_state_status_before`, `account_state_code_hash_before`, `account_state_hash_after` | Utf8 | yes |
| `account_state_balance_after` | coin | yes |
| `account_state_status_after`, `account_state_code_hash_after`, `in_msg_hash` | Utf8 | yes |
| `out_msg_count` | UInt32 | no |
| `_gs_op` | Utf8 | no |

### `ton.messages`

One row per transaction, direction, and message. An internal message appears twice: as `out` on the sender's transaction and as `in` on the receiver's transaction.

| Column | Type | Nullable |
| - | - | - |
| `id`, `tx_hash` | Utf8 | no |
| `tx_lt` | UInt64 | no |
| `tx_account`, `direction` | Utf8 | no |
| `mc_block_seqno` | UInt32 | no |
| `block_timestamp` | ts | no |
| `trace_id` | Utf8 | yes |
| `msg_hash` | Utf8 | no |
| `msg_hash_norm` | Utf8 | yes |
| `msg_type` | Utf8 | no |
| `source`, `destination` | Utf8 | yes |
| `value` | coin | yes |
| `value_extra_currencies` | `List<{currency_id Int32, amount coin}>` | no |
| `fwd_fee`, `ihr_fee`, `import_fee`, `extra_flags` | coin | yes |
| `created_lt` | UInt64 | yes |
| `created_at` | ts | yes |
| `ihr_disabled`, `bounce`, `bounced` | Boolean | yes |
| `opcode` | UInt32 | yes |
| `decoded_opcode`, `decoded_body`, `body_hash`, `body_boc`, `comment`, `init_state_hash`, `init_state_boc` | Utf8 | yes |
| `_gs_op` | Utf8 | no |

## Guide: Track failed transactions

Capture transactions that were aborted, for example to debug a contract or alert on failing wallets:

```yaml theme={"dark"}
name: ton-failed-transactions
resource_size: s

sources:
  ton_transactions:
    type: dataset
    dataset_name: ton.transactions
    version: 1.0.0
    start_at: latest

transforms:
  failed_transactions:
    type: sql
    primary_key: id
    sql: |
      SELECT
        id,
        hash,
        account,
        block_timestamp,
        compute_exit_code,
        action_result_code,
        total_fees,
        _gs_op
      FROM ton_transactions
      WHERE aborted = true

sinks:
  postgres_output:
    type: postgres
    from: failed_transactions
    schema: public
    table: ton_failed_transactions
    secret_name: MY_POSTGRES_SECRET
    primary_key: id
```

## Guide: Monitor incoming messages for an account

Stream every message an account receives. Filtering on `direction = 'in'` keeps one row per delivered message, so internal messages are not counted twice:

```yaml theme={"dark"}
name: ton-account-incoming-messages
resource_size: s

sources:
  ton_messages:
    type: dataset
    dataset_name: ton.messages
    version: 1.0.0
    start_at: latest

transforms:
  incoming_messages:
    type: sql
    primary_key: id
    sql: |
      SELECT *
      FROM ton_messages
      WHERE direction = 'in'
        AND destination = '<account_address>'

sinks:
  postgres_output:
    type: postgres
    from: incoming_messages
    schema: public
    table: ton_incoming_messages
    secret_name: MY_POSTGRES_SECRET
    primary_key: id
```

Replace `<account_address>` with the account address in the same format the dataset uses. Inspect a few rows with `goldsky turbo inspect` first to confirm the format.

## Performance tips

> [accordion] Filter early with SQL
>
> TON produces high volumes of transactions and messages across its shards. Apply filters as early as possible to reduce data volume downstream:
>
> ```yaml theme={"dark"}
> transforms:
>   filtered:
>     type: sql
>     sql: SELECT * FROM ton_messages WHERE direction = 'in' AND opcode IS NOT NULL
> ```

> [accordion] Start with latest for development
>
> When building and testing pipelines, use `start_at: latest` to avoid processing large amounts of historical data:
>
> ```yaml theme={"dark"}
> start_at: latest  # Only process new data
> ```

For any questions or feedback, reach out at [support@goldsky.com](mailto:support@goldsky.com).


## Related topics

- [Turbo pipeline sources: EVM, Solana, Stellar, NEAR, Bitcoin](https://docs.goldsky.com/turbo-pipelines/sources/overview.md)
- [Movement sources for Turbo pipelines](https://docs.goldsky.com/turbo-pipelines/sources/movement.md)
- [Solana sources for Turbo pipelines](https://docs.goldsky.com/turbo-pipelines/sources/solana.md)
- [EVM sources for Turbo pipelines](https://docs.goldsky.com/turbo-pipelines/sources/evm.md)
- [Hyperliquid HyperCore sources for Turbo pipelines](https://docs.goldsky.com/turbo-pipelines/sources/hypercore.md)
