So, what exactly is gas? Why are transaction fees so high at the moment, and what are some of the ways to make the transaction cost lower? You'll find answers to these questions in this video


Download 10.73 Kb.
Sana03.10.2023
Hajmi10.73 Kb.
#1690690
Bog'liq
6.ETH gas


So, what exactly is gas? Why are transaction fees so high at the moment, and what are some of the ways to make the transaction cost lower? You'll find answers to these questions in this video. Before we begin, if you want to learn more about decentralized finance and the technology behind it, make sure you subscribe to my channel, hit the bell icon, and enable all notifications. You can also consider joining us on Patreon and learning even more about DeFi.

Let's start with what gas actually is. Gas is a unit used for measuring the amount of computational effort required to perform specific actions on the Ethereum blockchain. The name itself hasn't been chosen by accident. Similarly to gasoline fueling a car and allowing it to drive, gas on the Ethereum network fuels transactions and allows them to perform different operations.


Every operation on the Ethereum blockchain, or to be precise, on the Ethereum Virtual Machine, has an associated gas cost. For example, adding two numbers costs three gas, getting the balance of an account costs 400 gas, and sending a transaction costs 21,000 gas. Smart contracts usually consist of multiple operations that together can cost even hundreds of thousands of gas.


What is interesting is that the gas cost by itself doesn't tell us how much we have to pay for a particular transaction. To calculate the transaction fee, we have to multiply the gas cost by the gas price. The gas price is measured in Gwei, a smaller unit than Ether, where one Gwei equals 0.000000001 Ether. We can think about it as a major and minor unit, similarly to dollars and cents.


As an example, let's say we want to send a simple Ethereum transaction, and the Ether price is at $1,800. Most of the popular Ethereum wallets, such as MetaMask, estimate necessary gas prices and allow us to choose between fast, medium, and slow transaction confirmation speeds. Let's assume that the wallet estimated the gas price to be set at 100 Gwei. If we want to have a chance of having our transaction confirmed within the next minute, we can quickly calculate that we have to pay $3.78 for such a transaction. We multiply the gas cost for sending a transaction (21,000 gas) and the gas price (100 Gwei). This is equal to 2.1 million Gwei, which is 0.0021 Ether. At the Ether price of $1,800, that gives us $3.78.


It's worth mentioning that gas is only an abstract unit that exists only inside the EVM, and the user always pays for the transactions in Ether. The main reason for having a separate unit for measuring computational effort is to decouple it from the price of Ether. This means that an increase in the Ether price should not change the cost of transactions. If the network activity stays the same and the price goes up, we should see the gas price going down, so the final transaction cost measured in Ether stays the same in dollar value.


Saying this, a price increase of Ether is very often correlated with an increase in the activity on the Ethereum network, something that indeed increases the cost of transactions. Now let's see how exactly an increase in network activity causes the transaction cost to go up.


To start with, all transactions sent to the Ethereum network land in the mempool. This is a place where all pending transactions are waiting for the miners to pick them up and include them in the next Ethereum block. Miners are incentivized to pick up transactions with the highest gas price first, as they are basically doing a fixed unit of work for a better price.


Miners are also limited to how many transactions they can include in one single block. This is determined by the maximum gas limit per block. At the time of creating this video, this limit is set to 12.5 million gas. As a quick example, let's assume there are only simple Ether transactions in the mempool, each one costing 21,000 gas. A miner can include around 595 such transactions. If there are, let's say, 1,000 pending transactions in the mempool, the miner would choose transactions by sorting all pending transactions by the gas price and choosing the 595 most profitable ones.


The current fee model is based on a simple auction mechanism, and the users who want to have their transactions picked up by miners first have to essentially outbid other people for the space in the block. This, in turn, drives the gas price higher, especially at times when a lot of users have urgent transactions that they want to confirm.


To wrap up the gas explanation, it's also important to understand why gas has to exist in the first place. EVM, as a Turing-complete machine, allows for executing any arbitrary code. Although this is one of the main reasons that makes Ethereum so powerful, it also makes it vulnerable to the halting problem. The halting problem is the problem of determining from a description of an arbitrary computer program and an input whether the program will finish running or continue to run forever.


Without gas, a user could execute a program that never stops, either by making a mistake in their code or just by being malicious. To prevent this, Ethereum introduced a gas cost associated with each operation that would prevent a program from running forever and bringing the whole network to a grinding halt.


Besides the gas price, each transaction also has a gas limit that has to be equal to or higher than the anticipated amount of computation needed for successfully executing a particular transaction. EVM, before executing each operation within a transaction, checks if there is enough gas left for that operation. In case there is not enough gas left, the whole transaction is reverted with an "out of gas" exception, and all state changes are rolled back. The user would still pay the transaction fee for the amount of work that has been done by the miner, even if the transaction fails. This is again to avoid attacks on the network.


If the transaction consumes less gas than initially anticipated, the remaining amount of gas is converted to Ether and refunded to the sender. It's also really important that all operations on Ethereum have the correct gas cost in relation to each other; otherwise, that could be another attack vector. One of such attacks took place in 2016 and resulted in the hard fork that repriced certain low-level operations.


Now, as we know a bit more about gas, let's have a look at the recent period of high transaction fees and a few solutions that can lower the transaction costs now and in the future. But before we discuss that, if you made it this far and you enjoyed the video, hit the like button so this kind of content can reach a wider audience.


With record volumes on decentralized exchanges, the highest total value locked on DeFi lending platforms, multiple yield farming opportunities available, and minting more and more NFTs, the Ethereum network is as busy as ever. This popularity results in high demand for block space, which in turn results in high transaction costs. It's not uncommon anymore to pay more than $10 for a simple ERC-20 transfer or $50 to $100 for a Uniswap transaction. This, of course, is not ideal, as it makes it really hard for smaller players to participate in the Ethereum ecosystem.


Fortunately, there are multiple solutions either already available or being actively worked on. Let's go through some of the most important ones.


Layer 2 scaling is a collective term for solutions that help with increasing the capabilities of the main Ethereum chain (Layer 1) by handling transactions off


-chain. Besides improving transaction speed and throughput, Layer 2 solutions can greatly reduce the transaction fees. Loopring is a good example of a decentralized exchange built on Layer 2 that is getting more and more popular. The exchange has recently hit $200 million in total value locked and over $10 million in daily trading volume. Another project, Matic, which has recently rebranded to Polygon, also hit over $200 million in TVL.


Polygon under Plasma Plus, Pulse Chain, and a more general-purpose solution, Optimism, that is based on optimistic roll-ups, is also being rolled out. This is important as it will allow DeFi smart contracts to interact with each other in a similar way to how they interact on Layer 1. One of the missing pieces that can increase the adoption of Layer 2 solutions even further is direct onboarding to Layer 2. This could decrease the cost of transactions even further, as users would be able to transfer their Ether directly from an exchange to a Layer 2 solution like Loopring.


If you want to learn more about Layer 2 scaling, check out this video here. Besides Layer 2 scaling, another solution that can decrease the transaction cost in the long run is Eth2, which introduces sharding and proof of stake. You can learn more about these concepts here.


EIP-1559 is another solution for optimizing the transaction cost. Although the proposal will not have a direct effect on lowering the transaction cost, it will allow for optimizing the fee model by smoothing the spikes and limiting the number of overpaid transactions. This will make transaction fees more predictable. From the timeline perspective, it looks like EIP-1559 could be implemented in early 2021. Here is a separate video that explains EIP-1559 in depth.


Besides using Layer 2 scaling solutions and waiting for other improvements, there are a few other tricks that can help us with lowering our transaction costs on Layer 1. First of all, if we don't have any urgent transactions, we can try to find times of the day when the gas prices are the lowest. Besides this, we should always double-check the gas cost estimated by our wallet with a separate reliable source, such as EtherGasStation.info.


Another trick used by One Inch exchange allows for lowering transaction fees with CHI tokens. These tokens must be burned alongside the primary operation, which allows for reducing the total amount of gas spent in a transaction. This can be achieved by leveraging an EVM mechanism that refunds gas when storage space is freed. When CHI tokens are minted, dummy smart contracts on the Ethereum blockchain are created. Burning CHI destroys these contracts and results in a gas refund.


So, how about other chains besides Ethereum? There is no doubt that the recent period of high transaction fees on Ethereum resulted in a few other chains capturing a meaningful amount of users and volume. At this point, it's hard to say how much of this will be a short-term play versus a longer-term user acquisition. Saying this, we have to keep in mind that some of these chains are not fully decentralized and permissionless. This basically creates a fake DeFi ecosystem that may be fun to play with, but it's actually not that much different from using a centralized exchange.




So, what do you think about gas and high transaction fees? What is your favorite way of lowering it? Comment down below. And as always, if you enjoyed this video, smash the like button, subscribe to my channel, and check out Filmatics on Patreon to join our DeFi community. Thanks for watching.
Download 10.73 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling