# Get Balance of an user address

Number of ERC-20 token hold by an address can be found using this method. The weightage for this API is 5

## API Specification

## Get Balance

<mark style="color:green;">`POST`</mark> `https://api.krypcore.com/api/v0/ft-manager/balanceOf`

Balance of an user's address can be gathered  under the given instance.&#x20;

#### Headers

| Name                                            | Type   | Description                      |
| ----------------------------------------------- | ------ | -------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | User Auth Key obtained from Dash |
| DappId<mark style="color:red;">\*</mark>        | String | DappId                           |

#### Request Body

| Name                                              | Type   | Description                                                         |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------- |
| contractAddress<mark style="color:red;">\*</mark> | String | The contract address of the ERC20 token.                            |
| address<mark style="color:red;">\*</mark>         | String | An user wallet address whose ERC20 token balance is to be retrieve. |

{% tabs %}
{% tab title="200: OK User Balance Fetch successfully" %}

```javascript
{
    "Data": 1000000000000000000,
    "Message": "Balance fetched successfully",
    "Status": "SUCCESS"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Mandatory Parameters are missing" %}

```javascript
{
    "Data": null,
    "Message": "Mandatory params missing",
    "Status": "FAILURE"
}
```

{% endtab %}

{% tab title="401: Unauthorized Authorization Key is missing" %}

```javascript
{
    "message": "Missing API key found in request"
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might call this method using our official libraries, or via `curl`:

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request POST 'https://api.krypcore.com/api/v0/ft-manager/balanceOf' \
--header 'Authorization: xxxxxxxxxxxxx' \
--header 'DappId: xxxxxxxxxxxxxx' \
--header 'ChainId: xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "contractAddress":"0xa9BCB7E413FfE96575390c6F44F54607b44F030a",
    "address":"0x688612BD8e65FF693070A875b6a49672502a0707"
}'
```

{% endtab %}

{% tab title="Node.js (Fetch)" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "contractAddress": "0xa9BCB7E413FfE96575390c6F44F54607b44F030a",
  "address": "0x688612BD8e65FF693070A875b6a49672502a0707"
});

 

var config = {
  method: 'post',
  url: 'https://api.krypcore.com/api/v0/ft-manager/balanceOf',
  headers: { 
    'Authorization': 'xxxxxxxxxxxxxx', 
    'DappId': 'xxxxxxxxxxxxxxxx', 
    'ChainId': 'xxxx',
    'Content-Type': 'application/json'
  },
  data : data
};

 

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}

{% tab title="Python " %}

```python
import requests
import json

 

url = "https://api.krypcore.com/api/v0/ft-manager/balanceOf"

 

payload = json.dumps({
  "contractAddress": "0xa9BCB7E413FfE96575390c6F44F54607b44F030a",
  "address": "0x688612BD8e65FF693070A875b6a49672502a0707"
})
headers = {
  'Authorization': 'xxxxxxxxxxxxxxx',
  'DappId': 'xxxxxxxxxxxxxxxx',
  'ChainId': 'xxxx',
  'Content-Type': 'application/json'
}

 

response = requests.request("POST", url, headers=headers, data=payload)

 

print(response.text)
```

{% endtab %}

{% tab title="Golang" %}

```go
package main
import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)
func main() {
  url := "https://api.krypcore.com/api/v0/ft-manager/balanceOf"
  method := "POST"
  payload := strings.NewReader(`{
    "contractAddress":"0xa9BCB7E413FfE96575390c6F44F54607b44F030a",
    "address":"0x688612BD8e65FF693070A875b6a49672502a0707"
}
`)
  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)
  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "xxxxxxxxxxxxxxxx")
  req.Header.Add("DappId", "xxxxxxxxxxxxxxxx")
  req.Header.Add("ChainId", "xxxx")
  req.Header.Add("Content-Type", "application/json")

 

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

 

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}
