Step 1: Get Extendable Delegates

Check all extendable delegates

POST https://api.tronsave.io/v2/get-extendable-delegates

Rate limit: 1 request per 1 second

Headers

Name
Type
Description

apikey

String

Tronsave api key that present for internal account.

Request Body

Name
Type
Description

extendTo*

String

Time in milliseconds you want to extend to

receiver*

String

The address that received resource delegate

requester

String

The address of the requester.. If not provided, the requester is taken from the API key.

resourceType

String

"ENERGY" or "BANDWIDTH", default: "ENERGY"

maxPriceAccepted

Number

Number maximum price you want to pay to extend

  {
            "extendOrderBook": [
                {
                    "price": 133,
                    "value": 64319
                },
                ...
            ], //Overview extends the resource amount at every single price
            "totalDelegateAmount": 64319, 
            //Total current delegate of receiver address in tronsave
            "totalAvailableExtendAmount": 64319,
            //Total available delegate of the receiver address in tronsave
            "totalEstimateTrx": 8554427,
            //Estimate TRX payout if using extend_data below to create extend request
            "yourBalance": 20000000,
            //api key's internal balance 
            "isAbleToExtend": true,
            //Compare balance internal and total_estimate_trx 
            "extendData": [
                {
                    "delegator": "TMN2uTdy6rQYaTm4A5g732kHRf72222222",
                    "isExtend": true,
                    "extraAmount": 0,
                    "extendTo": 1728459019
                }
            ]
            //extend_data that is used to create Extend requests in Step 2
}

Example

{
    "extendTo":1728704969000,
    "maxPriceAccepted":165,
    "receiver":"TFwUFWr3QV376677Z8VWXxGUAMF11111111",
    "resourceType": "ENERGY"
}

Example Code

const GetEstimateExtendData = async (extendTo, maxPriceAccepted) => {
    const url = TRONSAVE_API_URL + `/v2/get-extendable-delegates`
    const body = {
        extendTo, //time in seconds you want to extend to
        receiver: RECEIVER,   //the address that receives the resource delegate
        maxPriceAccepted, //Optional. Number the maximum price you want to pay to extend
        resourceType: RESOURCE_TYPE, //ENERGY or BANDWIDTH. optional. The default is ENERGY
    }
    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 
     * @link  
       {
            "error": false,
            "message": "Success",
            "data": {
                "extendOrderBook": [
                    {
                        "price": 784,
                        "value": 1002
                    }
                ],
                "totalDelegateAmount": 5003,
                "totalAvailableExtendAmount": 5003,
                "totalEstimateTrx": 4085783,
                "isAbleToExtend": true,
                "yourBalance": 2377366851,
                "extendData": [
                    {
                        "delegator": "TGGVrYaT8Xoos...6dmSZkohGGcouYL4",
                        "isExtend": true,
                        "extraAmount": 0,
                        "extendTo": 1745833276
                    },
                    {
                        "delegator": "TQBV7xU489Rq8Z...zBhJMdrDr51wA2",
                        "isExtend": true,
                        "extraAmount": 0,
                        "extendTo": 1745833276
                    },
                    {
                        "delegator": "TSHZv6xsYHMRCbdVh...qNozxaPPjDR6",
                        "isExtend": true,
                        "extraAmount": 0,
                        "extendTo": 1745833276
                    }
                ]
            }
        }
     */
    return response
}

Last updated