> 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/create-a-sell-order.md).

# 创建出售订单

### 接口调用

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

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

#### Request Body

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| relateOrderId<mark style="color:red;">\*</mark> | String | 买单Id                     |
| saleAddress<mark style="color:red;">\*</mark>   | String | 用户地址（创建出售订单的钱包地址）        |
| sourceFlag<mark style="color:red;">\*</mark>    | String | 渠道来源（需要双方约定一个名称来代表三方的渠道） |
| buyPledgeNum<mark style="color:red;">\*</mark>  | String | 能量/带宽出售数量                |
| payTrxAddress<mark style="color:red;">\*</mark> | String | trx接收地址                  |

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

```javascript
{
    "resCode": 100,
    "resMsg": "Success",
    "data": {
        "orderId": "82gaugby_r7oh_ki1y_f2ma_ltelk84hivte",
        "relateOrderId": "3j354cx4_a4to_hbck_3amx_zrc0zh51dfkg",
        "transaction": {
            "visible": false,
            "txID": "14fc0e21c3be5889bb413c2406b184df724ce0cefa239adf1e3ed8368e39d741",
            "raw_data": {
                "contract": [
                    {
                        "parameter": {
                            "value": {
                                "balance": 301000000,
                                "resource": "ENERGY",
                                "receiver_address": "41242e5341ccd7d16af9e3a3b1c5cb07794f596609",
                                "lock": true,
                                "owner_address": "41dcf5a07cfac1534c2410714d6ba6576f49c4a6d7"
                            },
                            "type_url": "type.googleapis.com/protocol.DelegateResourceContract"
                        },
                        "type": "DelegateResourceContract"
                    }
                ],
                "ref_block_bytes": "141a",
                "ref_block_hash": "b29ae11706ac4963",
                "expiration": 1682213709000,
                "timestamp": 1682213651693
            },
            "raw_data_hex": "0a02141a2208b29ae11706ac496340c8c980defa305a75083912710a35747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e44656c65676174655265736f75726365436f6e747261637412380a1541dcf5a07cfac1534c2410714d6ba6576f49c4a6d7100118c0cac38f01221541242e5341ccd7d16af9e3a3b1c5cb07794f596609280170ed89fdddfa30"
        }
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

### 调用示例

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

```
// example
const params = {
    relateOrderId: 'mt1wxcl1_dplo_r0qp_5bho_w5an5hev6d70',
    saleAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    payTrxAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    buyPledgeNum: 600,
    sourceFlag: 'tronLink'
}
 const res = await axios.post('https://open.tronify.io/api/tronRent/addTronSale',params)
 console.log(res)
 if(res.resCode === '100'){
    const signedTx = await tronWeb.trx.sign(res.data.transaction)
    const sellerOrderParams = {
        "orderId": res.data.orderId,
        "pledgeHash": signedTx.txID,
        "signedData": signedTx
    }
    const res = await axios.post('https://open.tronify.io/api/tronRent/uploadPledgeHash',sellerOrderParams )
 
 }
```

{% endtab %}
{% endtabs %}

### Postman 示例

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