v2 — Extend with Private Key

A complete working example that extends an existing resource delegation by paying for it with a locally signed transaction built from your private key.

This is a full, runnable example showing how to extend an existing resource delegation using the v2 Extend Orders API while paying with a transaction signed locally from your private key.

The flow has two API calls:

  1. POST /v2/get-extendable-delegates — estimates which delegates can be extended and how much TRX it will cost (totalEstimateTrx).

  2. POST /v2/extend-request — submits the extend request together with a signedTx that pays TronSave the estimated amount.

Between those two calls you build and sign a TRX transfer to TronSave's receiver address using your own private key, so TronSave never holds your funds.

This example uses TronWeb to build and sign the transfer. TronWeb version 5.3.2 is required.

Read more: https://tronweb.network/docu/docs/5.3.2/Release%20Note/

Configuration

Before running, set the following values:

Constant
Description

TRONSAVE_API_URL

TronSave API base URL. Mainnet: https://api.tronsave.io.

RECEIVER

The address that receives the extended resource delegation.

RESOURCE_TYPE

ENERGY or BANDWIDTH. Optional — defaults to ENERGY.

REQUESTER_ADDRESS

The address that requests (and pays for) the extension.

PRIVATE_KEY

Private key for REQUESTER_ADDRESS, used to sign the TRX transfer locally.

TRON_FULL_NODE

TRON full node used by TronWeb to build the transaction (e.g. https://api.trongrid.io).

TRONSAVE_RECEIVER_ADDRESS

The TronSave address that receives your payment. Mainnet: TWZEhq5JuUVvGtutNgnRBATbF8BnHGyn4S. Testnet: TATT1UzHRikft98bRFqApFTsaSw73ycfoS.

See Environments for the full list of mainnet and testnet endpoints, and the Extend Orders API reference for endpoint details.

Full example

How it works

  1. Estimate. GetEstimateExtendData calls /v2/get-extendable-delegates with extendTo, receiver, requester, an optional maxPriceAccepted, and resourceType. The response includes extendData (the delegates that can be extended) and totalEstimateTrx (the cost in SUN).

  2. Sign. If extendData is non-empty, GetSignedTx builds a TRX transfer of totalEstimateTrx from REQUESTER_ADDRESS to TRONSAVE_RECEIVER_ADDRESS and signs it locally with PRIVATE_KEY.

  3. Submit. SendExtendRequest posts extendData, receiver, and the signedTx to /v2/extend-request. On success the response contains an orderId.

maxPriceAccepted is an upper bound on the price (in SUN) you are willing to pay to extend. If the order book price exceeds it, fewer delegates may be returned in extendData.

Next steps

  • Extend Orders API reference — full request and response schemas for get-extendable-delegates and extend-request.

  • Authentication — compare the private-key/signed-transaction flow with the API key flow.

  • Order types — understand how extend orders relate to other order types.

Last updated