创建trx能量买单

创建购买能量的订单

接口调用

POST https://open.tronify.io/api/tronRent/addTronRentRecord

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

Request Body

Name
Type
Description

fromAddress*

String

用户地址(创建买单的钱包地址)

pledgeAddress*

String

能量

pledgeNum*

int

能量数量(需大于10000)

orderPrice

String

价格

交易类型为freedom时,必选,支持30及以上数值

交易类型为fastTrade、EnenryTreasure时,不可选

tradeType

String

交易类型(

freedom:自助交易,能量可以按照天冻结

fastTrade: 快速租赁,支持按分钟、小时和天租赁

EnenryTreasure:能量宝,支持按分钟、小时和天租赁

默认:freedom

orderType*

String

ENERGY

sourceFlag*

String

渠道来源(需要双方约定一个名称来代表三方的渠道)

pledgeDay

String

租用时长,单位(天)

交易类型为freedom时,必选,支持3-30天

交易类型为fastTrade、EnenryTreasure时,可选,支持1-30天

(pledgeDay, pledgeHourpledgeMinute 不能同时为空)

pledgeHour

String

租用时长,单位(小时)

交易类型为fastTrade、EnenryTreasure时,可选,取值1,3

pledgeMinute

String

租用时长,单位(分钟)

交易类型为fastTrade、EnenryTreasure时,可选,取值10

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

调用示例

// example
const params = {
    fromAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    tradeType: 'fastTrade',
    pledgeDay: '3',
    orderType: 'ENERGY',
    orderPrice: 110,
    pledgeNum: 32000,
    sourceFlag: 'tronLink'
}
//调用创建能量买单接口
const res = await axios.post('https://open.tronify.io/api/tronRent/addTronRentRecord',params)
console.log(res)
if(res.resCode === '100'){
    const orderId = res.data.orderId;
    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'){
        // ...
    }

}

Postman 示例

Last updated