Diving into DeFi: Gas, Gas Fee and Network Miners - Transaction Optimization

in #steemcryptochallenge4 years ago (edited)

A Guide to Transaction Fees Optimization on Ethereum Blockchain



Image credit


Gas


Just like conventional vehicles need gas or fuel to run, transactions also need to be powered by something. Some form of energy is needed to make transactions happen. For centralized systems like banks, when you make a transaction, for instance a bank transfer, that transaction happens because the bank provided you with their services. Exclude the bank services and the transaction will not happen. These bank services are the energy that makes the transaction to happen. You can call these services the gas or fuel needed for banking transactions.

For DeFi, the story is somewhat the same. When you initiate a transaction on a DeFi blockchain, some resources are used to make that transaction happen. They are called computing resources. These computing resources are the fuel behind transactions on DeFi blockchains and they are referred to as gas.


Network Miners


Talking about mining is really cool stuff but you may not have time left to read other posts so let's just stick to who network miners are and what they do.

First of all, you need to know that blockchains have what is called communication points. In a blockchain, communication is carried out one way or the other between different parties. The points of origin and destination of each communication is called a communication point. These communication points are referred to as nodes. Nodes differ based on their functions, however, for the purpose of this context, we're considering just one kind of node - the miner node.

The miner node is a destination point kind of communication point. When transactions are made on a blockchain, these transactions are sent to all the nodes in the network. The miner node gathers the transaction it receives and organizes it into a block. Now there are a lot of miners that can be on a network and they compete for who will create a valid block first. Whoever does creates first, gets a reward.

Mining needs some really cool hardware stuff and also a lot of electrical power. For the miners to be able to provide this, their reward has to be significant. For some blockchains based on a consensus algorithm called the-proof-of-work, this miner nodes are the most important nodes in such blockchains and the mining reward is a necessity for such blockchain to run.


Gas Fee


If you've used blockchain applications like crypto wallets or Decentralized Apps (DApps), you can recall that you paid a certain fee when carrying out a transaction. This fee is paid to the miners to reward them for their efforts and also to replace the resources they used up in completing your transaction.

Recall that the resources they used up in completing your transaction are the energy without which your transaction wouldn't have been completed. These resources powered your transactions and they are other wise know as gas. The fee you paid is thus called a gas fee


Fees for different blockchains


Depending on the consensus algorithm or protocol the blockchain is based on, the fees may vary. Tron blockchain is based on Delegated-Proof-of-Stake (DPOS) while Proof-of-Authority (POA) is the consensus protocol of the POA network. For this post however, we're focusing on Ethereum block chain.


Ethereum


For Ethereum, the consensus algorithm used is proof-of-work. The fee charged is known as gas fee. Like we said earlier, this gas is the resources need to complete a transaction. For simple transactions like simple exchanges, the fee is lower but if you're dealing with smart contracts, it's higher.

One funny thing with this is that the amount of gas needed is it can only be determined after the transaction has taken place and yet you have to pay for it before the transaction takes place. crazy stuff right? Well, you could go crazy if you pay the wrong fee cos your transaction could be left uncompleted for days. Now to get it right, you have to ask the dApp provider for previous fee amounts, then try and put in something higher than the average.

The transaction cost or gas fee is determine by the following

Gas Fee = Gas price x Gas Limit

Gas Limit is the maximum amount of gas that a user is willing to pay for in completing a transaction. This can usually be set up by the user.

Gas price is the maximum amount a user is willing to pay for 1 unit of gas. The amount is in gwei

1 gwei = 1 nanoether or 0.000000001 ETH


Transaction Fee Optimization on the Ethereum Blockchain


Whether your transaction is completed or not, the gas used cannot be refunded, so when you're setting your fees, you need to make sure whatever is set is optimal. Here are a few tips to help you set your fees to optimal.

To optimize your transaction fee, need to know that

  • A transaction will not be completed if the gas allotted for that transaction finishes before the transaction is completed.
  • Gas used up in performing a transaction cannot be returned whether the transaction is completed or not.
  • There is no need to be scared of setting too much gas limit. If any gas remains, it will be returned to your wallet.
  • The amount of gas needed differs for different transactions. It's smaller for simple exchanges and larger for more complicated transactions like those involving smart contracts.

Upon knowing this, you can then set an optimal fee for any of your transaction.


Thanks for reading.


Sort:  

Yes i agree for any services we need to pay some amount.

But in ETH Defi,some times we need to pay gas if transaction not completed too,our gas fee not possible to withdraw. Those price is very high now a days. For small investors its very hard to handle.

Nice post from you. Have a great day ahead.

#twopercent #india #affable

Thanks for reading friend.

You have to optimize the price you set at the beginning. If you don't by enough gas, transaction will not be completed because gas will get finish while transaction is still on. Also If you pay a lower price and there is a lot of other transactions with higher gas fee, your transaction will not be attended to rather the miners will attend to the transaction that paid higher transaction fee.

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.030
BTC 58613.96
ETH 3153.58
USDT 1.00
SBD 2.43