# Tokens

## Get ERC20 Token Total Supply by Contract Address

Returns the current amount of an ERC-20 token in circulation.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/{address}/total-supply`

**Query Parameters**

| Name    | Type                                            | Description |
| ------- | ----------------------------------------------- | ----------- |
| `chain` | `wemix`  \| `wemixTestnet` (default to `wemix`) | Chain       |

**Example:**

```
http://scan.wemix.com/api/token/0x7d72b22a74a216af4a002a1095c8c707d6ec1c5f/total-supply?chain=wemix
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "address": "0x7d72b22a74a216af4a002a1095c8c707d6ec1c5f",
    "chain": "wemix",
    "totalSupply": "7392337.121269413755837723"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch token total supply"
}
```
{% endtab %}
{% endtabs %}

## Get ERC20 Token Account Balance for Token Contract Address

Returns the current balance of an ERC-20 token of an address.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/balance?address={address}&contractaddress={contractaddress}`

**Query Parameters**

| Name                          | Type                                           | Description                                         |
| ----------------------------- | ---------------------------------------------- | --------------------------------------------------- |
| `chain`                       | `wemix` \| `wemixTestnet` (default to `wemix`) | Chain                                               |
| `address` (required)          | `string`                                       | representing the address to check for token balance |
| `contractaddress`(required)   | `string`                                       | contract address of the ERC20 Token.                |

**Example:**

```
http://scan.wemix.com/api/token/balance?address=0x81efc0abf0c3c04b8b0369cc50804b309beb4bf3&contractaddress=0x770d9d14c4ae2f78Dca810958c1d9b7ea4620289
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "address": "0x81efc0abf0c3c04b8b0369cc50804b309beb4bf3",
    "contractAddress": "0x770d9d14c4ae2f78Dca810958c1d9b7ea4620289",
    "chain": "wemix",
    "balance": "2104351372244000000000000",
    "formattedBalance": "2104351.372244",
    "decimals": 18,
    "symbol": "CROW",
    "name": "CROW"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing address parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing contractaddress parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid address format"
}

OR

{
    "error": "Invalid contract address format"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch token balance"
}
```
{% endtab %}
{% endtabs %}

## Get Token Holder List by Contract Address

Return the ERC20 token holders and number of tokens held.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/balance?address={address}&contractaddress={contractaddress}`

**Query Parameters**

| Name                        | Type                                            | Description                              |
| --------------------------- | ----------------------------------------------- | ---------------------------------------- |
| `chain`                     | `wemix`  \| `wemixTestnet` (default to `wemix`) | Chain                                    |
| `contractaddress`(required) | `string`                                        | contract address of the ERC20 Token.     |
| `page`                      | `integer`                                       | page number                              |
| `offset`                    | `integer` (`10` \| `15` \| `30` \| `45`)        | the number of results displayed per page |

**Example:**

```
http://scan.wemix.com/api/token/holders?contractaddress=0x770d9d14c4ae2f78Dca810958c1d9b7ea4620289&page=1&offset=45
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "contractAddress": "0x770d9d14c4ae2f78Dca810958c1d9b7ea4620289",
    "chain": "wemix",
    "page": 1,
    "offset": 30,
    "holders": [
        {
            "holderAddress": "0x65285a4788de8c5cc29120e153c9fe1fd1dbe4f0",
            "quantity": "3453439.200000000072351744"
        },
        {
            "holderAddress": "0x81efc0abf0c3c04b8b0369cc50804b309beb4bf3",
            "quantity": "2104351.400000000079429632"
        },
        {
            "holderAddress": "0xaa6249cd06f7f40ade3ccdddc6e60ab3c0424df2",
            "quantity": "808610.60000000002490368"
        },
        {
            "holderAddress": "0xfbbfdf33db6866a1343c1ca2b01c4c94f22dd917",
            "quantity": "566924.800000000016777216"
        },
        ...
    ]
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing contractaddress parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Offset must be a valid number and one of: 10, 15, 30, 45"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch token holders"
}
```
{% endtab %}
{% endtabs %}

## Get Token Holder Count by Contract Address

Return the ERC20 token holder count.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/holder-count?contractaddress={contractaddress}`

**Query Parameters**

| Name                        | Type                                            | Description                          |
| --------------------------- | ----------------------------------------------- | ------------------------------------ |
| `chain`                     | `wemix`  \| `wemixTestnet` (default to `wemix`) | Chain                                |
| `contractaddress`(required) | `string`                                        | contract address of the ERC20 Token. |

**Example:**

```
http://scan.wemix.com/api/token/holder-count?contractaddress=0x770d9d14c4ae2f78Dca810958c1d9b7ea4620289
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "contractAddress": "0x770d9d14c4ae2f78Dca810958c1d9b7ea4620289",
    "chain": "wemix",
    "holderCount": 75571
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing contractaddress parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch token holder count"
}
```
{% endtab %}
{% endtabs %}

## Get Token Info Contract Address

Return the project information given a contract address.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/info?contractaddress={contractaddress}`

**Query Parameters**

| Name                        | Type                          | Description                                      |
| --------------------------- | ----------------------------- | ------------------------------------------------ |
| `chain`                     | `wemix`  (default to `wemix`) | Chain                                            |
| `contractaddress`(required) | `string`                      | contract address of the ERC20 _or_ ERC721 Token. |

**Example:**

```
http://scan.wemix.com/api/token/info?contractaddress=0x7d72b22a74a216af4a002a1095c8c707d6ec1c5f&chain=wemix
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "contractAddress": "0x7d72b22a74a216af4a002a1095c8c707d6ec1c5f",
    "tokenName": "Wrapped Wemix",
    "symbol": "WWEMIX",
    "divisor": "18",
    "tokenType": "ERC20",
    "totalSupply": "7129567.587017832703804373",
    "description": "",
    "website": "https://www.wemix.com/",
    "email": "",
    "blog": "https://medium.com/wemix-communication",
    "reddit": "",
    "facebook": "https://www.facebook.com/WEMIXBlockchain/",
    "twitter": "https://twitter.com/WemixNetwork",
    "github": "",
    "telegram": "https://t.me/WEMIX_ANNouncement",
    "wechat": "",
    "linkedin": "",
    "discord": "",
    "whitepaper": "https://www.wemix.com/download/WEMIX3.0_Whitepaper.pdf",
    "tokenPriceUSD": "0.8310217734195009"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing contractaddress parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}

{% tab title="404" %}
```json
{
    "error": "Can not find token info or unable to determine token type for the given contract"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch token information"
}
```
{% endtab %}
{% endtabs %}

## Get ERC20 Holdings for an Address

Return the erc20 tokens held by an address.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/erc20-holdings?address={address}`

**Query Parameters**

| Name                | Type                                           | Description |
| ------------------- | ---------------------------------------------- | ----------- |
| `chain`             | `wemix` \| `wemixTestnet` (default to `wemix`) | Chain       |
| `address`(required) | `string`                                       | address     |

**Example:**

```
http://scan.wemix.com/api/token/erc20-holdings?address=0x4290997f9cf89b36a4131deed8b6aed205868575&chain=wemix
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "address": "0x4290997f9cf89b36a4131deed8b6aed205868575",
    "chain": "wemix",
    "totalTokens": 3,
    "tokens": [
        {
            "TokenAddress": "0x00caec2e118abc4c510440a8d1ac8565fec0180c",
            "TokenName": "WemixFi LP WEMIX-WEMIX$",
            "TokenSymbol": "WFLP-V1",
            "TokenQuantity": 1.6577329413881237,
            "TokenDivisor": "18"
        },
        {
            "TokenAddress": "0x29b440f80fd4be4d0acfb5f14aeafd5dcbf371b1",
            "TokenName": "EXDRA2",
            "TokenSymbol": "EXDRA2",
            "TokenQuantity": 1.0135033358731709,
            "TokenDivisor": "18"
        },
        {
            "TokenAddress": "0xb3c3530c3e54914df9f4c5875fb682e547eecbe2",
            "TokenName": "PLAY Token",
            "TokenSymbol": "PLAY",
            "TokenQuantity": 193.09,
            "TokenDivisor": "18"
        }
    ]
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing required parameter: address"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid address format"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch ERC20 token holdings"
}
```
{% endtab %}
{% endtabs %}

## Get ERC721 Holdings for an Address

Return the erc721 tokens held by an address.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/erc721-holdings?address={address}`

**Query Parameters**

| Name                | Type                                           | Description |
| ------------------- | ---------------------------------------------- | ----------- |
| `chain`             | `wemix` \| `wemixTestnet` (default to `wemix`) | Chain       |
| `address`(required) | `string`                                       | address     |

**Example:**

```
http://scan.wemix.com/api/token/erc721-holdings?address=0x00277efddc396ead57a2536cc54a9dc8d7517902&chain=wemix
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "address": "0x00277efddc396ead57a2536cc54a9dc8d7517902",
    "chain": "wemix",
    "totalNFTs": 3,
    "nfts": [
        {
            "ContractAddress": "0x55c124d12af088498877eaf814007c12546ad625",
            "ContractName": "wemixchamp",
            "ContractSymbol": "wemixchamp",
            "TokenId": "4451",
            "TransactionHash": "0x6ec07049e293be44a7a5d29726d182791651f067960dcd46efca43c23768bb9d",
            "BlockNumber": "65250799"
        },
        {
            "ContractAddress": "0x754397ab88fdefa90894e95f281d3c59907a60af",
            "ContractName": "WEMIX CHAMPIONSHIP 2024 Ticket",
            "ContractSymbol": "WECHAMP",
            "TokenId": "3568",
            "TransactionHash": "0xdb99c5ef6b3f6f2693b7968727f574641f9045b997db18646fae56fbf0724a47",
            "BlockNumber": "65251260"
        },
        {
            "ContractAddress": "0x754397ab88fdefa90894e95f281d3c59907a60af",
            "ContractName": "WEMIX CHAMPIONSHIP 2024 Ticket",
            "ContractSymbol": "WECHAMP",
            "TokenId": "3569",
            "TransactionHash": "0xdb99c5ef6b3f6f2693b7968727f574641f9045b997db18646fae56fbf0724a47",
            "BlockNumber": "65251260"
        }
    ]
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing required parameter: address"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid address format"
}
```
{% endtab %}

{% tab title="500" %}
```json
{
    "error": "Failed to fetch ERC721 token holdings"
}
```
{% endtab %}
{% endtabs %}



## Get Historical ERC20-Token TotalSupply by ContractAddress & BlockNo

Returns the amount of an ERC-20 token in circulation at a certain block height.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/{address}/total-supply-history?block={block}`

**Query Parameters**

| Name    | Type                                                                                   | Description  |
| ------- | -------------------------------------------------------------------------------------- | ------------ |
| `chain` | `wemix` \| `wemixTestnet` (default to `wemix`)                                         | Chain        |
| `block` | <p><code>latest</code> | <code>integer</code> <br>(default to <code>latest</code>)</p> | Block height |

**Example:**

```
http://scan.wemix.com/api/token/0x732e6973595136976173af4a56eac99f52becc6e/token-supply-history?block=87413799
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "address": "0x732e6973595136976173af4a56eac99f52becc6e",
    "chain": "wemix",
    "totalSupply": "265546000000000000000000"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}
{% endtabs %}



## Get Historical ERC20-Token Account Balance for TokenContractAddress by BlockNo

Returns the balance of an ERC-20 token of an address at a certain block height.

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/{address}/total-balance-history?contractaddress={contractaddress}&block={block}`

**Query Parameters**

| Name                         | Type                                                                                   | Description                            |
| ---------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------- |
| `chain`                      | `wemix` \| `wemixTestnet` (default to `wemix`)                                         | Chain                                  |
| `contractaddress(required)`  | Hex `string`                                                                           | ERC-20 Token contract address to query |
| `block`                      | <p><code>latest</code> | <code>integer</code> <br>(default to <code>latest</code>)</p> | Block height                           |

**Example:**

```
http://scan.wemix.com/api/token/0x931a0c8f4fc83192c8aeef1a6cd6b38a11463422/token-balance-history?chain=wemix&contractaddress=0x94786463971fca0bf1c7f0cc58b81c9bb74f1e43&block=85849674
```

**Response**

{% tabs %}
{% tab title="200" %}
```json
{
    "contractAddress": "0x94786463971fca0bf1c7f0cc58b81c9bb74f1e43",
    "accountAddress": "0x931a0c8f4fc83192c8aeef1a6cd6b38a11463422",
    "chain": "wemix",
    "balance": "27538000000000000000"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing contract address parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}
{% endtabs %}



## Get Address ERC721 Token Inventory By Contract Address

Returns the ERC-721 token inventory of an address, filtered by contract address, with optional pagination

<mark style="color:green;">`GET`</mark> `http://scan.wemix.com/api/token/{address}/nft-inventory?contractaddress={contractaddress}&page={page}&offset={offset}`

**Query Parameters**

| Name                         | Type                                                | Description                                                |
| ---------------------------- | --------------------------------------------------- | ---------------------------------------------------------- |
| `chain`                      | `wemix` \| `wemixTestnet` (default to `wemix`)      | Chain                                                      |
| `contractaddress(required)`  | Hex `string`                                        | ERC721 Token contract address to query                     |
| `page`                       | the `integer` page number, if pagination is enabled | Page number to return (default to 1)                       |
| `offset`                     | `integer`                                           | the number of tokens displayed per page (default to 10000) |

**Example:**

{% code overflow="wrap" %}
```
http://scan.wemix.com/api/token/0xf2b542a0a93666d403204aa27637fc5bd5002d80/nft-inventory?contractaddress=0x543fd49c5858c426402a7ca15e6e61bda18c2374
```
{% endcode %}

{% tabs %}
{% tab title="200" %}
```json
[
    {
        "TokenAddress": "0x543fd49c5858c426402a7ca15e6e61bda18c2374",
        "TokenId": "35462"
    }
]
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Missing contract address parameter"
}
```
{% endtab %}

{% tab title="400" %}
```json
{
    "error": "Invalid contract address format"
}
```
{% endtab %}
{% endtabs %}
