Estimate TRX
Get an estimate of TRX
POST
https://api.tronsave.io/v2/estimate-buy-resource
POST
https://api.tronsave.io/v2/estimate-buy-resource
Rate limit: 15 requests per 1 second
Request params
resourceAmount*
Number
The number of resources.
unitPrice
String, Number
"FAST", "MEDIUM", "SLOW", or number:
-"FAST": If the market is ready to fill = 100%, FAST = MEDIUM. If the market is 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 is ready to fill = 0%, MEDIUM = SLOW + 10.
-"SLOW": The lowest price that can be set for this order.
-If the price is a number, the price unit is equal to SUN
durationSec
Number
The duration of the bought resource, time unit, is in seconds. Default 3d
requester
String
The address of requester.
receiver
String
The address of receiver resource.
resourceType
String
"ENERGY" or "BANDWIDTH", default: "ENERGY"
options
Object
optional
options.allowPartialFill
Boolean
Allow the order to be filled partially or not
options.minResourceDelegateRequiredAmount
Number
The minimum resource amount delegated by a single provider.
Request params example
{
"resourceType": "ENERGY",
"receiver": "TFwUFWr3QV376677Z8VWXxGUAMF123456",
"durationSec": 259200,
"resourceAmount": 32000,
"unitPrice": "MEDIUM",
"options": {
"allowPartialFill": true,
"minResourceDelegateRequiredAmount": 32000
}
}
Responses
{
"error": false,
"message": "Success",
"data": {
"unitPrice": 64,
"durationSec": 259200,
"estimateTrx": 6144000,
"availableResource": 32000
}
}
Example code
const GetEstimate = async (requestAddress, receiverAddress, resourceAmount, durationSec) => {
const url = TRONSAVE_API_URL + "/v2/estimate-buy-resource";
const body = {
resourceAmount,
unitPrice: "MEDIUM",
resourceType: RESOURCE_TYPE,
durationSec,
requester: requestAddress,
receiver: receiverAddress,
options: {
allowPartialFill: true,
},
};
const data = await fetch(url, {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify(body),
});
const response = await data.json();
/**
* Example response
{
"error": false,
"message": 'Success',
"data": {
"unitPrice": 50,
"durationSec": 259200,
"estimateTrx": 7680000,
"availableResource": 32000
}
}
*/
return response;
};
Last updated