Resource Model

Bandwidth and energy are two important system resources of the TRON network. Bandwidth is the unit that measures the size of the transaction bytes stored in the blockchain database. The larger the transaction, the more bandwidth resources will be consumed. Energy is the unit that measures the amount of computation required by the TRON virtual machine to perform specific operations on the TRON network. Since smart contract transactions require computing resources to execute, each smart contract transaction requires to pay for the energy fee.

Bandwidth

All types of transactions need to consume Bandwidth Points. Transactions are transmitted and stored in the TRON network in the form of byte arrays. One byte requires one Bandwidth Point, so the Bandwidth Points that a transaction needs to consume is equal to the number of transaction bytes.

When the available bandwidth is insufficient, TRX needs to be burned to pay for Bandwidth Points:

Burned TRX =  the amount of bandwidth consumed * the unit price of bandwidth

Currently, the unit price of bandwidth is 1000sun.

How to Get Bandwidth Points

Each external account has 1,500 free bandwidth per day, and more bandwidth can be obtained by staking TRX. All users share the fixed amount of bandwidth according to the number of staked TRX. The total fixed bandwidth supply for the entire network is 43,200,000,000 per day. The following formula can be used to calculate how much bandwidth can be obtained by staking a certain amount of TRX:

The amount of bandwidth obtained = the amount of TRX staked for obtaining bandwidth / the total amount of TRX staked for obtaining bandwidth in the whole network  * 43_200_000_000

You can send a FreezeBalanceContract type of transaction to stake TRX to obtain bandwidth. The following will use wallet-cli as an example to create a FreezeBalanceContract type of transaction:

wallet> freezeBalance TC9vGE2cPC3AkLtCpRvDjNvLh7Efap9Pvg  1000000 3 0  TC9vGE2cPC3AkLtCpRvDjNvLh7Efap9Pvg

Bandwidth Points Consumption

In addition to query operations, any transaction needs to consume bandwidth. The bandwidth points consumption rules are: first, check whether the transaction initiator's bandwidth obtained by staking TRX is sufficient, if it is sufficient, consume the bandwidth obtained by staking TRX; Otherwise, check whether the free bandwidth of the transaction initiator is sufficient, and if so, consume the free bandwidth, otherwise, TRX will be burned to pay for the bandwidth of the transaction according to the unit price of 0.001TRX per bandwidth.

Bandwidth Points Recovery

After the account's free bandwidth and the bandwidth obtained by staking TRX are consumed, they will gradually recover within 24 hours.

Account Bandwidth Balance Query

First, call the node HTTP interface wallet/getaccountresource to obtain the current resource status of the account, and then calculate the bandwidth balance by the following formula:

Free bandwidth balance = freeNetLimit - freeNetUsed

Bandwidth balance obtained by staking TRX = NetLimit - NetUsed

Note: If the result returned by the interface does not contain the parameters in the above formula, it means that the parameter value is 0.

Energy

The execution of each instruction of smart contract consume a certain amount of energy while running. so contracts of different complexity consume different amounts of energy. When the contract is executed, Energy is calculated and deducted according to instruction one by one. When the available energy of the account is insufficient, TRX needs to be burned to pay for the corresponding energy.

Burned TRX = Energy quantity * the unit price of Energy

Currently, the unit price of Energy is 280sun.

How to Get Energy

Energy can only be obtained by staking TRX. All users share the fixed amount of energy according to the number of staked TRX. The daily fixed total energy supply of the entire network is 90,000,000,000. Please use the following formula to calculate how much energy can be obtained by staking a certain amount of TRX:

The amount of energy obtained = the amount of TRX staked for obtaining energy / the total amount of TRX staked for obtaining energy in the whole network * 90_000_000_000

You can send a FreezeBalanceContract type of transaction to stake TRX to obtain energy. The following will use wallet-cli as an example to create a FreezeBalanceContract type of transaction:

wallet> freezeBalance TC9vGE2cPC3AkLtCpRvDjNvLh7Efap9Pvg  1000000 3 1  TC9vGE2cPC3AkLtCpRvDjNvLh7Efap9Pvg

Energy Consumption

When the contract is executed, Energy is calculated and deducted according to instruction one by one. The priority of account energy consumption is as follows:

  • Energy obtained by staking TRX
  • Burn TRX

First, the energy obtained by staking TRX will be consumed. If this part of energy is not enough, the account's TRX will continue to be burned to pay for the energy resources required for the transaction, according to the unit price of 0.00028TRX per energy.

If the contract exits due to throwing a revert exception while execution, only the energy consumed by instructions that have already been executed will be deducted. But for abnormal contracts, such as contract execution timeout, or abnormal exit due to bug, the maximum available energy of this transaction will be deducted. You can limit the maximum energy cost of this transaction by setting the fee_limit parameter of the transaction.

Energy Recovery

After the energy resource of the account is consumed, it will gradually recover within 24 hours.

Account Energy Balance Query

First call the node HTTP interface wallet/getaccountresource to obtain the current resource status of the account, and then calculate the energy balance by the following formula:

Energy Balance = EnergyLimit - EnergyUsed

Note: If the result returned by the interface does not contain the parameters in the above formula, it means that the parameter value is 0.