# Badge claim

## Get claimed badge proof

<mark style="color:blue;">`GET`</mark> `/api/v1/oauth2/badge/claiminfo`

For user used wallet mint transaction

#### Query Parameters

| Name                                          | Type   | Description |
| --------------------------------------------- | ------ | ----------- |
| white\_code<mark style="color:red;">\*</mark> | String | white code  |
| claim\_type                                   | Number | default =1  |

#### Headers

| Name                                           | Type   | Description  |
| ---------------------------------------------- | ------ | ------------ |
| Access-Token<mark style="color:red;">\*</mark> | String | access token |

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

```javascript
{
    "code": 200,
    "data": [
        {
            "code": "0f70662562ec52699a922f85ba308924",
            "contract_name": "TATEEWAA",
            "dapp_name": "MMTest",
            "is_claim_start": true, //whether start or not
            "is_upgrade_start": false,//not yet 
            "issue_type": 1,
            "level": 1,
            "nft_address": "0xdf58C11e624565ea718672A78134352f3e2cF31B",
            "nft_logo": "https://metis.memosync.org:6083/matrix-test/689c57ebcc184958876577730924c170.png",
            "nft_name": "TATEEWAA",
            /*proof for badge request parameter
             *reference：https://github.com/nuvosphere/RP2/blob/master/packages/cUtils/polisClient.ts#LL227C12-L227C12
             * tx = await contract.claimByCode(code,proof,data);
             */
            "proof": [
                "0xfa7ed0f7bdf82b1fe2608a8a80c2b0f3293d078e366a6243aeca87ab0167a320",
                "0x4ec5738617a571d260dcff0e945bbfa9ecdcd2371d5758c4e5bedd29532b0aa7",
                "0x38efb985b1bb9f53b0d69d1a60e841feaef1649246ce27c98077c6fb8c4f0098",
                "0x574cefb33df41467ab296ef28acfce8cfba84333238c8fcc95e267339b6657a5"
            ],　
            "rp": 1
        }
    ],
    "msg": ""
}
```

{% endtab %}
{% endtabs %}

## Scan and claim

<mark style="color:green;">`POST`</mark> `/api/v1/oauth2/badge/scan_mint`

For ex: "<http://me.nuvosphere.io/#/claim-badge?code=0x88f8ff6c7259031303c146cb7caa3a24055cdbb7,0ca2e6b4f2be922270dda4e95dcc3c03>" \
The code before "," is the badge address. While after"," is the code address

#### Headers

| Name                                           | Type   | Description  |
| ---------------------------------------------- | ------ | ------------ |
| Access-Token<mark style="color:red;">\*</mark> | String | access token |

#### Request Body

| Name                                                | Type    | Description                                                                               |
| --------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------- |
| contract\_address<mark style="color:red;">\*</mark> | String  | badge contract address                                                                    |
| code<mark style="color:red;">\*</mark>              | String  | claimed code                                                                              |
| wait                                                | Boolean | <p>default =true<br>false then will base on the return task ID and search the result.</p> |

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

```javascript
{
    "code": 200,
    "data": {
        "badge_logo": "https://metis.memosync.org:6083/matrix-test/c80f9830fdb24dee9df772027aa74f24.png",
        "is_upgrade": false
    },
    "msg": ""
}
// wait=false
{
    "code": 200,
    "data": {
        "task_id": "2b9b947596bc5652a035fa009eb9588e" //task id
    },
    "msg": ""
}
```

{% endtab %}
{% endtabs %}

## Get task status and result

<mark style="color:blue;">`GET`</mark> `/api/v1/oauth2/task/result`

#### Query Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| task\_id<mark style="color:red;">\*</mark> | String | task id     |

#### Headers

| Name                                           | Type   | Description  |
| ---------------------------------------------- | ------ | ------------ |
| Access-Token<mark style="color:red;">\*</mark> | String | access token |

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

```javascript
{
    "code": 200,
    "data": {  //task result
        "code": 500,
        "msg": {
            "code": -32000,
            "message": "execution reverted: address had minted."
        },
        "status": 2　//task status. 2－failure　1－succeed　0－porcessing
    },
    "msg": ""
}
```

{% endtab %}
{% endtabs %}
