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

# Tokens

> X Layer token transfers, balance changes, holder balances and daily prices.

<Info>
  **In progress.** This table is not served yet. The page documents it as it lands.
</Info>

Four surfaces cover token activity on X Layer.

* [`facts.token_transfers`](/docs/catalog/tokens/transfers): one row per token transfer.
* [`facts.token_balance_changes`](/docs/catalog/tokens/balance-changes): one row per account per transfer, so a transfer produces a negative row for the sender and a positive one for the receiver.
* [The balance functions](/docs/catalog/tokens/balances): holder balances at any date, computed at query time.
* [`metrics.tokens_prices_daily`](/docs/catalog/tokens/prices): one USD price per token per day.

Every column and both function signatures are documented at [Tokens](/docs/catalog/tokens/index).

## Sample queries

<Warning>
  The event tables split by day on `block_timestamp` and hold billions of rows. Bound that column in every query; without a bound the query reads the whole table.
</Warning>

<Tabs>
  <Tab title="Daily activity">
    **Count the transfers and the accounts behind them on one day.** Counts of distinct accounts across longer windows cannot be added up day by day; [Assets ▸ Senders](/docs/catalog/assets/senders) covers the surface built for that question.

    ```sql theme={null}
    select
        count(*) as transfers,
        count(distinct from_address) as senders,
        count(distinct to_address) as recipients
    from `facts.token_transfers`
    where block_timestamp >= timestamp('2026-08-20')
      and block_timestamp < timestamp('2026-08-21')
      and chain_id = 'xlayer'
      and token_type = 'erc20'
    ```
  </Tab>

  <Tab title="Busiest tokens">
    **Rank the busiest X Layer tokens on one day.** Joining `dimensions.tokens` on `token_id` adds the symbol and name of each contract.

    ```sql theme={null}
    select
        tokens.symbol,
        transfers.token_address,
        count(*) as transfer_count,
        count(distinct transfers.from_address) as senders
    from `facts.token_transfers` as transfers
    join `dimensions.tokens` as tokens
        using (token_id)
    where transfers.block_timestamp >= timestamp('2026-08-20')
      and transfers.block_timestamp < timestamp('2026-08-21')
      and transfers.chain_id = 'xlayer'
    group by tokens.symbol, transfers.token_address
    order by transfer_count desc
    limit 20
    ```
  </Tab>

  <Tab title="Net balance moves">
    **Find the accounts that gained and lost the most of one token on one day.** Summing `balance_change_raw` per account nets the incoming and outgoing legs; dividing by `10^decimals` converts to token amounts.

    ```sql theme={null}
    select
        changes.account_address,
        sum(changes.balance_change_raw) / pow(10, tokens.decimals) as net_change
    from `facts.token_balance_changes` as changes
    join `dimensions.tokens` as tokens
        using (token_id)
    where changes.block_timestamp >= timestamp('2026-08-20')
      and changes.block_timestamp < timestamp('2026-08-21')
      and changes.chain_id = 'xlayer'
      and changes.token_address = '0x74b7f16337b8972027f6196a17a631ac6de26d22'
    group by changes.account_address, tokens.decimals
    order by net_change desc
    limit 20
    ```
  </Tab>

  <Tab title="Current holders">
    **List the largest current holders of one X Layer token.** The returned `balance` is already converted out of raw units.

    ```sql theme={null}
    select
        account_address,
        balance
    from `functions.calculate_latest_token_balances`(
        'xlayer',
        '0x74b7f16337b8972027f6196a17a631ac6de26d22',
        'erc20'
    )
    order by balance desc
    limit 20
    ```
  </Tab>

  <Tab title="Balance history">
    **Trace one account's balance in one token over time.** The function returns a row only on the days the balance moved; the balance on any other date is the latest row at or before it.

    ```sql theme={null}
    select
        balance_date,
        balance
    from `functions.calculate_historical_eod_token_balances`(
        'xlayer',
        '0x74b7f16337b8972027f6196a17a631ac6de26d22',
        'erc20'
    )
    where account_address = '0x28c6c06298d514db089934071355e5743bf21d60'
    order by balance_date desc
    limit 20
    ```
  </Tab>

  <Tab title="Daily price">
    **Read one X Layer token's daily price.** Each row is the midnight UTC price in USD.

    ```sql theme={null}
    select
        prices.timestamp,
        tokens.symbol,
        prices.price
    from `metrics.tokens_prices_daily` as prices
    join `dimensions.tokens` as tokens
        using (token_id)
    where prices.timestamp >= timestamp('2026-08-16')
      and prices.timestamp < timestamp('2026-08-23')
      and prices.token_id = '0x74b7f16337b8972027f6196a17a631ac6de26d22-xlayer'
    order by prices.timestamp
    ```
  </Tab>
</Tabs>

## Notes

The token list is everything we see onchain, which reaches far past the tokens anyone would want: a ranking of the busiest tokens returns contracts whose symbols imitate well-known ones. Nothing has gone wrong when those appear. Joining `dimensions.asset_tokens` keeps the tokens tied to a named asset with a named issuer; [Assets](/docs/catalog/chain-verticals/evm/xlayer/assets) covers that layer.
