# 创建带宽买单

### 接口调用

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

**以下参数带\*字段为必填，不带\*号为选填**

#### Request Body

| Name                                            | Type   | Description                                                         |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------- |
| fromAddress<mark style="color:red;">\*</mark>   | String | 用户地址（创建买单的钱包地址）                                                     |
| pledgeAddress<mark style="color:red;">\*</mark> | String | 带宽接收地址                                                              |
| pledgeNum<mark style="color:red;">\*</mark>     | String | 带宽数量                                                                |
| orderPrice                                      | String | <p>价格，默认900</p><p>支持700及以上数值</p>                                    |
| pledgeDay                                       |        | <p>租赁时长，单位（天）</p><p>支持1-30天</p><p>(pledgeDay, pledgeHour不能同时为空)</p> |
| sourceFlag<mark style="color:red;">\*</mark>    | String | 渠道来源（需要双方约定一个名称来代表三方的渠道）                                            |
| orderType<mark style="color:red;">\*</mark>     | String | BANDWIDTH                                                           |
| pledgeHour                                      | String | <p>租赁时长，单位（小时）</p><p>支持1, 3小时</p>                                   |

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

```javascript
{
    "resCode": 100,
    "resMsg": "Success",
    "data": {
        "orderId": "16zi4ynw_sdvn_qv8h_ujfc_crfsgyi07zat",
        "platformAddr": "TAdm9uEjiDge14T6AkZuo8vCNBEV1Fitmn",//转trx的目标地址
        "fromAddress": "TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k",//钱包地址
        "pledgeAddress": "TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k",//接收能量地址
        "pledgeDay": 3,
        "source": "tronLink",
        "orderType": "BANDWIDTH",
        "orderPrice": 110,
        "pledgeNum": 3500,
        "pledgeTrxNum": 9.45
    }
}
```

{% endtab %}
{% endtabs %}

### 调用示例

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

<pre><code>// example
const params = {
    fromAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeDay: 3,
    orderType: 'BANDWIDTH',
    orderPrice: 900,
    pledgeNum: 3500,
    sourceFlag: 'tronLink'
}
//调用创建带宽买单接口
const res = await axios.post('https://open.tronify.io/api/tronRent/addTronRentRecord',params)
console.log(res)
    if(res.resCode === '100'){
<strong>    const orderId = res.data.orderId;
</strong>    const transaction = res.data.transaction;
    //签名交易数据
    const signedTx = await tronWeb.trx.sign(transaction)
    const params = {
        "orderId": orderId,
        "fromHash": signedTx.txID,
        "signedData": signedTx
    };
    //使用签名后的数据调用上传买单哈希接口，完成交易
    const rest = await axios.post('https://open.tronify.io/api/tronRent/uploadHash', params );
    console.log(rest)
    if(rest.resCode === '100'){
        // ...
    }
}
</code></pre>

{% endtab %}
{% endtabs %}

### Postman 示例

<figure><img src="/files/SJytKaRKoV54CzvQEwKv" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-tron.tronify.io/tron-api/create-bandwidth-order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
