> For the complete documentation index, see [llms.txt](https://qualitax.gitbook.io/polymesh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qualitax.gitbook.io/polymesh/getting-started/polymesh-data.md).

# Polymesh Data

In order to query and explore Polymesh data, follow the steps below:

**Step 1** : Install and run Polymesh subquery : <https://github.com/PolymeshAssociation/polymesh-subquery> .

{% hint style="info" %}
Alternatively, a public GraphQL endpoint is available for use with the client of your choice, such as the Altair Chrome extension.

Endpoint: <https://mainnet-graphql.polymesh.network/>

Please be aware that this public endpoint has a rate limit and a maximum of 100 results per query. If your query returns a large result set, you may need to implement pagination to retrieve all the data effectively.
{% endhint %}

**Step 2:** Use the Polymesh graphql playground <http://localhost:3001/graphql> or pgAdmin to get a quick overview and understanding of the data. &#x20;

{% hint style="info" %}
This documentation covers both GraphQL (via the playground) and SQL (via pgAdmin) queries.
{% endhint %}

**Step 3 :**&#x20;

<mark style="color:purple;">**GraphQL:**</mark>  In the playground,  run the query below or click on "Schema" on the right side of the panel.

```
query {
  __schema {
    types {
      name
      description
      fields {
        name
      }
    }
  }
}
```

<figure><img src="https://243096197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEJbeWS9CeNvCKkvrw412%2Fuploads%2Ffsoqgm8wtWeQtB60CdkR%2Fimage.png?alt=media&amp;token=d9203b8d-06cb-4154-bee6-765f39085eed" alt=""><figcaption></figcaption></figure>

<mark style="color:purple;">**SQL:**</mark> In pgAdmin, run the query below to return the list of tables and their descriptions.

```
SELECT 
    cls.relname AS table_name,
    obj_description(cls.oid) AS table_description
FROM 
    pg_class cls
JOIN 
    pg_namespace ns ON ns.oid = cls.relnamespace
WHERE 
    ns.nspname = 'public' AND 
    cls.relkind = 'r';
```

| table\_name                          | table\_description                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| debugs                               | -                                                                                                                                                                                                                                                                                                                                                                    |
| found\_types                         | -                                                                                                                                                                                                                                                                                                                                                                    |
| blocks                               | A set of transactions that were executed together. Includes a reference to its parent, which reference its parent, this forms a chain to the genesis block                                                                                                                                                                                                           |
| permissions                          | Represents an Account's permissions. The primary key for an Identity always has full permission                                                                                                                                                                                                                                                                      |
| \_metadata                           | NULL                                                                                                                                                                                                                                                                                                                                                                 |
| identities                           | Represents a person or business on chain. All Polymesh assets belong to an Identity. A single Identity can have many accounts (i.e. 'keys') An Identity needs a valid CDD claim from at least one KYC/KYB provider to perform most actions on chain                                                                                                                  |
| accounts                             | Represents a public/private key pair. Most actions must be signed by an appropriately permissioned Account. Before an Account can sign most Extrinsics it must first be attached to an Identity                                                                                                                                                                      |
| account\_histories                   | Represents historical data of identities assigned to an account                                                                                                                                                                                                                                                                                                      |
| bridge\_events                       | Represents `POLY`, the Ethereum based ERC-20 token, being converted to POLYX, the native Polymesh token                                                                                                                                                                                                                                                              |
| staking\_events                      | Represents a change in staking status                                                                                                                                                                                                                                                                                                                                |
| assets                               | Represents a tokenized Asset on the Polymesh chain. The central data structure for the ecosystem                                                                                                                                                                                                                                                                     |
| ticker\_external\_agent\_actions     | Represents an administrative action on an Asset, e.g. tokens issued, compliance rules updated, document added, etc.                                                                                                                                                                                                                                                  |
| venues                               | Represents a place to trade assets. This allows for additional mediation and control over the exchange of Assets e.g. An asset may specify it can only be exchanged at a particular Venue, allowing the Venue owner to explicitly approve transactions                                                                                                               |
| portfolios                           | Represents a grouping of Assets held by an Identity. Particular accounts maybe authorized only over certain portfolios Note: identities will always have a default Portfolio (id = 0)                                                                                                                                                                                |
| stos                                 | Securities Token Offering. Represents a fund raising effort from a company. e.g. sale of company equity in exchange for a stable coin                                                                                                                                                                                                                                |
| authorizations                       | Represents a request to grant an Account some permission to perform actions for an Identity. e.g. become a Portfolio custodian                                                                                                                                                                                                                                       |
| investments                          | Represents participation in an STO                                                                                                                                                                                                                                                                                                                                   |
| ticker\_external\_agents             | Represents an Identity authorized to perform actions on behalf of a company                                                                                                                                                                                                                                                                                          |
| ticker\_external\_agent\_histories   | Represents a change in the status of an external agent.                                                                                                                                                                                                                                                                                                              |
| agent\_groups                        | Represents a set of agents authorized to perform actions for a given Asset                                                                                                                                                                                                                                                                                           |
| agent\_group\_memberships            | Represent membership in a group. Tracks which members belong to which groups                                                                                                                                                                                                                                                                                         |
| portfolio\_movements                 | Represents a transfer of fungible assets between a single identities portfolios. Note: transfers between identities are known as `Settlements`                                                                                                                                                                                                                       |
| instructions                         | Represents a request to exchange Assets between parties. Before an Instruction is executed all involved parties must sign and submit an affirmation. Once an Instruction is affirmed it will then be attempted to be executed. If any party fails to satisfy any compliance or transfer restriction the Instruction will fail, and no movement of assets will occur. |
| settlements                          | Represents a trade of assets between parties                                                                                                                                                                                                                                                                                                                         |
| legs                                 | Represents the movement of a single Asset in a trade, e.g. Alice will give Bob 1 USDS                                                                                                                                                                                                                                                                                |
| distributions                        | Represents a distribution to the owners of an Asset. e.g. dividend payment                                                                                                                                                                                                                                                                                           |
| distribution\_payments               | Represents an owner of an asset collecting a distribution e.g. accepting a dividend                                                                                                                                                                                                                                                                                  |
| proposals                            | Represents a potential change to how the chain will operate. It will need gain sufficient 'Aye' votes before having effect                                                                                                                                                                                                                                           |
| proposal\_votes                      | Represents a vote on a governance proposal                                                                                                                                                                                                                                                                                                                           |
| claim\_scopes                        | The scope of a claim. e.g. `target` is Blocked from owning                                                                                                                                                                                                                                                                                                           |
| custom\_claim\_types                 | Represents the registered CustomClaimType                                                                                                                                                                                                                                                                                                                            |
| claims                               | A claim made about an Identity. All active identities must have a valid CDD claim, but additional claims can be made. e.g. The Identity belongs to an accredited, US citizen                                                                                                                                                                                         |
| trusted\_claim\_issuers              | An claim issuer that is trusted for an Asset. Assets relying on on chain compliance should be explicit on which issuers they trust                                                                                                                                                                                                                                   |
| asset\_pending\_ownership\_transfers | Represents a request to take ownership of a particular Asset                                                                                                                                                                                                                                                                                                         |
| transfer\_managers                   | deprecated in favor of `TransferCompliance`                                                                                                                                                                                                                                                                                                                          |
| stat\_types                          | Represents an on chain statistic about the Asset owners. e.g. How many investors hold the Asset. These are required to be enabled in order for the chain to enforce transfer restrictions e.g. A restriction requiring ownership to be at least 50% Canadian would require a StatType of type `Balance` scoped to Jurisdiction before being created                  |
| transfer\_compliances                | Represents restriction that will ensure the composition of ownership remains a certain way e.g. No more than 2000 individual investors to avoid additional reporting requirements                                                                                                                                                                                    |
| transfer\_compliance\_exemptions     | Represents an exemption for an individual for TransferCompliance rules                                                                                                                                                                                                                                                                                               |
| nft\_holders                         | Represents what NFTs of a collection an Identity owns                                                                                                                                                                                                                                                                                                                |
| compliances                          | Represents a restriction all investor must comply with for a given Asset e.g. All investors must be German citizens                                                                                                                                                                                                                                                  |
| asset\_holders                       | Represents how much of a given Asset an Identity owns                                                                                                                                                                                                                                                                                                                |
| asset\_documents                     | Represents off chain documentation for an Asset. A hash should be included on chain so readers can be sure their copy has not been tampered with e.g. A companies 10-K report                                                                                                                                                                                        |
| migrations                           | Represents the list of migrations executed                                                                                                                                                                                                                                                                                                                           |
| asset\_transactions                  | Represents all the transactions related to an Asset                                                                                                                                                                                                                                                                                                                  |
| fundings                             | Represents an investment into an Asset                                                                                                                                                                                                                                                                                                                               |
| asset\_mandatory\_mediators          | NULL                                                                                                                                                                                                                                                                                                                                                                 |
| subquery\_versions                   | Represents the deployed version of the node indexing the data                                                                                                                                                                                                                                                                                                        |
| polyx\_transactions                  | Represents transactions involving POLYX                                                                                                                                                                                                                                                                                                                              |
| child\_identities                    | Represents the parent child mapping for an Identity                                                                                                                                                                                                                                                                                                                  |
| multi\_sigs                          | Represents a MultiSig                                                                                                                                                                                                                                                                                                                                                |
| multi\_sig\_signers                  | Represents a MultiSig signer                                                                                                                                                                                                                                                                                                                                         |
| multi\_sig\_proposals                | Represents a MultiSig proposal                                                                                                                                                                                                                                                                                                                                       |
| multi\_sig\_proposal\_votes          | Represents a MultiSig proposal vote                                                                                                                                                                                                                                                                                                                                  |
| meditator\_affirmations              | Represents a mediator's approval for an instruction                                                                                                                                                                                                                                                                                                                  |
| events                               | Information of a chain state transition on. For most use cases a more specific entity should be queried                                                                                                                                                                                                                                                              |
| extrinsics                           | Represents external data included into the chain. Virtually all user actions, as well as runtime operations are extrinsics. Usually extrinsics are signed. When the block author includes data, e.g. `timestamp.set` then the signature is implied. This is indicated with `signed = 0`                                                                              |

**Step 4 : Select tables of interest.**

| table\_name                      | table\_description                                                                                                                                                                                                                                     |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| assets                           | Represents a tokenized Asset on the Polymesh chain. The central data structure for the ecosystem                                                                                                                                                       |
| asset\_transactions              | Represents all the transactions related to an Asset                                                                                                                                                                                                    |
| asset\_holders                   | Represents how much of a given Asset an Identity owns                                                                                                                                                                                                  |
| identities                       | Represents a person or business on chain.                                                                                                                                                                                                              |
| legs                             | Represents the movement of a single Asset in a trade, e.g. Alice will give Bob 1 USDS                                                                                                                                                                  |
| settlements                      | Represents a trade of assets between parties                                                                                                                                                                                                           |
| fundings                         | Represents an investment into an Asset                                                                                                                                                                                                                 |
| stat\_types                      | Represents an on chain statistic about the Asset owners. e.g. How many investors hold the Asset.                                                                                                                                                       |
| investments                      | Represents participation in an STO                                                                                                                                                                                                                     |
| ticker\_external\_agent\_actions | Represents an administrative action on an Asset, e.g. tokens issued, compliance rules updated, document added, etc.                                                                                                                                    |
| venues                           | Represents a place to trade assets. This allows for additional mediation and control over the exchange of Assets e.g. An asset may specify it can only be exchanged at a particular Venue, allowing the Venue owner to explicitly approve transactions |

**Step 4 :** Familiarize ourselves with the data schema for tables of interests.

```

SELECT 
    column_name, 
    data_type, 
    character_maximum_length, 
    column_default, 
    is_nullable 
FROM 
    information_schema.columns 
WHERE 
    table_schema = 'public' 
    AND table_name = '{{table_name}}';


```

For instance, for {{table\_name}} = assets, the query returns

<figure><img src="https://243096197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEJbeWS9CeNvCKkvrw412%2Fuploads%2F1eHAv0GzijeX6ALmVq1u%2Fimage.png?alt=media&amp;token=1c78d84e-cfcb-4a02-94ec-0155e497fb1a" alt=""><figcaption></figcaption></figure>
