# Buyer charge

### Endpoint usage

<mark style="color:green;">`POST`</mark> `https://open.tronify.io/api/tronRent/user/recharge`

The fields with \* are required, and the fields without \* are optional

#### Headers

| Name                                      | Type   | Description                                                      |
| ----------------------------------------- | ------ | ---------------------------------------------------------------- |
| api-key<mark style="color:red;">\*</mark> | String | Access the buyer management platform of tronify.io to obtain it. |

#### Request Body

| Name                                         | Type   | Description                                                                                       |
| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| address<mark style="color:red;">\*</mark>    | String | User address (Wallet address)                                                                     |
| sourceFlag<mark style="color:red;">\*</mark> | String | Source channel (Both sides need to agree on a name to represent the channel of the third parties) |
| balance<mark style="color:red;">\*</mark>    | String | The amount of TRX                                                                                 |

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

```javascript
{
    "resCode": 100,
    "resMsg": "Success",
    "data": {
        "visible": false,
        "txID": "b4bb945886a562b2be5e01cff2bab4ec9d994fbc8879dcb3a06331c242d7e518",
        "raw_data": {
            "contract": [
                {
                    "parameter": {
                        "value": {
                            "amount": 2000000,
                            "owner_address": "41dcf5a07cfac1534c2410714d6ba6576f49c4a6d7",
                            "to_address": "418dfb584145620fbe46b7d557b1edff4c448a0752"
                        },
                        "type_url": "type.googleapis.com/protocol.TransferContract"
                    },
                    "type": "TransferContract"
                }
            ],
            "ref_block_bytes": "ca75",
            "ref_block_hash": "1abdca8db37bb677",
            "expiration": 1687276659000,
            "timestamp": 1687276601209
        },
        "raw_data_hex": "0a02ca7522081abdca8db37bb67740b8c29acc8d315a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a1541dcf5a07cfac1534c2410714d6ba6576f49c4a6d71215418dfb584145620fbe46b7d557b1edff4c448a07521880897a70f9fe96cc8d31"
    }
}
```

{% endtab %}
{% endtabs %}

### code example

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

```
// example
const params = {
    address: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    balance: 100,
    sourceFlag: 'tronLink'
}
const headers = {
  'api-key': 'your-api-key'
};
 const res = await axios.post('https://open.tronify.io/api/tronRent/user/recharge',params, { headers })
 console.log(res)
 if(res.resCode === '100'){
    const signedTx = await tronWeb.trx.sign(res.data)
    const broastTx = await tronWeb.trx.sendRawTransaction(signedTx)
    return broastTx.txid 
 }
```

{% endtab %}
{% endtabs %}

### Postman example

<figure><img src="https://3188465811-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fnv0Qbx2yTtH3TKQFd528%2Fuploads%2Ft3lAONdfqA8sCUxofjJf%2F16.jpg?alt=media&#x26;token=ea2ae92c-7c28-4970-bae8-ca8b73425ce1" alt=""><figcaption></figcaption></figure>
