---
# System prepended metadata

title: Statistics

---

# Statistics

We plan to collect per-milestone information to provide statistics about the Tangle and the ledger state. Ideally, these statistics can also be aggregated in predefined time intervals such as _1 hour_, _24 hours_, _7 days_, and so on.

We are currently looking into implementing the following statistics -- for some we still might have to figure out how to compute them efficiently.

## Tangle statistics

Gathering tangle-based statistics is straightforward, we simply observe what happens in a single milestone. These statistics are also easy to deal with because to aggregate them into time intervals the per-milestone values can simply be summed together.

* [ ] `stardust_payload_activity` - Statistics about the payloads 
    * [ ] `transaction_count` - Number of transaction payloads in a milestone
    * [ ] `tagged_data_count` - Number of tagged data payloads in a milestone
    * [ ] `milestone_count` - Number of milestone payloads in a milestone
    * [ ] `treasury_transaction_count` - Number of treasury transaction in a milestone
* [ ] `stardust_transaction_activity` - Statistics about transactions 
    * [ ] `conflicting_count` - Number of conflicting transactions in a milestone
    * [ ] `confirmed_count` - Number of confirmed transactions in a milestone

## Protocol parameters

The following statistics simply record the protocol parameters for the current ledger index and _should only be recorded if changed_. We collect these changes to protocol parameters to facilitate analysis like: _"How did the recent changes to the rent structure influence the size of the ledger?"_

* [ ] `stardust_info` (only recorded when changed)
    * [ ] `token_supply`
    * [ ] `treasury_tokens`
* [ ] `stardust_protocol_parameters` - Protocol parameters (only recorded when changed)
    * [ ] `min_pow_score`
    * [ ] `below_max_depth`
    * [ ] `v_byte_cost`
    * [ ] `v_factor_data`
    * [ ] `v_factor_key`

If we don't store the parameters together with the time series, the teams would have to get this data from secondary sources, greatly increasing the complexity.

## Ledger statistics

* [ ] `stardust_ledger_outputs` - Shows the distribution of current unspent outputs of the ledger
    * [ ] `total_alias_count` - The current number of unspent Alias outputs in the ledger
    * [ ] `total_alias_value` - The current number of tokens held by unspent Alias outputs in the ledger
    * [ ] `total_basic_count` - The current number of unspent Basic outputs in the ledger
    * [ ] `total_basic_value` - The current number of tokens held by unspent Basic outputs in the ledger
    * [ ] `total_foundry_count` - The current number of unspent Foundry outputs in the ledger
    * [ ] `total_foundry_value` - The current number of tokens held by unspent Foundry outputs in the ledger
    * [ ] `total_nft_count` - The current number of unspent Nft outputs in the ledger
    * [ ] `total_nft_value` - The current number of tokens held by unspent Nft outputs in the ledger
    * [ ] `total_treasury_count` - The current number of unspent Treasury outputs in the ledger
    * [ ] `total_treasury_value` - The current number of tokens held by unspent Treasury outputs in the ledger

* [ ] `stardust_claiming_rewards` - Shows information about the claiming rewards
    * [ ] `total_claimed_value` - The total number of tokens that have been claimed since genesis.
    * [ ] `total_claimed_count` - The total number outputs that have been claimed since genesis.

* [ ] `stardust_alias_activity`
    * [ ] `created_count` - The number of Aliases that have been created in the current milestone.
    * [ ] `governor_changed_count` - The number Aliases where the governor changed in the current milestone.
    * [ ] `state_changed_count` - The number Aliases where the state changed in the current milestone.
    * [ ] `destroyed_count` - The number of Aliases that have been destroyed in the current milestone.

* [ ] `stardust_nft_activity`
    * [ ] `created_count` - The number of NFTs that have been created (minted) in the current milestone.
    * [ ] `transferred_count` - The number NFTs that have been transferred in the current milestone.
    * [ ] `destroyed_count` - The number of NFTs that have been destroyed (burned) in the current milestone.

* [ ] `stardust_foundry_activity`
    * [ ] `created_count` - The number of Foundries that have been created (minted) in the current milestone.
    * [ ] `transferred_count` - The number Foundries that have been transferred in the current milestone.
    * [ ] `destroyed_count` - The number of Founrdies that have been destroyed (burned) in the current milestone.

* [ ] `stardust_ledger_size`
    * [ ] `total_data_bytes` - The number of data bytes in the ledger
    * [ ] `total_key_bytes` - The number of key bytes in the ledger
    * [ ] `total_storage_deposit_value` - The current value (_byte cost_) of all storage deposits.

* [ ] `stardust_base_token_activity`
    * [ ] `transferred_value` - The number of tokens that has been transferred in the current milestone.

* [ ] `stardust_address_activity`
    * [ ] `sending_count` - The number of addresses that have sent funds in the current milestone.
    * [ ] `receiving_count` - The number of addresses that have received funds in the current milestone.
    * [ ] `total_count` - The number of addresses that have either sent or received funds. :warning: Note that this is not necessarily equal to `sending_count` + `receiving_count` (consider an address that sends to itself).

* [ ] `stardust_address`
    * [ ] `address_with_balance_count` - The number of addresses that hold a balance.

* [ ] `stardust_unlock_conditions` - Information about unlock conditions (check for timestamp where appropriate)
    * [ ] `total_timelock_count` - The total number of timelocked outputs  in the current ledger state
    * [ ] `total_timelock_value` - The total amount of tokens that are timelocked in the current ledger state
    * [ ] `total_expiration_count` - The total number of timelocked outputs  in the current ledger state
    * [ ] `total_expiration_value` - The total amount of tokens that are timelocked in the current ledger state
    * [ ] `total_storage_deposit_return_count` - The total number of SDRUCs in the current ledger state
    * [ ] `total_storage_deposit_return_value` - The total amount of SDRUCS in the current ledger state

# Implementation

This data will be exposed via a read-only InfluxDB instance and can therefore easily be exposed to Grafana.

## What happens to existing APIs?

This new time series database would deprecate most of the current Analytics API. The only thing that we plan on keeping are the `/ledger/richest-addresses` and `ledger/token-distribution` endpoints, which will most likely be moved to the Explorer API though.