{"estimateBuy": {"unit_price":90,//price buy Energy(SUN)"duration_millisec":3600,//time buy (seconds)"estimate_trx":5287085,// TRX payout for buy Energy"available_energy":58745//energy buy for transaction }}
Params
Type
Description
Required
amount
number
amount energy buy for transaction Approve
true
buy_energy_type
"FAST"| "MEDIUM"|"SLOW"
"FAST" : If market ready to fill = 100%, FAST = MEDIUM. If market ready to fill < 100%, FAST = MEDIUM + 10. If market ready to fill = 0%, FAST = SLOW + 20.
"MEDIUM" : The lowest price for the maximum market fill for this order. If market ready to fill = 0%, MEDIUM = SLOW + 10.
"SLOW": The lowest price that can be set for this order.
If price is number, price unit is equal to sun.
true
target_address
string
The address of receiver resource.
true
is_partial
boolean
Allow the order to be filled partially or not.
true
Step 4: Buy Energy
You need to transfer the amount of TRX that you have to pay for the amount of energy you want to purchase.
Info data from step 3:
{"estimateBuy": {"unit_price":90,//price buy Energy(SUN)"estimate_trx":5287085,// TRX payout for buy Energy"available_energy":58745//energy buy for transaction ... }}
Event buy energy:
constorderID=awaittronSave.buyEnergy({ amount:5287085,//estimateBuy.estimate_trx price:"MEDIUM", duration:3600000,//1 hours allowPartialFill:true, target:"TKVsa...XYZ", fulfilledOnly:true,//only fulfill transaction sponsor:"sponsor"// if you want sponsor not required });
Response:
dataBuy :"1544aca76c81df1264fcafb9"//order id
Step 5: Check status transaction
Your can check status order with API: ( buy success when fullFillPercent =100)