> ## 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.

> ## Agent Instructions
> To query the Token Terminal data catalog, read https://tokenterminal.com/docs/catalog/agents-manual.md first. It is the whole catalog as one page: table naming grammar, key columns, partition and cluster rules, units, additivity, and the tables that are documented but not served yet.
> Never query a catalog table on a time bound alone. Also filter its cluster key, which you read from INFORMATION_SCHEMA.COLUMNS; an empty result means the object is a view, whose pruning contract is on its page. Compute is billed to the caller's own Google Cloud project.

# Accounts

> Wallets and contracts labeled with the projects that own them.

`dimensions.accounts` holds one row per address on MegaETH that is labeled or that a `facts_accounts` table holds a row for, keyed on `chain_id` and `address`. An account is a wallet or a contract, such as an exchange wallet or a Uniswap pool, and where it is labeled its row names the project that runs it, so a labeled address in any MegaETH table resolves to the project behind it. An address nobody has labeled has a null `label_source` and null label columns beside its region and funding.

A labeled address reaches the table in one of two ways, and `label_source` says which. `curated` is an attribution a person authored; `factory_derived` is an address a known factory emitted, and those rows name that factory in `parent_address`. Factory output is the bulk of the labeled rows, so filter to `curated` for the set somebody has already looked at.

Every column is documented at [Accounts](https://tokenterminal.com/docs/catalog/accounts/registry.md).

## Sample queries

> [!WARNING]
>
> The table is clustered on `chain_id` then `address`. Filter on `chain_id` to read one chain, and add `address` for a single account; a query filtered only on `project_id` or `label_source` reads every row of a table that spans every account the facts hold, so keep the select list to the columns you need.

> [tab] Labeled projects
>
> **Rank the projects with the most labeled addresses on MegaETH.** Joining `dimensions.projects` on `project_id` adds each project's name and its market sector.
>
> ```sql theme={null}
> select
>     projects.name,
>     projects.primary_market_sector,
>     count(*) as addresses
> from `dimensions.accounts` as accounts
> join `dimensions.projects` as projects
>     using (project_id)
> where accounts.chain_id = 'megaeth'
>   and accounts.label_source = 'curated'
> group by projects.name, projects.primary_market_sector
> order by addresses desc
> limit 50
> ```

> [tab] What one project runs
>
> **List the addresses one project runs on MegaETH.** `contract_name` is the label the attributing project gives an address, such as `Factory` or a pool's pair.
>
> ```sql theme={null}
> select
>     address,
>     contract_name,
>     account_type
> from `dimensions.accounts`
> where chain_id = 'megaeth'
>   and project_id = 'gainsnetwork'
>   and label_source = 'curated'
> order by contract_name
> limit 100
> ```

> [tab] A factory's output
>
> **Rank the factories by how many addresses they emitted on MegaETH.** Every factory-derived row names its factory in `parent_address`, so grouping on that column returns one row per factory.
>
> ```sql theme={null}
> select
>     parent_address,
>     project_id,
>     count(*) as emitted
> from `dimensions.accounts`
> where chain_id = 'megaeth'
>   and label_source = 'factory_derived'
> group by parent_address, project_id
> order by emitted desc
> limit 50
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.