Crypto Academy Week 13- Homework Post for Professor @sapwood | Bandwidth& Energy (Tron)

in hive-108451 •  3 years ago 
Hello Steemians, I'm glad to part of this wonderful lesson delivered by processor @sapwood on "Bandwidth and Energy (Tron). The concept of Bandwidth and Energy in Tron blockchain was explained in details in the lesson. In our previous lesson, we explored Justlend platform and performed some task on the platform. I was surprised at the amount of TRX I lost during this homework. But after taking this lesson, I have come to realise the reason I lost so much TRX and also what I need to do to limit the amount of TRX burnt during smart contract calls.

images (19).jpeg
Source

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

How to Connect TronLink Wallet to Tronscan.org

For this section, there are two ways to access Tronscan.org. This can be through a browser or Tronlink wallet. I find the second very easy and straightforward and I will be performing my homework task using Tronlink wallet.
To connect Tronlink wallet to Tronscan.org, follow the steps below.

Steps Include

  • Open Tronlink wallet and click on Discover menu at the bottom. The Discover page allows you to interact with Dapps on the Tron network. So we will be accessing Tronscan.org from here.

20210514_164414.jpeg

  • At the Discover, you can find several Dapps which Tronscan is a popular Dapp appearing on the interface. You can simply click on the icon to gain access to Tronscan.org. But a better alternative is to access Tronscan.org by using the search bar. Type in tronscan.org/ and enter. This can be further demonstrated using the screenshots below.

20210514_164500.jpeg

  • After that, you will get a notice that you will be redirected to a third-party Dapp. Click Enter to be redirected to tronscan.org.

20210514_164542.jpeg

  • After that, your wallet will be automatically connected to Tronscan.org at the landing page.
  • To confirm of your wallet is automatically connected, click on the three dashed lines at the top corner for a drop-down menu, then click Wallet.

20210514_164627.jpeg

From the image above, we can see that I have successfully connected my Tronlink wallet address to Tronscan.org. We can also see I have 5000 Bandwidth and 0 Energy.

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

How do I freeze TRX to obtain Bandwidth

Below are the steps to freeze TRX to obtain Bandwidth.

Steps Include:

  • From tronscan.org/ landing page, click on the three dash line at the top right corner for a drop-down menu.
  • Scroll down to Wallet and click the arrow beside your wallet address.

iikke.jpg

  • After that, you will be redirected to the landing page. Switch to resources and click Obtain.
  • After that, a page opens up requesting for the resources to obtain by freezing TRX, click on obtain option and select Tron Power and Bandwidth.
  • After that, input the amount of Tron to be frozen and click onFreeze. We will be freezing 10TRX to obtain 15.58 Bandwidth. Further explanation is shown in the screenshots below.

20210514_164858.jpeg

  • After you clicked freeze, a smart contract request is shown to confirm the freezing of 10TRX on Tronscan.org. Click on confirm and sign the transaction using your Tronlink password. This transaction requires a fee of 245 Bandwidth.

20210514_164941.jpeg

After, a page pops up showing have successfully frozen 10 TRX. From the resource page, we can see that I have obtained 15 Bandwidth by freezing 10 TRX. This can be shown in the picture below.

20210514_165015.jpeg

Summary of operation:

  • TRX freezes: 10 TRX
  • Bandwidth obtained: 15 Bandwidth
  • Transaction fee: 245 Bandwidth

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

How do I Freeze TRX to obtain Energy?
Below are the following steps to freeze TRX to obtain Bandwidth.

Steps Include:

  • From tronscan.org/ landing page, select the three dash line at the top corner for a drop-down menu.
  • Scroll down to locate Wallet and click at the arrow ">" beside your wallet address as shown below.

iikke.jpg

  • After that, you will be redirected to a landing page. Switch to resources and click Obtain.
  • After that, a page opens up requesting the resources to obtain by freezing TRX, click on obtain option and select Tron Power and Energy.
  • After that, input the amount of Tron to be frozen and click onFreeze. We will be freezing 10TRX to obtain 300 Energy. Further explanation is shown in the screenshots below.

20210514_165225.jpeg

  • After you clicked freeze, a smart contract request is shown to confirm the freezing of 10TRX on Tronscan.org. Click on confirm and sign the transaction using your Tronlink password. This transaction requires a fee of 247 Bandwidth.

20210514_165259.jpeg

  • After, a page pops up showing you have successfully frozen 10 TRX. From the resource page, we can see that I have obtained 300 Energy by freezing 10 TRX.

20210514_165342.jpeg

Summary of transaction:

  • Amount of TRX frozen: 10 TRX
  • Amount of Energy obtained: 300 Energy
  • Transaction fee: 247 Bandwidth

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

What types of Transaction consumes Bandwidth only and what type of types of transactions consumes both Bandwidth and Energy? Examples of both types of your own wallet? (Screenshot needed).

It is necessary to know that Tron Bandwidth is consumed during ordinary transfers from one wallet to another on the Tron network, whereas transactions that require smart contract trigger consumes both Bandwidth and Energy.

Example of transaction that consumes Bandwidth

There are two ways I can view this. I can visit tronscan.org/ and view my transfer history. This is after I have accessed my wallet by inputting my wallet address in the search field. Similarly, I can illustrate this from my Tronlink transaction history. I will be illustrating from Tronlink wallet.

  • Open Tronlink wallet and click on any asset. I will click TRX because I have transfer history on the asset.
  • Switch to sent icon at the top of the screen to view sent transactions.
  • Select any transaction to view transfer details. After that, details of the transaction is displayed.

20210514_165509.jpeg

  • Scroll down the page to view the resources that were consumed for the transaction. But firstly, the type of transaction is displayed which showed that this is an ordinary TRX transfer from my wallet to another wallet.

20210514_165555.jpeg

Also, from the screenshot above, we can see that 268 Bandwidth was consumed. We have 0 Energy consumed because the transaction didn't trigger any smart contract. Similarly, 0 TRX was burned because I have sufficient Bandwidth to cover up the transaction. We can also view the details of this transaction on Tronscan.org/ by clicking on view detailed data at bottom of the page as shown above.

20210514_165638.jpeg

From the picture below, we can confirm the details we have from Tronlink wallet on Tronscan.org.

20210514_165715.jpeg

Example of transaction that consumes both Bandwidth and Energy

For this illustration, we will follow the steps as explained above. But this time around, we will select a transaction that consumed both Bandwidth and Energy. This will probably be a transaction that triggered a smart contract. On my previous assignment, I carried out a transaction that triggered a smart contract while supplying TRX on JustLend platform. This transaction will be used for this illustration.

Note:This illustration will be done using TronLink wallet.

  • Open Tronlink wallet and click on any asset. I will click TRX because I have transfer history on the asset.
  • Switch to sent icon at the top of the screen to view sent transactions.
  • Select any transaction to view transfer details. After that, details of the transaction is displayed.

20210514_165822.jpeg

  • After you have clicked the transaction, the transaction details will be displayed.
    From what we have, we can see that this type of transaction is a smart contract triggered transaction. And from our lesson, this kind of transaction consumes both Bandwidth and Energy.

20210514_165911.jpeg

Similarly, 284 Bandwith was consumed for this transaction and **80,377 Energy was consumed. From what we have above, 0 TRX was burnt because I had enough Bandwidth to cover the transaction. Whereas 11.25 TRX was burnt for 80,377 Energy because I do not have sufficient energy to cover the transaction. This would have been avoided if I had freezes some TRX to obtain Energy before carrying out this transaction.

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

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

To check his much Bandwidth and Energy consumed in a particular transaction, I will illustrate this using a smart contract triggered transaction which consumes both Bandwidth and Energy. I will illustrate this using my previous transaction on JustSwap platform. I swapped 1TRX for 0.125USDT on JustSwap.

Note:This illustration will be done using TronLink wallet.

  • Open Tronlink wallet and click on any asset. I will click TRX because I have transfer history on the asset.
  • Switch to sent icon at the top of the screen to view sent transactions.
  • Select any transaction to view transfer details. After that, details of the transaction is displayed. I will select my transaction on JustSwap. I swapped 1TRX for 0.125USDT.

20210514_170036.jpeg

  • After you have clicked the transaction, the transaction details will be displayed.
    From what we have, we can see that this type of transaction is a smart contract triggered transaction. And from our lesson, this kind of transaction consumes both Bandwidth and Energy.
    Now I will check how much Bandwidth and Energy was consumed in this transaction.

20210514_170125.jpeg

From what we have above, **349 Bandwidth was burned for this transaction and **48,363 Energy was consumed. Due to insufficient Energy in my account, 6.77 TRX was burned to cover up the Energy consumed in the transaction. I paid 6.77 TRX to swap 1TRX and I was wondering why my TRX was disappearing after this transaction. Let's just say I was uninformed about how the process works. All thanks to professor @sapwood for this amazing lesson.
Summary of transaction:

  • Transaction type: Smart contract triggered
  • Transaction action: 1TRX swapped for 0.125 USDT
  • Bandwidth consumed: 349 Bandwidth
  • Energy consumed: 48,363 Energy
  • Transaction fee: 6.77 TRX burned to cover Energy consumed.

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

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

Energy is required to process smart contract transactions on Tron network. This is because smart contracts trigger consumes CPU as it operates on Tron Virtual Machine(TVM). Therefore, a user needs to have sufficient Energy to perform a smart contract trigger transaction. If there's no sufficient Energy required for this operation, TRX will be burned to accommodate the required Energy for the transaction. To avoid burning TRX to accommodate the required Energy, a certain amount of TRX which will accommodate the Energy required will be frozen. By freezing a certain amount of TRX, a user obtain Energy to accommodate smart contract call which consumes both Energy and Bandwidth. The amount of energy received by freezing TRX depends on the liquidity of the entire network and also the total amount of TRX frozen in Tron network. This can also be calculated mathematically using the formula:
Energy obtained= ( TRX frozen for gaining Energy/ total TRX frozen in the entire network to gain Energy) * total energy limit.
This can also be calculated using a calculator on translation.io/calculator/. A screenshot of the calculator is shown in the picture below.

20210514_170233.jpeg

From the picture above, freezing 1 TRX is equal to 30 Energy. This means 10 TRX is equal to 300 Energy. I think this is a better way to calculate the amount of Energy you will obtain by freezing a certain amount of TRX.

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

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

Swap transaction on Justswap

For this illustration, I will be swapping TRX for USDT using Justswap platform.

  • Open your Tronlink wallet and click on Discovery at the bottom of the page.
  • Visit Justswap platform by locating it on the popular page. Also, you can use the search bar and type Justswap.

20210514_170337.jpeg

  • After that, the landing page of Justswap opens up. Input the amount of TRX you want to swap for USDT. For this illustration, I will be swapping 7.93 TRX to obtain 1 USDT.
  • After inputting the amount swap, click on Swap.
  • A smart contract call is triggered, click *Confirm to confirm the transaction.
  • After that, sign the transaction using your Tronlink wallet password.

20210514_170416.jpeg

The details of the transaction can be seen in the picture below. 7.93 TRX was swapped to obtain 1.0009 USDT. The transaction consumed 350 Bandwidth 33,363 Energy. Similarly, 4.67 TRX was burned to cover the Energy consumed in the transaction.

20210514_170458.jpeg

Borrowing on JustLend market

For this illustration, I will be using a previous transaction during our previous assignment on JustLend. In the previous assignment, I borrowed 1USDT from JustLend market. The details of the transaction will be illustrated below.

  • Visit JustLend market.
  • Select USDT market and click on borrow.
  • Input the amount of USDT to be borrowed and click on Borrow. This will trigger a smart contract call, confirm and sign the transaction using your Tronlink password.

20210514_170605.jpeg

From JustLend market, 1 USDT was borrowed at a borrow APY of 1.81%. The details of the transaction are shown in the pictures below.

20210514_170643.jpeg

From the transaction details above, 313 Bandwidth was consumed and 204, 506 Energy was consumed. Also, 28.63 TRX was burned for energy consumed in the transaction due to insufficient energy.

Summary of both transactions

DetailsJustswap transactionJustLend Transaction
Transfer action7.93 TRX swap for 1.009USDT1 USDT borrowed
Transfer typeSmart contract triggerSmart contract trigger
Consumed Bandwidth350313
Consumed Energy33,363204506
TRX burned for Bandwidth00
TRX burned for Energy4.6728.63

In conclusion, both transactions are smart contract triggered transactions that require both Bandwidth and Energy. From the table above, we can see a slight difference in the Bandwidth consumed but there's a huge difference in the Energy consumed. Borrowing in JustLend consumed 204596 Energy which is approximately 6x of energy consumed in swapping using JustSwap. This effect can also be seen in the TRX consumed for energy on both transactions. We can see that 4.67 TRX was consumed for Energy on Justswap and 28 TRX was consumed for Energy on JustLend. This is an indication that more Energy is consumed when borrowing on JustLend than Swapping using on JustSwap.

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

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

To identify whether a transfer is an ordinary transfer or a smart-contract operated transfer, we will do that by checking the resources consumed in the transfer. An ordinary transfer will consume only Bandwidth while smart-contract-operated transfer will consume both Bandwidth and Energy.

Steps involved in identifying an " Ordinary transfer" using Tronscan

  • Open Tronlink wallet and click on Discover menu at the bottom. The Discover page allows you to interact with Dapps on the Tron network. So we will be accessing Tronscan.org from here.

20210514_170858.jpeg

  • On the landing page, input your wallet address in the search option to access your wallet.
  • Scroll down and click on Transfers
  • After that, search for an ordinary transfer from your transactions history. This will probably be a transaction that consumed only Bandwidth.

20210514_170943.jpeg

I selected a transfer of TRX to my Binance Wallet. Below is the transaction details.

20210514_171024.jpeg

From the picture above, this is an ordinary transfer of TRX. Only 268 Bandwidth was consumed for the transaction. From what we can see, no Energy was consumed which proves that this is an ordinary transfer

Steps to identify a "Smart-contract-operated" transfer

  • Open Tronlink wallet and click on Discover menu at the bottom. The Discover page allows you to interact with Dapps on the Tron network. So we will be accessing Tronscan.org from here.

20210514_171117.jpeg

  • On the landing page, input your wallet address in the search option to access your wallet.
  • Scroll down and click on Transactions
  • Smart-contract transfer can easily be identified by clicking transaction type to select trigger-smart contracts. This will filter your transactions history to smart-contract triggered transactions.

20210514_171158.jpeg

I selected a recent transaction I carried out on Justswap as shown above. I swapped 7.93 TRX for 1.009 USDT. The transaction details are shown below.

20210514_173140.jpeg

From the picture above, the transfer above is smart-contract-operated. The reason is that both Energy and Bandwidth was consumed. 350 Bandwidth was consumed while 33,363 Energy was consumed for the transfer.
From the exploration carried out on Tronscan.org, we can say that the difference between an ordinary transfer and a smart-contract-operated transfer is the type of resources consumed. Ordinary transfer consumes only Bandwidth while smart-contract-operated transfer consumes both Bandwidth and Energy.

8SzwQc8j2KJZWBXFXnbnQ1FtoZhRqrTWozhqoqWHpGmpmo6CxrnQFoLKyfpP5wZLq2meH4hgfA33eGpaeEMKZoE5GjP6QfgAyq42mQ8X5L823HUFjGz.jpeg

In conclusion, Tron network consumes two resources in a particular transaction. This includes Bandwidth and Energy. The type of resources consumed depends on the type of transaction carried out. Ordinary transfers only Bandwidth which a user is entitled to 5000 Bandwidth for 24hrs. Similarly, transactions that include smart contract trigger consumes both Bandwidth and Energy. TRX is burned to accommodate Energy consumed in smart contract trigger transfer due to insufficient Energy. Energy can be obtained by freezing a certain amount of TRX. By freezing TRX to obtain Energy, transactions on Tron network can be carried out cheaper without burning TRX.

Thank you professor @sapwood for this amazing lesson.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for attending the lecture in Steemit-Crypto-Academy- Season 2 & doing the homework task-5.

Borrowing in JustLend consumed 204596 Energy which is approximately 6x of energy consumed in swapping using JustSwap. This effect can also be seen in the TRX consumed for energy on both transactions. We can see that 4.67 TRX was consumed for Energy on Justswap and 28 TRX was consumed for Energy on JustLend. This is an indication that more Energy is consumed when borrowing on JustLend than Swapping using on JustSwap.

That's correct.

So Energy consumption varies from one smart contract to the other. Further within JustLend, you will find that it is the "Borrow" function which consumes highest Energy as compared to the other types of functions(mint, repay, etc)

Suggestions/Feedback

  • The author has produced real transactions to demonstrate Bandwidth & Energy.
  • The author has included all the screenshots relevant to this Task. He has also made a compartive analysis of resource consumption(Borrow & Swap function).

Thank you.


Homework Task -5 accomplished.
[9]