Steemit Crypto Academy | Season 2: Week5-- Bandwidth & Energy (Tron)

in SteemitCryptoAcademy3 years ago (edited)

010.png

sap204.png

Background

Transaction fee or simply fee is an important aspect of the UX in the crypto and Blockchain world. Whatever comes free always attracts the attention of the user.

But nothing is free in this world. Even internet usage still requires you to pay for the monthly plan/package. For every single use you are not paying, but you are paying in bulk. Further, there is still an indirect cost or precisely a resource model attached to it.

In the first generation Blockchains, e.g. Etherum Blockchain, how fair the associated fee is; in today's reality it does complicate the UX in the Etherum ecosystem because of higher fees, not cost-effective at all. We agree that a transaction does take time and computation. But how fair is the associated fee to truly reflect the consumption of resources?

Further, the fluctuating fees and auction-based fee in Blockchain complicate the thing. This problem interface is mitigated by the resource model(Bandwidth & Energy) of Tron Blockchain, where it does not charge you fees upfront. Rather it allows you to stake your TRX to acquire the required resources to carry out a transaction/interact with a dApp.

With the introduction of computational resources like Bandwidth, CPU, RAM, Storage, etc the representation of the associated cost in a transaction/interaction becomes true and fair. The various computational resources are further conceptualized and categorized as Bandwidth & Energy.

sap204.png

Bandwidth & Energy

Whether a transaction in a Blockchain costs you certain fees or not, it always consumes resources. It depends on a particular blockchain how it represents and quantifies those resources and how true the resource model is.

The resource model of Tron Blockchain comprises-- Bandwidth, CPU, Storage, RAM.

It is further conceptualized and categorized into two resource points-- Bandwidth & Energy.

  • Bandwidth point represents Bandwidth
  • Energy represents CPU & Storage.

Ordinary transfers consume Bandwith only whereas smart contract trigger consumes both bandwidth & energy.

Bandwidth points consumption= number of bytes of a transaction * Bandwidth point rate

Every account in Tron Blockchain has a free 5000 Bandwidth every 24 hrs. Any consumption/use is reset to zero at 24 hrs. In other words, you get a full 5000 Bandwith every day.

A user can also get additional Bandwidth by freezing TRX. But how much an account can possess Bandwidth depends on the liquidity of the entire Tron Network and the total amount of frozen TRX in the network.

Bandwidth Points obtained = (the amount of TRX self-frozen / the total amount of TRX frozen for Bandwidth Points in the network) * 43_200_000_000

Bandwidth consumption

So far we have established that you get 5000 Bandwidth every day(reset to 5000 every 24h). Second, you can also get Bandwidth points by freezing TRX, how much is purely dynamic, as it depends on the frozen TRX of the entire network at any given time.

screenshot - 2021-05-09T134212.561.png

So for the ordinary transfers, it will first consume the Bandwidth points from freezing TRX. If no such Bandwidth is available, it will consume the free Bandwidth(5000 Bandwidth per day).

If the available Bandwidth(by freezing TRX)+Free Bandwidth(5000) is not sufficient or already exhausted, then it will burn TRX to accommodate the required Bandwidth points.

Energy

Smart contract trigger consumes CPU as it operates on virtual machines. Further, how much time does it take to execute in the virtual machine is calculated as Energy. 1 Energy= 1 Micro-second.

008.png

There is no such free Energy in Tron Blockchain. Energy can be obtained by freezing TRX. How much energy you can get by freezing TRX depends on the liquidity of the entire network and the total amount of the frozen TRX in Tron Network.

Energy obtained = (the TRX frozen for gaining Energy / the total TRX frozen for gaining Energy in the entire network) * total_energy_limit

Energy consumption

A smart contract call consumes both bandwidth & energy.

The consumption of Bandwidth will follow the same loop as discussed above.

screenshot - 2021-05-09T134357.224.png

For the consumption energy, it will first consume the Energy from freezing TRX, if it is insufficient/exhausted, then it will burn TRX to accommodate the required Energy.

Caveat- The Energy and/or TRX will still be burnt even if a transaction fails.

One can always estimate Energy/Bandwidth by freezing TRX using https://tronstation.io/calculator. You can also calculate how much Energy will you get by burning TRX.

Example-- Let's calculate "Bandwidth by freezing TRX" manually

Recollect the formula of Bandwidth--

Bandwidth Points obtained = the amount of TRX self-frozen / the total amount of TRX frozen for Bandwidth Points in the network * 43_200_000_000

Let's say we freeze 1 TRX
Total TRX frozen you can get from Troncscan.org

tronscan1.png

Total TRX frozen= 31.287 Billion

However, this is the total TRX frozen(for both Bandwidth and Energy). We need TRX frozen for Bandwidth points in the entire network.

Go to https://tronstation.io/calculator

screenshot - 2021-05-09T121037.707.png

On the top left, you can find these two figures--

Total Energy Weight: 2,925,334,047 Total Net Weight: 28,361,784,682

So Total TRX frozen for Bandwidth Points= 28.361 Billion
And Total TRX frozen for Energy= 2.925 Billion

=> Bandwidth Points obtained by freezing 1 TRX= 1 / 28, 361, 784, 682 * 43_200_000_000= 1.5231

Check it again from Tronstation.io/calculator to ascertain whether the calculated figure is correct or not.

Similarly, you can also calculate Energy.

Note-

  • Freezing TRX means you will lock your TRX for a certain period(at least 72 hrs) and you won't be able to trade frozen TRX.
  • By freezing TRX you get Bandwidth & Energy which are required for transfers, smart contract trigger. In other words, you gain the required resources to interact with the dApps of the Tron ecosystem, to transfer assets to another peer.
  • By freezing TRX you will either get Energy or Bandwidth(depending on your selection), not both.

sap204.png

Freeze TRX to obtain Bandwidth & Energy

  • Go to https://tronscan.org/
  • Connect your Wallet
  • Click on Resources.
  • Click on Obtain. A pop-up will appear, asking you to fill the relevant boxes.
  • Select either Tron Power & Bandwidth or Tron Power & Energy. Selecting Bandwidth will give you Bandwidth and selecting Energy will give your Energy.
  • Enter the amount of TRX.
  • Tick the Box to confirm.
  • Finally, click on Freeze.

screenshot (99).png

screenshot (100).png

screenshot - 2021-05-09T115928.713.png

tp10.png

screenshot - 2021-05-09T120149.225.png

sap204.png

How do I check How much Bandwidth/Energy consumed in a smart contract trigger?

  • Go to Tronscan.org
  • In the search field enter your Tron Wallet Address.
  • Click on Transfers-- There are two tabs here-- One is TRX & TRC10 Transfer & the other is TRC20 & TRC721 Transfers.

screenshot (93).png

screenshot (94).png

Many of you(participants of Homework Task-3) have already experienced JustLend last week. JustLend lists TRX & TRC20 assets. So you can click TRC20 and TRC721 Transfers.

screenshot (95).png

In Just Lend there were three phases you all went through--
(1) Supplied the assets(e.g. TRX) to acquire jTokens
(2) Borrowed another asset(e.g. USDT)
(3) Repayment of the borrowed asset

Step-1- Supply- Method of calling- Mint(e.g. you supplied TRX to mint jTRX tokens)
Step-2- Borrow- Method of calling- Borrow(e.g. you borrowed USDT)
Step-3- Repay- Method of calling- Transfer( e.g. you repaid USDT)

Now click on the transaction hash of all smart contract trigger in order- (Mint-Borrow-Transfer).

Method of calling- Mint(Supply)

I supplied 90 TRX to mint 8997 jTRX tokens

screenshot (96).png

Txn Hash- f561f7bbdd62f4c820e6c33570d50dfcff0e957b7d92adfcf0ee1a190c03646d

Consumption of Bandwidth- 284

Consumption of Energy- 80,377

TRX burned to accommodate Energy- 11.252

Method of calling- Borrow

I borrowed 5 USDT from JustLend.

screenshot (97).png

Txn Hash- 941bddc311c6a48c9debbdf77b9e66b42ab47da43cdec854c61e00e37f6242d5

Consumption of Bandwidth- 313

Consumption of Energy- 141,818

TRX burned to accommodate Energy- 19.854

Method of calling- Transfer(Repayment)

I repaid 5 USDT.

screenshot (98).png

Txn Hash- 7e40c78340dd31c93fa330b522432d4c5ef494a8c8e06ee15a3f0cc389f780ea

Consumption of Bandwidth- 345

Concumption of Energy- 14,631

TRX burned to accommodate Energy- 2.048

ResourcesSupply(mint)Borrow(borrow)Repayment(Transfer)
Quantity90 TRX5 USDT5 USDT
Bandwidth284313345
Energy8037714181814631
TRX burned to accommodate energy11.252 TRX19.854 TRX2.048 TRX

sap204.png

Observation & Analysis

Now, here in this example, I borrowed 5 USDT from JustLend, and as it is a smart contract-operated transaction it costs me 313 Bandwidth & 141,818 Energy. During the trigger, I did not have sufficient energy in my wallet, so to accommodate the required energy it burned 19.854 TRX.

Now recall the concept of energy-- how it is calculated. It is the time required to execute a contract in virtual machines. 1 Energy= 1 Microsecond.

So to execute this "borrow" contract it took 141,818 microseconds.

Similarly to execute a "mint" contract took 80,377 microseconds, and to transfer, it took 14631 microseconds.

For bandwidth, it did not require any TRX to be burned, as 5000 Bandwidth is given as free every day. As you can observe in all three cases the consumed bandwidth is somewhere around 300, with the average figure being 314 bandwidth.

=> Per day free transfers= 5000/314= 15.92.

So around 15 transactions(ordinary transaction, smart contract triggers excluded) we can easily make free of cost in Tron Blockchain every day. Beyond that, it will burn TRX to accommodate Bandwidth. So in such a case, the user should freeze a few TRX to avoid TRX being burned.

sap204.png

Conclusion

With the above analysis, we can conclude that under normal operation/general purpose, the ordinary transaction cost is zero, in other words, you can also say that when the network is running at normal capacity or below capacity, the transaction fee is zero.

A user(or many such users) when making transactions beyond 15 or so(tentative figure), resource efficiency comes into play, which means those who have staked TRX with higher quantity will get the required resources to carry out bulk transactions(or TRX be burned to accommodate the required Bandwidth).

Regarding smart contract trigger, they are by default business activities, hence the necessary Energy requirement must be complied by the users, again resource efficiency, high quantity of TRX being staked will enable you to carry out a business activity (or TRX be burned to accommodate the required Bandwidth/Energy).

The blockchain with a fee-based model always forces you to make a transaction of the native coin(e.g. ETH in Etherum Blockchain). The model of computational resources is better, fair, and transparent in the context of associated costs in a transaction.

In a nutshell, Tron Blockchain does not force you to transact TRX as long as you are using this Blockchain for retail/general purposes(lowering the barrier to entry). For business purposes, bulk transactions, etc you might need to stake sufficient TRX to accommodate Bandwidth & Energy.

Thank you.

sap204.png

Homework Task (Season 2/Week-5)

(1) How do I connect my TronLink Wallet to Tronscan.org?(Screenshots needed)

(2) How do I freeze TRX to obtain Bandwidth? (Screenshots needed)

(3) How do I freeze TRX to obtain Energy? (Screenshots needed)

(4) What types of transaction consumes Bandwidth only and what types of transaction consume both Bandwidth & Energy? Example of both types of your own wallet? (Screenshots needed)

(5) How do I check "how much Bandwidth and Energy are consumed in a particular transaction"?(Screenshots needed)

(6) How do I avoid burning TRX to accommodate the Energy required for a transaction?

(7) Include the real example of your interaction with JustLend & Justswap? Indicate how a "swap"(in Justswap) function consumes different "Energy & Bandwidth" than a "borrow" function(in JustLend)? You can trade a small amount(as little as 1 USDT)? (Screenshots needed)

(8) Explore Tronscan(check your own wallet) to identify an "ordinary transfer" & a "Smart-contract-operated transfer"? Indicate the difference between the two?

Important Note-

(1) With the rise of STEEM price, the purchasing power of Steemians has greatly improved, therefore we expect the participants of this task to showcase a real example using JustLend & Justswap. You can do a micro-transaction (if you don't have sufficient TRX or other listed assets of JustLend & Justswap). This will help you gain real experience.

(2) Those who have already used JustLend (Season2- Week3) and demonstrated with a real example can include their examples in this Task, such users have to interact with Justswap only. Those who have not participated in the previous task have to showcase their real examples/interaction with JustLend and Justswap(both) to compare the "Energy & Bandwidth" consumption.

Guidelines

  • Your article should be at least 300 words.
  • It is always better to gain user experience before submitting your article.
  • Refrain from spam/plagiarism. This task requires screenshot(s) of your own experience. Use images from copyright-free sources and showcase the source, if any.
  • This homework task will run until 15th May'2021, Time- 11:59 PM UTC.
  • Users having a reputation of 50 or above, and having a minimum SP of 100(excluding any delegated SP) are eligible to partake in this Task.
  • Add tag #sapwood-s2week5 #cryptoacademy in your post and should be among the first five tags. You can also use other relevant tags like #defi #tronscan #market or any other relevant tag.
  • Those who include the real examples/screenshots will score better.
  • If you are using a wallet other than Steem integrated Tron wallet, you should mention it at the beginning of the post, so that we can verify the transactions required in this Task.

(Please feel free to join the comment section if you have any doubt on Homework-Task)

sap204.png

Cc:-
@steemitblog
@steemcurator01
@steemcurator02

sap204.png

Unless otherwise stated, all the images, infographics, charts, tables, etc(if any) are my original works. The screenshots are taken from Tronscan.

sap204.png

Sort:  

This is a beautiful lecture
I will be participating in this

 3 years ago 

I am eligible or not?

Eligible. But make sure you don't power down.

Thank you.

 3 years ago 

Ok sir thanks

Thanks for this wonderful lecture professor @sapwood. I've made my entry for the task and the link to it is presented below. Thank you, sir.

https://steemit.com/hive-108451/@fredquantum/crypto-academy-week-13-or-homework-post-for-sapwood-or-bandwidth-and-energy-tron

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 61674.06
ETH 3067.94
USDT 1.00
SBD 3.81