Steemit Crypto Academy Week 13 - Homework Post for @sapwood

in hive-108451 •  3 years ago 

Hey all. In this post, I will be attempting the assignment given by @sapwood

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

I would be using the browser on my laptop to complete this. The pre-requisites of this include downloading the tronlink wallet extension for your browser. You would also need to import your Tron wallet to Tronlink by using the private key of your wallet. Once you have completed these prerequisites, you can proceed with the steps below to connect it with tronscan.org.
1- Open tronscan.org website and click on the connect wallet button on the top right.

image.png
Click on the Connect wallet button

2- This would give you the option to connect your ledger wallet or your Tronlink wallet. Click on the Tronlink option here.

2.PNG
Click on the Tronlink Option here

3- If you do this when you first open the browser, then Tronlink extension would open up and you would need to enter the password. In my case, I had already done that. So, it connected automatically.

image.png
Wallet was successfully connected

You can also register on the tronscan website using either your email ID or mobile number. When I tried the email Id option did not send me the verification link even after a couple of hours. The mobile number registration is much more convenient and you will receive your login OTP instantly. So, do try it out.

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

Every day, your Tron wallet gets replenished with 5000 bandwidth. This can be used to send Tron tokens to other wallets. However, if the 5000 bandwidth is not sufficient for your needs, then you can increase it by freezing the TRX tokens that you hold.

Follow these steps to achieve this.
1- Once you Connect your Tronlink wallet to tronscan.org, you will be able to see the following screen. Click on the obtain button next to the energy reading in the center of the screen.

image.png
Default screen after you connect tronlink wallet

2- In the pop-up that opens, by default, the drop-down would be set to Obtain Tron Power and Bandwidth. (Here, Tron Power can be used to perform voting operations.) By entering the amount of Trx that you want to freeze and confirming that you would be freezing it for a minimum of 3 days, you are ready to hit the freeze button.

3- This would then open up the Tronlink wallet and you need to confirm the operation. Once you confirm, the Trx token would be frozen and you will receive the Bandwidth.

image.png
By clicking on the accept button, the transaction would be completed

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

The process of obtaining Energy is similar to that of obtaining bandwidth. Energy is needed when a smart contract gets executed. Unlike Ethereum where you would need to pay the gas fees for all smart contract execution, here on Tron, you can make use of Energy resources to do the same. The best part is that you can receive Energy for simply freezing your Trx tokens. So, when you unfreeze them later(minimum 3 days), you will receive the entire amount.

The steps to obtain Energy are:
1- On the landing page after you connect your Tronlink wallet, hit the Obtain button.
image.png
Default screen after you connect tronlink wallet

2- On the popup, you will need to choose a different option i.e. Tron Power and Energy. You will then need to provide the details of the frozen amount and click on freeze. You would then need to accept this on the tronlink wallet

5.PNG
Choose the TP and Energy from the drop down

3- Finally, the transaction is successful.

6.PNG
Successful transaction

(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?

Transactions consuming only Bandwidth: Transactions such as freezing TRX tokens or transfer of TRX or TRC10 tokens from one wallet to another consume only Bandwidth.

image.png
Here I froze 100 TRX tokens and you can see that only Bandwidth was consumed

image.png
This is a Steem Reward that I receive and even this consumed only bandwidth

Transactions consuming both Bandwidth and Energy: TRC20 and TRC721 transactions consume both Bandwidth as well as Energy. These are smart contract executions that consume a lot more resources than normal transfers.

image.png
Here are all the TRC20 and TRC721 transactions that I have done

image.png
This transaction of mine on JustLend consumed 313 Bandwidth and 204506 Energy

The easiest way for you to spot these transactions is to head over to the transfers tab on tronscan.org.

image.png
Here TRX&TRC10 transfers use only bandwidth and TRC20&TRC721 consume both bandwidth and energy

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

I would pick one of the smart contract executions to demonstrate this as it would have consumed both bandwidth and energy.

1- First go to tronscan.org and search for your wallet.
2- Then head over to the transfers tab and select TRC20&TRC721 option. This would provide you the list of all the TRC20 and TRC721 transactions that you have executed.

image.png
List of all TRC20 and TRC721 transactions that I have done

3- Click on the hash of any one of these transactions.

image.png
Bandwidth Consumed=313 and Energy Consumed = 204506

4- As you can see from the screenshot above, you can see both the bandwidth as well as the energy consumed to complete this transaction. Here, 28.63028 TRX was burnt because my account had just 4 Energy left when this transaction was done.

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

The sure-set way to get energy without having to burn TRX is to freeze your TRX to receive TP and Energy. However, to get enough energy to accommodate the entire JustLend USDT borrow transaction would be 6841.53954. This is something that not all of us might readily have.

image.png
This was calculated using https://tronstation.io/calculator

The other way to do this is to make use of https://tronlending.org/ to rent out the Energy for a fixed price.

1- Once you are in tronlending.org, enter the amount of TRX that you would have had to freeze to receive the required energy. From my calculations previously, I would have needed to freeze 6841 TRX to complete one USDT borrow transaction on JustLend. So, I have entered that in the rental amount field.

2- I have also chosen to go the minimum number of rental days as well. By least number of days on tronlending is 3 days.

image.png
Estimated costs

3- From the above estimates, you can see that I would need 50.06 TRX to get this energy in my account. Simply burning TRX would cost me just 35 TRX. However, this energy that I am renting out will be available for 3 days. So, if I aim on using it for all 3 days, then using this makes complete sense.

(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)?

** JustLend**

image.png

On tronscan.org, hover over the JustDeFi tab on top and you will see JustLend on the dropdown. Click on it and you will be redirected to JustLend's site.

On JustLend I have already set TRX as collateral. So, I am all set to borrow USDT now. You can do this by clicking on the Borrow button next to the supply button on the market section.

image.png
Maximum USDT I can borrow after using 100TRX as collateral
1- The maximum USDT that I can borrow is 7.3. However, for this assignment, I will be borrowing just 1 USDT.

2- On accepting the transaction on my TronLink wallet, I will receive the 1 USDT. This makes use of the borrow method and is one of the most resource-intensive functions.

image.png
Bandwidth Consumed=313 and Energy Consumed = 204506
3- As you can see from the above screenshot that this used over 200000 energy for borrowing just 1 USDT.

JustSwap
image.png

1- On tronscan.org, hover over the JustDeFi tab on top and you will see JustSwap on the dropdown. Click on it and you will be redirected to JustSwap's site.

2- Here, by default, the from token would be set to TRX. You will need to set the To Token.

image.png
I have already set the To token to USDT here

3- Then enter the number of tokens you want to receive or swap. This will automatically calculate the other field for you.

image.png
In this screenshot I provided 1 USDT in the To field and the 8.25 TRX awas auto-calculated based on current market values

4- Click on Swap and accept the transaction on the tronlink wallet popup.

10.PNG
Click on accept

This would swap the tokens and you will see it reflect in your wallet once the transaction is confirmed on the blockchain.

I can now head over to the transfers tab on tronscan and see the resources us=tilized for this transaction. The transaction on JustSwap used up 1/4 of the energy used by the transaction on JustLend.

image.png
The Energy used was just 55377 and the Bandwidth used was 350 for this transaction

So, we can say that JustSwap uses very slightly more bandwidth than JustLend. However, the energy used by JustLend for my transaction was 4 times the energy used by JustSwap for the same value of tokens.

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

To do this, you can check the transactions in the transfers tab on tronscan.org. Over here, TRX & TRC10 represent normal transfers(Use only bandwidth) and TRC20 & TRC721 represent smart contracts(Requires Energy)
I will choose the transaction of me freezing 100 TRX to receive Energy and TP.

By clicking on the hash, you can find the details of the transaction along with the resources used.

image.png
255 Bandwidth was used
As you can see from the attached screenshot, only bandwidth was consumed in this transaction

By switching over to the TRC20 & TRC721 tab in the transfer section, you can find all smart contract executions. Here, I will choose my supply transaction of 100 TRX.

image.png
Bandwidth=284 Energy 80377

As you can see that smart contract execution makes use of Energy in addition to bandwidth. Since smart contracts consume a considerable amount of CPU, we have energy consumption which represents its usage.

Disclaimer: All transactions were made using the same TRX wallet that is linked to my Steemit account.

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.

However, to get enough energy to accommodate the entire JustLend USDT borrow transaction would be 6841.53954.

Yes, and a small scale trader may not have that much amount. Further, it will be sufficient only for one function(borrow). In the entire loop(mint, borrow, repay, etc), you might need more than that. So the cost-effective way is to lease it from TronLending, but again that depends on the liquidity in the Lending market.

However, the energy used by JustLend for my transaction was 4 times the energy used by JustSwap for the same value of tokens.

That's correct. And evidently, the borrow function consumes the highest amount of Energy as compared to other types in JustLend.

Suggestions/Feedback

  • The author has produced real transactions to demonstrate Bandwidth & Energy. He has also made the comparison of resource conumption.
  • The author has included all the relevant screenshots required in this Task.
  • The author has produced a well organized article.

Thank you.


Homework Task -5 accomplished.
[9]

Thank you @sapwood