The Ins and Outs of Gas

Claire Royle
teamglasses
Published in
3 min readOct 3, 2018

Beans, beans, good for the heart.

The more you eat, the more you fa — —

NO! Not *that* kind of gas! I’m talking about gas on the Ethereum network!

By now, hopefully you are familiar with the concept of blockchain and crypto. If you want a quick refresher, check out this post. Basically Ethereum is the network, and Ether (ETH) is what powers that network. When you use the Ethereum blockchain to send a transaction you must pay for it to use that network. That payment is known as gas and is paid in ETH.

Paying for gas is not a guarantee that a transaction will be successful. Even if the transaction fails, miners must still validate the transaction, which is what the gas pays for.

Gas refers to either the limit or the price of gas.

Gas limit is probably the easier to understand, and what most people mean when referring to gas. It it is literally the upper limit that you are willing to spend on gas for a particular transaction. This limit is imposed so that the network does not inadvertently use a whole ETH worth of gas (for context, gas is usually a very small percentage of the total transaction. We’re talking pennies on the dollar here…). As the price of gas is determined by data already on the blockchain, a limit that is too low will result in a failed transaction and an “Out of Gas” error message. Conversely any unused gas is always refunded to your account at the end of a transaction.

Gas price is just as simple, really. Just as the price of gas to fill up your car is the price per gallon, the price of gas on the blockchain is the price it will take to get your transaction to the next block. The gas price also dictates how long it will take for a transaction to reach its destination, with lower gas prices taking longer. Gas is priced in GWei, a very small unit of Ethereum where 1 GWei = 1 x10^-9 or 0.000000001 ETH. MyEtherWallet has a tool that allows for quick conversion here.

So, what do you actually pay?

The cost of a transaction, also known as the TX fee, is the Gas Limit multiplied by the Gas price.

According to the Ethereum Yellow Paper, a transaction requires at least a 21,000 gas limit.

The gas price is dependant upon how many other transactions are competing to get on the next block so i recommend checking Etherscan for the current safe price.

Let’s say we have set the gas price at 20 GWei and a gas limit of 21,000. The total TX fee would be 21,000 *20 GWei = 0.00042 ETH, which as of August 29, 2018 is about 12 cents.

Having high or low gas and fees, or some combination thereof, will determine whether a miner will think validating your transaction is worth it to them, and will affect how quickly your transaction succeeds or fails.

Individuel token sales may have their own recommendations for gas, so be sure to check with the company before sending money to a smart contract.

Economics and Gas

Supply and demand of economics governs everything — including blockchain. Even though ETH has an endless supply, the more people demand it for gas, the higher the price will rise. I have simplified the concept hugely, but when millions and millions of transactions are trying to be computed, the network will get clogged up and gas will spike.

Examples of this can be seen in CryptoKitties and the Chinese coin clog and gas spike of earlier this summer.

Just like we rely on gas to power cars, the Ethereum blockchain uses gas to push transactions through the blocks. While we may not like the fees that miners take to validate our transactions on the network, it is important that we understand the components of gas and the reasons for its existence. Through educating ourselves on gas, we can securely use the blockchain in a way that everyone can benefit from.

--

--

Claire Royle
teamglasses

Claire works as customer support at Team Glasses, LLC. She lives in Texas with her husband and dog, and loves baking and doing crafts. www.teamglasses.io