Staking on TRON network
The TRON network has three system resources:
How to stake to obtain system resources
Energy and bandwidth resources are obtained by the account owner through staking, please refer to wallet/freezebalancev2 to learn how to complete the stake operation through HTTP API, refer to Stake2.0 Solidity API to learn how to complete the stake operation through the contract.
TRON allocates resources through the staking mechanism. In addition to obtaining bandwidth or energy resources, staking TRX will also obtain voting rights (TRON Power, TP for short) equal to the amount staked. Staking 1 TRX, you will get 1TP. The energy or bandwidth resources obtained by staking are used to pay transaction fees, and the obtained voting rights are used to vote for super representatives to obtain voting rewards.
The unstaking operation will release the corresponding resources.
How to delegate resources
After the account obtains energy or bandwidth resources through staking, it can delegate resources to other addresses through delegation operation, and can also take back allocated resources through cancel delegation operation. Please pay attention to the following situations when delegating resource:
- Only energy and bandwidth can be delegated to other addresses, voting rights cannot be delegated
- Only unused resources obtained by staking through Stake2.0 can be delegated to other addresses
- Energy/Bandwidth can only be delegated to an activated external account address, not to a contract address
You can use the wallet/getcandelegatedmaxsize interface to query the available delegation share of a certain resource type in the account. A timelock
and lock_period
can be used when delegating resources. If time lock
is true, after the resource delegating is completed, the resource delegation for the address only can be canceled after the locking period specified by lock_period
passed. During the locking period, if the user performs same type of resource delegating for the same address again, the lock time will be set to the newly set value. If the time lock is not used, the delegation can be canceled immediately after the resource is delegated.
How to unstake TRX
After completing the TRX staking, you can unstake at any time. After unstaking, you need to wait for 14 days before you can withdraw the unstaked TRX into your account. 14 days is the No.70 parameter of TRON network which can be voted on by network governance proposals. Please refer to unfreezebalancev2 to learn how to complete unfreeze balance through HTTP API, and use withdrawexpireunfreeze to withdraw the unstaked TRX which have passed the 14 days into your account .
The staked TRX can be partially unstaked multiple times, but only a maximum of 32 unstaking operations are allowed at the same time. That is to say, when a user initiates the first unstake operation, before the TRX of the first unstaking arrives and is ready to be withdrawn to his or her account, he or she can only initiate another 31 unstake operations. The remaining counts of unfreeze can be queried through the getavailableunfreezecount interface.
The TRX that have been delegated cannot be unstaked. In addition to losing the same amount of resource shares, the unstaking will also lose the same amount of TP resources.
When unstaking, If there is a previously unstaked principal that has passed the lock-up period, then this unstake operation will withdraw the unstaked principal that has passed the lock-up period to the account at the same time. You can use the gettransactioninfobyid API to query the withdrawn amount of unstaked TRX that has expired the lock-up period in withdraw_expire_amount
field.
TRON Power Reclaim
After unstaking the TRX staked in the Stake2.0 stage, the same amount of voting rights will be lost. The system will first reclaim the idle voting rights in the account. If the idle TP is insufficient, it will continue to reclaim the used TP. If the user has voted for multiple super representatives, a certain number of votes will be withdrawn in proportion from each super representative, and the corresponding voting rights will be recovered. The calculation formula for withdrawing votes for each SR is,
The number of votes withdrawn from the current super representative = total number of votes to be withdrawn * (number of votes for the current super representative / total number of votes of this account)
For example, Suppose A staked 2,000TRX and obtained 2,000 TRON Power, of which 1,000 TRON Power voted for 2 super representatives, 600 votes and 400 votes respectively, and 1,000 TRON Power remained in the account. At this time, A unstakes 1,500TRX, which means that 1,500 TRON Power needs to be reclaimed from A’ account. In this case, the idle 1,000 TP in A’s account will be withdrawn first, and the spared 500 TP will be withdrawn from the voted TP,
which is 300 TP and 200 TP respectively from the two super representatives. Here's how the votes are calculated:
- Number of votes withdrawn by Super Representative 1 = 500 * (600 / 1,000) = 300
- Number of votes withdrawn by Super Representative 2 = 500 * (400 / 1,000) = 200
At present, the TRON network uses the Stake2.0 stake mechanism, but the resources and votes obtained by Stake1.0 are still valid. The TRX staked at Stake1.0 can still be withdrawal through Stake1.0 API, but it should be noted that if the TRX staked in Stake 1.0 is unstaked, all votes in the account will be revoked.
How to cancel unstaking
Stake2.0 supports canceling all unstakes after the user unstakes TRX, which will make the assets be used for stake again to obtain corresponding resources, without having to wait for the unstaked funds to pass the lock-up period before withdrawing the funds to the account , and then stake them again. Please refer to cancelallunfreezev2 to learn how to cancel all unstaking operations through the HTTP API.
When canceling unstakings, all unstaked funds still in the waiting period will be re-staked, and the resource obtained through the re-staking remains the same as before. Unstakings that exceeded the 14-day waiting period cannot be canceled, and this part of the unstaked funds will be automatically withdrawn to the owner’s account. Users can query the canceled unstaked principal amount cancel_unfreezeV2_amount
, and the withdrawn principal amount that has expired the lock-up period withdraw_expire_amount
through the gettransactioninfobyid
interface.
API
The following table shows the relevant interfaces of the stake model and their descriptions:
API | Description |
---|---|
freezebalancev2 | Stake TRX |
unfreezebalancev2 | Unstake TRX |
unfreezebalance | Unstake the TRX staked during Stake1.0 |
delegateresource | Delegate resources |
undelegateresource | Undelegate resources |
withdrawexpireunfreeze | Withdraw unfrozen balance |
getavailableunfreezecount | Query the remaining times of executing unstake operation |
getcanwithdrawunfreezeamount | Query the withdrawable balance |
getcandelegatedmaxsize | Query the amount of delegatable resources share of the specified resource Type |
getdelegatedresourcev2 | Query the amount of resource delegated by fromAddress to toAddress |
getdelegatedresourceaccountindexv2 | Query the resource delegation index by an account |
getaccount | Query the account stake status, resource share, unstake status, and voting status |
getaccountresource | Query the total amount of resources, the amount of used, and the amount of available |
cancelallunfreezev2 | Cancel unstaking |
Updated 2 months ago