# Token

## **VM Category Type**

| Value | Type   | Description |
| ----- | ------ | ----------- |
| neovm | String | Neo VM      |
| wasvm | String | WASM VM     |

## 1. Get token list by token type

{% hint style="info" %}
Please note that the API response will only contain the token records corresponding to the tokens that have been verified and are listed on the **Explorer** portal. The list of currently listed [**OEP-4**](https://explorer.ont.io/token/list/oep4/10/1), [**OEP-5**](https://explorer.ont.io/token/list/oep5/10/1) and [**OEP-8**](https://explorer.ont.io/token/list/oep8/10/1) tokens can be accessed by following the respective links.
{% endhint %}

```javascript
url：/v2/tokens/{token_type}?page_size=10&page_number=1, 
method：GET, 
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":{
        "records":[
            {
                "contract_hash": "16edbe366d1337eb...4c94aeef02", 
                "creator": "AUr5QUfeBADq6BMY6Tp5yuMsUNGpsD7nLZ", 
                "description": "30", 
                "logo": "", 
                "create_time":1516946305, 
                "update_time":1516948340, 
                "contact_info":"{\"website\":\"www.test.cn\", \"github\":\"github.com\"}", 
                "total_supply": 1000000000, 
                "name": "name", 
                "symbol": "MYT", 
                "decimals": 8, 
                "address_count": 1, 
                "tx_count": 30, 
                "vm_category":"neovm"
            }
        ], 
        "total":12
    }
}
```

| Url RequestField | Type   | Description                                                               |
| ---------------- | ------ | ------------------------------------------------------------------------- |
| token\_type      | String | oep4, oep5, oep8                                                          |
| page\_size       | int    | number of records in one page (The page size is limited between 1 and 20) |
| page\_number     | int    | number of the page (At least 1 or greater)                                |

| ResponseField  | Type   | Description                                                                    |
| -------------- | ------ | ------------------------------------------------------------------------------ |
| contract\_hash | String | contract hash                                                                  |
| name           | String | contract name                                                                  |
| creator        | String | creator address                                                                |
| description    | String | contract description                                                           |
| logo           | String | logo url                                                                       |
| create\_time   | int    | create time                                                                    |
| update\_time   | int    | update time                                                                    |
| contact\_info  | String | contact information.JSON format string                                         |
| total\_supply  | int    | total supply of the token                                                      |
| symbol         | String | symbol of the token                                                            |
| decimals       | int    | decimals of the token. If the token type is oep5, response not have this param |
| address\_count | int    | total address                                                                  |
| tx\_count      | int    | total transaction                                                              |
| vm\_category   | String | neovm or wasmvm                                                                |
| total          | int    | total contract                                                                 |

### **OEP8 Token**

If the param `token_type` == **oep8**, then the result is:

```javascript
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":{
        "records":[
            {
                "contract_hash": "16edbe366d1337eb...4c94aeef02", 
                "name": "name", 
                "creator": "AUr5QUfeBADq6BMY6Tp5yuMsUNGpsD7nLZ", 
                "description": "test contract", 
                "logo": "", 
                "create_time":1516946305, 
                "update_time":1516948340, 
                "contact_info":"{\"website\":\"www.tst.cn\", \"github\":\"github.com\"}", , 
                "total_supply": {
                	"01":"1002", 
                	"02":"899", 
                	"03":"321"
                }, 
                "symbol": {
                	"01":"TNA", 
                	"02":"TNB", 
                	"03":"TNC"
                }, 
                "token_name":{
                	"01":"TokenNameFrist", 
                	"02":"TokenNameSecond", 
                	"03":"TokenNameThird"
                }, 
                "token_id":{
                	"01":"01", 
                	"02":"02", 
                	"03":"03"
                }
                "address_count": 1, 
                "tx_count": 30, 
                "vm_category":"neovm"
            }
        ], 
        "total":12
    }
}

```

## 2. Get token detail by token type and contracthash

```javascript
url：/v2/tokens/{token_type}/{contract_hash}, 
method：GET, 
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":{
        "contract_hash": "16edbe366d...99424c94aeef02", 
        "name": "name", 
        "abi":"25a80bbc...5381", 
        "code": "013ec56b6...006a5", 
        "source_code":"", 
        "create_time":1516946305, 
        "update_time":1516948340, 
        "contact_info":"{\"website\":\"www.test.cn\", \"github\":\"github.com\"}", 
        "logo":"", 
        "description": "oep4 token", 
        "creator": "AFmseVrdL9f9oyC....G6UbvhPbdYzM", 
        "ont_sum": "2123.000000000", 
        "ong_sum": "1233123123.000000000", 
        "address_count": 122, 
        "tx_count": 30, 
        "token_sum":{\"Ht\":\"124\"}", 
        "category":"oep", 
        "type":"oep4", 
        "total_supply": 1000000000, 
        "symbol": "MYT", 
        "decimals": 8, 
        "vm_category":""
    }
}
```

| Url RequestField | Type   | Description      |
| ---------------- | ------ | ---------------- |
| token\_type      | String | oep4, oep5, oep8 |
| contract\_hash   | String | contract\_hash   |

| ResponseField  | Type   | Description                                                                    |
| -------------- | ------ | ------------------------------------------------------------------------------ |
| contract\_hash | String | contract hash                                                                  |
| name           | String | contract name                                                                  |
| create\_time   | int    | create time                                                                    |
| update\_time   | int    | update time                                                                    |
| contact\_info  | String | contact information.JSON format string                                         |
| logo           | String | logo url                                                                       |
| description    | String | contract description                                                           |
| creator        | String | creator address                                                                |
| ong\_sum       | String | total ong                                                                      |
| ont\_sum       | String | total ont                                                                      |
| address\_count | int    | total address                                                                  |
| tx\_count      | int    | total transaction                                                              |
| token\_sum     | String | total token.JSON format string                                                 |
| type           | String | oep4, oep5, oep8, others                                                       |
| abi            | String | contract abi                                                                   |
| code           | String | contract code                                                                  |
| source\_code   | String | contract source code                                                           |
| category       | String | category                                                                       |
| total\_supply  | int    | total supply of the token                                                      |
| symbol         | String | symbol of the token                                                            |
| decimals       | int    | decimals of the token. If the token type is oep5, response not have this param |
| vm\_category   | String | neovm or wasmvm                                                                |

### **OEP8 Token**

If the param `token_type` == **oep8**, then the result is:

```javascript
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":{
        "contract_hash": "16edbe366d...99424c94aeef02", 
        "name": "name", 
        "abi":"25a80bbc...5381", 
        "code": "013ec56b6...006a5", 
        "source_code":"", 
        "create_time":1516946305, 
        "update_time":1516948340, 
        "contact_info":"{\"website\":\"www.test.cn\", \"github\":\"github.com\"}", 
        "logo":"", 
        "description": "LuckyNumber is a decentralized, tru.....", 
        "creator": "AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM", 
        "ont_sum": "2123.000000000", 
        "ong_sum": "1233123123.000000000", 
        "address_count": 122, 
        "tx_count": 30, 
        "token_sum":{\"Ht\":\"124\"}", 
        "category":"oep", 
        "type":"oep8", 
        "total_supply": {
            "01":"1002", 
            "02":"899", 
            "03":"321"
        }, 
        "symbol": {
            "01":"TNA", 
            "02":"TNB", 
            "03":"TNC"
        }, 
        "token_name":{
            "01":"TokenNameFrist", 
            "02":"TokenNameSecond", 
            "03":"TokenNameThird"
        }, 
        "token_id":{
            "01":"01", 
            "02":"02", 
            "03":"03"
        }
    }
}

```

## 3. Get oep8 token transaction list by token name

```javascript
url：/v2/tokens/oep8/{contract_hash}/{token_name}/transactions?page_size=10&page_number=1, 
method：GET, 
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":{
    	"records":[
    		{
                "tx_hash":"9762458cd30612509f7c...a010ccc7b347057eb5", 
                "tx_type":209, 
                "tx_time":1522210288, 
                "block_height":1212, 
                "confirm_flag":1, 
                "block_index":1, 
                "fee":"0.01", 
    		}
    	], 
    	"total":20
    }
}
```

| Url RequestField | Type   | Description                                                               |
| ---------------- | ------ | ------------------------------------------------------------------------- |
| contract\_hash   | String | oep8 token contract hash                                                  |
| token\_name      | String | oep8 token name                                                           |
| page\_size       | int    | number of records in one page (The page size is limited between 1 and 20) |
| page\_number     | int    | number of the page (At least 1 or greater)                                |

| ResponseField         | Type   | Description                                              |
| --------------------- | ------ | -------------------------------------------------------- |
| records.tx\_hash      | String | transaction hash                                         |
| records.tx\_type      | int    | transaction type (208/209)                               |
| records.tx\_time      | int    | UNIX time of the transaction                             |
| records.block\_height | int    | block height                                             |
| records.confirm\_flag | int    | transaction state on the blockchain, 0:failure 1:success |
| records.block\_index  | int    | The index of transactions within a block                 |
| records.fee           | String | fee                                                      |
| total                 | int    | total                                                    |

## 4. Get circulating supply of ONT and ONG

```
url：/v2/summary/native/circulating-supply/{token}
method：GET
```

| URL Request Field | Type   | Description    |
| ----------------- | ------ | -------------- |
| token             | String | "ont" or "ong" |

**Example Response**&#x20;

```
696743794   // number of tokens in circulation
```

## 5. Get list of token holder addresses

Return addresses with balance greater than 0. The addresses retuned from the balckend has been processed, they are ready for display in the frontend directly without furuter processing. But the balance value requires the frontend to process based on the token's precision.&#x20;

```
Native tokens (ONT&ONG):
url：/ontholder/getAssetHolder?qid=1&contract={contract_hash}}&from=0&count=10

oep4 tokens:
url：/ontholder/oep4/getAssetHolder?qid=1&contract={contract_hash}&from=0&count=10

orc20 tokens:
url：/ontholder/orc20/getAssetHolder?qid=1&contract={contract_hash}&from=0&count=10

method：GET
```

| URL Request Parameter | Type   | Description                |
| --------------------- | ------ | -------------------------- |
| qid                   | String | request ID, default: 1     |
| contract              | String | token contract address     |
| from                  | int    | first entry to query       |
| count                 | int    | number or entries to query |

**Example Response**&#x20;

```json
{
    "qid": "1",
    "method": "getAssetHolder",
    "error_code": 0,
    "error_info": "",
    "result": [
        {
            "address": "ALVbBHBEquMgtAMrFywT8yBYRmdGBLbGiV",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "20010000000000000",
            "percent": 0.9955223880597015
        },
        {
            "address": "AbtTQJYKfQxq4UdygDsbLVjE8uRrJ2H3tP",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "69990000000000",
            "percent": 0.003482089552238805
        },
        {
            "address": "AG4pZwKa9cr8ca7PED7FqzUfcwnrQ2N26w",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "10000000000000",
            "percent": 4.97512437810945E-4
        },
        {
            "address": "AcNsGxJdopi1hz6MXziFraWcgEKxdNDwSx",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "9895145371331",
            "percent": 4.92295789618457E-4
        },
        {
            "address": "AeWeheZi7a7XoHw2AoivCFDa68xfa436eg",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "104569135801",
            "percent": 5.202444567213E-6
        },
        {
            "address": "AT9sH4s84NGJYVqNHQWN6vkgb7jQ12eR7p",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "8900000000",
            "percent": 4.42786069651E-7
        },
        {
            "address": "AFqw9nGHiskTsrfqyMQr3Y3hZ759VpH5j1",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "1100000000",
            "percent": 5.4726368159E-8
        },
        {
            "address": "AZ8duTd8sPgRS2NQAArkbP3puRYtuGaCF7",
            "contract": "2f34b28eb98a1dd901d303f5294c87546fb37fe7",
            "balance": "285492868",
            "percent": 1.4203625273E-8
        }
    ]
}
```

| Response Parameter | Type   | Description                                                             |
| ------------------ | ------ | ----------------------------------------------------------------------- |
| address            | String | token holder address                                                    |
| contract           | String | token contract address                                                  |
| balance            | String | value of token holder address balance multiplied by the token precision |
| percent            | Double | percentage of balance accounting for token total supply                 |

## 6. Get the number of token holders

```
Native tokens (ONT&ONG):
url：/ontholder/getAssetHolderCount?qid=1&contract={contract_hash}

oep4 tokens:
url：/ontholder/oep4/getAssetHolderCount?qid=1&contract={contract_hash}

orc20 tokens:
url：/ontholder/orc20/getAssetHolderCount?qid=1&contract={contract_hash}

method：GET
```

| Request Parameter | Type   | Description            |
| ----------------- | ------ | ---------------------- |
| qid               | String | request id, default: 1 |
| contract          | String | token contract address |

**Example response**

```json
{
    "qid": "1",
    "method": "getAssetHolderCount",
    "error_code": 0,
    "error_info": "",
    "result": 8
}
```

| Response Parameter | Type | Description                                       |
| ------------------ | ---- | ------------------------------------------------- |
| result             | int  | number of addresses with a balance greater than 0 |
