# Add Whitelisted Contract Linked to DApp

This API allows you to add a whitelisted contract linked to a decentralized application (DApp) within a specified instance

## API Specification

## Add Whitelisted Contract Linked to DApp

<mark style="color:green;">`POST`</mark> `https://api.krypcore.com/api/v0/gasless/addWhitelistedContractLinkedToDApp`

Add Whitelisted Contract Linked to DApp under the given instance.&#x20;

#### Headers

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

#### Request Body

| Name                                                 | Type   | Description                                                         |
| ---------------------------------------------------- | ------ | ------------------------------------------------------------------- |
| contractAddress<mark style="color:red;">\*</mark>    | String | The address of the contract that needs to be added to the whitelist |
| contractName<mark style="color:red;">\*</mark>       | String | The name of the contract                                            |
| linkedDAppId<mark style="color:red;">\*</mark>       | String | The ID of the DApp that linked to the contract                      |
| gasLimitConfigured<mark style="color:red;">\*</mark> | Number | The configured gas limit for the transaction                        |
| chainId                                              | Number | chain id                                                            |

{% tabs %}
{% tab title="200: OK SUCCESS" %}

```javascript
{
    "data": null,
    "message": "Whitelisted contract created successfully",
    "status": true
}
```

{% endtab %}

{% tab title="401: Unauthorized Failure in authentication" %}

```
{
    "message": "Invalid API key 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 'https://api.krypcore.com/api/v0/gasless/addWhitelistedContractLinkedToDApp' \
--header 'Authorization: 03374415-xxxx-xxxx-xxxx-1277d243034e' \
--header 'Content-Type: application/json' \
--data '{
"contractAddress": "0x5443702dd8eb3e26c31a20b81fcfd292cfxxxxxx",
"contractName": "demo",
"linkedDAppId": "DEV_DEMO_PACE_46_xxxxxxxx",
"gasLimitConfigured": 0.5,
"chainId": 80001
}'
```

{% endtab %}

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

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "03374415-xxxx-xxxx-xxxx-1277d243034e");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "contractAddress": "0x5443702dd8eb3e26c31a20b81fcfd292cfxxxxxx",
  "contractName": "demo",
  "linkedDAppId": "DEV_DEMO_PACE_46_xxxxxxxx",
  "gasLimitConfigured": 0.5,
  "chainId": 80001
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.krypcore.com/api/v0/gasless/addWhitelistedContractLinkedToDApp", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Python " %}

```python
import requests
import json

url = "https://api.krypcore.com/api/v0/gasless/addWhitelistedContractLinkedToDApp"

payload = json.dumps({
  "contractAddress": "0x5443702dd8eb3e26c31a20b81fcfd292cfxxxxxx",
  "contractName": "demo",
  "linkedDAppId": "DEV_DEMO_PACE_46_xxxxxxxx",
  "gasLimitConfigured": 0.5,
  "chainId": 80001
})
headers = {
  'Authorization': '03374415-xxxx-xxxx-xxxx-1277d243034e',
  '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/gasless/addWhitelistedContractLinkedToDApp"
  method := "POST"

  payload := strings.NewReader(`{`+"
"+`
"contractAddress": "0x5443702dd8eb3e26c31a20b81fcfd292cfxxxxxx",`+"
"+`
"contractName": "demo",`+"
"+`
"linkedDAppId": "DEV_DEMO_PACE_46_xxxxxxxx",`+"
"+`
"gasLimitConfigured": 0.5,`+"
"+`
"chainId": 80001`+"
"+`
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "03374415-xxxx-xxxx-xxxx-1277d243034e")
  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 %}
