创建带宽买单
创建购买带宽的买单
接口调用
POST
https://open.tronify.io/api/tronRent/addTronRentRecord
以下参数带*字段为必填,不带*号为选填
Request Body
租赁时长,单位(天)
支持1-30天
(pledgeDay, pledgeHour不能同时为空)
{
"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
}
}
调用示例
// 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'){
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 示例