> For the complete documentation index, see [llms.txt](https://docs-tron.tronify.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-tron.tronify.io/tron-api-buyer/buyer-sale-energy.md).

# 租赁能量

### 接口调用

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

#### Headers

| Name                                      | Type   | Description                                 |
| ----------------------------------------- | ------ | ------------------------------------------- |
| api-key<mark style="color:red;">\*</mark> | String | 访问tronify.io买家管理平台获取。tradeType是userTrade时必传 |

#### Request Body

| Name                                            | Type   | Description                    |
| ----------------------------------------------- | ------ | ------------------------------ |
| fromAddress<mark style="color:red;">\*</mark>   | String | 用户地址（创建买单的钱包地址）                |
| sourceFlag<mark style="color:red;">\*</mark>    | String | 渠道来源（需要双方约定一个名称来代表三方的渠道）       |
| pledgeNum<mark style="color:red;">\*</mark>     | String | 能量数量                           |
| orderType<mark style="color:red;">\*</mark>     | String | ENERGY                         |
| pledgeHour<mark style="color:red;">\*</mark>    | String | 目前支持0、1、3                      |
| pledgeDay<mark style="color:red;">\*</mark>     | String | 传值整数，如：0、1、2、3                 |
| tradeType<mark style="color:red;">\*</mark>     | String | userTrade                      |
| pledgeAddress<mark style="color:red;">\*</mark> | String | 能量/带宽接收地址。 可以传多个地址批量租赁，地址间用,分割 |
| pledgeMinute<mark style="color:red;">\*</mark>  | String | 目前支持0、10                       |

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

```
{
    "resCode": 100,
    "resMsg": "Success",
    "data": {
        "orderId": "16zi4ynw_sdvn_qv8h_ujfc_crfsgyi07zat",
        "fromAddress": "TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k",//钱包地址
        "pledgeAddress": "TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k",//接收能量地址
        "pledgeDay": 3,
        "source": "tronLink",
        "orderType": "ENERGY",
        "orderPrice": 110,
        "pledgeNum": 500,
        "pledgeTrxNum": 0.165
    }
}
```

{% endtab %}
{% endtabs %}

### 调用示例

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

```
// example
const params = {
    fromAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeDay: 3,
    pledgeHour: 0,
    pledgeMinute: 0,
    orderType: 'ENERGY',
    pledgeNum: 500,
    sourceFlag: 'tronLink',
    tradeType: 'userTrade'
}
const headers = {
  'api-key': 'your-api-key'
};
 const res = await axios.post('https://open.tronify.io/api/tronRent/addTronRentRecord',params, { headers })
 console.log(res)
 if(res.resCode === '100'){
   //...  
 }
```

{% endtab %}
{% endtabs %}

### Postman 示例

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