Step 2: Extend Request
Last updated
Last updated
POST
https://api.tronsave.io/v2/extend-request
Create a new extended request order by
Rate limit: 15 requests per 1 second
apikey*
String
Tronsave api key that present for internal account
receiver*
String
The address that received resource
extendData*
Array
resourceType
String
"ENERGY" or "BANDWIDTH", default: "ENERGY"
Return the order ID if successful.
{
"error": false,
"message": "Success",
"data": {
"orderId": "6819da2d4d1b2aadb0d44eee"
}
}
{
"MISSING_PARAMS": "Missing some params in body",
"INVALID_PARAMS": "Some params are invalid",
"INTERNAL_ACCOUNT_NOT_FOUND": "internal account does not exist",
"INTERNAL_BALANCE_ACCOUNT_TOO_LOW": "Balance is not enough",
"SOME_DELEGATE_CANNOT_EXTEND": "This delegate order can't be extended due to some errors. Please try again later."
}
{
"API_KEY_REQUIRED": "Missing api key in headers",
"INVALID_API_KEY": "api key not correct"
}
{
"RATE_LIMIT": "Rate limit reached",
}
Example
"extendData":[
{
"delegator": "TFwUFWr3QV376677Z8VWXxGUAMFSSSSSSS",
"isExtend": true,
"extraAmount": 0,
"extendTo": 1746702000
},
{
"delegator": "TFwUFWr3QV376677Z8VWXxGUAMFFFFFFFF",
"isExtend": true,
"extraAmount": 0,
"extendTo": 1746702000
},
...
],
"receiver": "TFwUFWr3QV376677Z8VWXxGUAMF1111111",
"resourceType": "BANDWIDTH"
}
{
"apikey": <YOUR_API_KEY>
}
{
"error": false,
"message": "Success",
"data": {
"orderId": "6819da2d4d1b2aadb0d44eee"
}
}
Example Code
const SendExtendRequest = async (extendTo, maxPriceAccepted) => {
const url = TRONSAVE_API_URL + `/v2/extend-request`
// Get estimate extendable delegates
const estimateResponse = await GetEstimateExtendData(extendTo, maxPriceAccepted)
const extendData = estimateResponse.data?.extendData
if (extendData && extendData.length) {
const body = {
extendData: extendData,
receiver: RECEIVER,
}
const data = await fetch(url, {
method: "POST",
headers: {
'apikey': API_KEY,
"content-type": "application/json",
},
body: JSON.stringify(body)
})
const response = await data.json()
/**
* Example response
{
error: false,
message: 'Success',
data: { orderId: '680b5ac7b09a385fb3d582ff' }
}
*/
return response
}
return []
}
function sendExtendRequest(int $extendTo, int $maxPriceAccepted): array {
$url = TRONSAVE_API_URL . "/v2/extend-request";
$estimateResponse = getEstimateExtendData($extendTo, $maxPriceAccepted);
$extendData = $estimateResponse['data']['extendData'] ?? [];
if (!empty($extendData)) {
$body = [
'extendData' => $extendData,
'receiver' => RECEIVER,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'apikey: ' . API_KEY,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
return [];
}
def send_extend_request(extend_to: int, max_price_accepted: int) -> Dict[str, Any]:
"""Send extend request"""
url = f"{TRONSAVE_API_URL}/v2/extend-request"
headers = {
'apikey': API_KEY,
'Content-Type': 'application/json'
}
estimate_response = get_estimate_extend_data(extend_to, max_price_accepted)
extend_data = estimate_response.get('data', {}).get('extendData', [])
if extend_data:
body = {
'extendData': extend_data,
'receiver': RECEIVER,
}
response = requests.post(url, headers=headers, json=body)
return response.json()
return {}
POST
https://api.tronsave.io/v2/extend-request
Rate limit: 15 requests per 1 second
receiver*
String
The address that received resource
extendData*
Array
resourceType
String
"ENERGY" or "BANDWIDTH", default: "ENERGY"
signedTx
SignedTransaction
"extendData":[
{
"delegator": TGGVrYaT8XoosBEXPp6dmSZkoh11223344,
"isExtend": true,
"extraAmount": 0,
"extendTo": 1746403201
},
...
],
"receiver": "TGGVrYaT8XoosBEXPp6dmSZkoh123456",
"resourceType": "BANDWIDTH",
"signedTx": {
"visible": false,
"txID": "446eed36e31249b98b201db2e81a3825b185f1a3d8b2fea348b24fc021e58e0d",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"amount": 5500000,
"owner_address": "417a0d868d1418c9038584af1252f85d486502eec0",
"to_address": "41055756f33f419278d9ea059bd2b21120e6add748"
},
"type_url": "type.googleapis.com/protocol.TransferContract"
},
"type": "TransferContract"
}
],
"ref_block_bytes": "0713",
"ref_block_hash": "6c5f7686f4176139",
"expiration": 1691465106000,
"timestamp": 1691465046758
},
"raw_data_hex": "0a02071322086c5f7686f417613940d084b5999d315a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a15417a0d868d1418c9038584af1252f85d486502eec0121541055756f33f419278d9ea059bd2b21120e6add74818e0fcb70670e6b5b1999d31",
"signature": ["xxxxxxxxx"]
}
}
{
"error": false,
"message": "Success",
"data": {
"orderId": "6818426a65fa8ea36d119d2c"
}
}
Example Code
const SendExtendRequest = async (extendTo, maxPriceAccepted) => {
const url = TRONSAVE_API_URL + `/v2/extend-request`
// Get estimate extendable delegates
const estimateResponse = await GetEstimateExtendData(REQUESTER_ADDRESS, extendTo, maxPriceAccepted)
const extendData = estimateResponse.data?.extendData
// check if there are extendable delegates
if (extendData && extendData.length) {
const totalEstimateTrx = estimateResponse.data?.totalEstimateTrx
// Build a signed transaction by using the private key
const signedTx = await GetSignedTx(totalEstimateTrx)
const body = {
extendData: extendData,
receiver: RECEIVER,
signedTx
}
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: { orderId: '680b5ac7b09a385fb3d582ff' }
}
*/
return response
}
return []
}
function sendExtendRequest(int $extendTo, int $maxPriceAccepted): array {
$url = TRONSAVE_API_URL . "/v2/extend-request";
$estimateResponse = getEstimateExtendData(REQUESTER_ADDRESS, $extendTo, $maxPriceAccepted);
$extendData = $estimateResponse['data']['extendData'] ?? [];
if (!empty($extendData)) {
$totalEstimateTrx = $estimateResponse['data']['totalEstimateTrx'];
$signedTx = getSignedTx($totalEstimateTrx);
$body = [
'extendData' => $extendData,
'receiver' => RECEIVER,
'signedTx' => $signedTx
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
return [];
}
def send_extend_request(extend_to: int, max_price_accepted: int) -> Dict[str, Any]:
"""Send extend request"""
url = f"{TRONSAVE_API_URL}/v2/extend-request"
estimate_response = get_estimate_extend_data(REQUESTER_ADDRESS, extend_to, max_price_accepted)
extend_data = estimate_response.get('data', {}).get('extendData', [])
if extend_data:
total_estimate_trx = estimate_response['data']['totalEstimateTrx']
signed_tx = get_signed_tx(total_estimate_trx)
body = {
'extendData': extend_data,
'receiver': RECEIVER,
'signedTx': signed_tx
}
response = requests.post(url, json=body)
return response.json()
return {}
Array extends data. Get a response from the API estimate,
Array extends data. Get a response from the API estimate,
Signed transaction, note that it is a JSON object (signedTx in )
To create a signed transaction, please follow the instructions
The amount of TRX required for signing is provided in the total_estimate_trx
field of the API response.