What is Ethereum Gas and How does it Work?

What is Ethereum Gas and How does it Work?

First thing’s first, let’s get this out of the way: Ethereum Gas is not its own cryptocurrency. Sure, there’s Ethereum, Ethereum Classic, and a bunch of other Ether-derived tokens, or tokens running on the Ethereum platform—but Gas isn’t one of those. Gas is something else. Something much more interesting, and it’s essential to understanding the mechanics of Ethereum. Essentially, Ethereum Gas is what it sounds like; it’s fuel—it’s a measurement of the amount of work an action on the Ethereum network will take to complete, and, like petroleum, its price fluctuates based on the market.

 

An Introduction to Ethereum Gas

At its core, Ethereum is a platform on which smart contracts are executed. A smart contract is a conditional transaction: it allows money and other assets such as deeds to be transferred only after certain conditions have been met by both transacting parties. These contracts are verified by the decentralised Ethereum network via a proof-of-work system, which needs to be incentivised in order to operate efficiently and thus transfer the large (or small) amounts of capital associated with a given transaction. Enter: Ethereum Gas, a measurement of the amount of work a set of actions will cost the network.

 

How Much does Ethereum Gas Cost?

Ethereum Gas and its associated costs are similar to Gas in a car. Let’s look at a (simplified) real-world example: let’s say your car will drive 10 kilometres for 1 litre of fuel. For the sake of the example, let’s assume driving 10 kilometres will always use 1 litre of fuel. However, this doesn’t mean it will always cost the same amount of capital to drive 10 kilometres, because the cost of 1 litre of fuel can and will fluctuate as per market conditions.

This is how Ethereum Gas works too. A given action undertaken on the Ethereum network always costs the same amount of Gas (because always requires the same amount of processing power), but the market—comprised primarily of miners running nodes and undertaking the proof-of-work calculations necessary to keep Ethereum decentralised and secure—determines how much a unit of Gas costs at any given time.

Different actions cost different amounts. We’re not going to go through all of them, or even close, but what we can do is include the screenshot above, drawn from the Ethereum Yellow Paper, which outlines the Gas necessary to execute any given action on the network. If you want to really understand Ethereum inside and out, check out this foundational paper in full, from which you can learn the basis of everything from the philosophy to the mathematics of the cryptocurrency.

In fact, we advise you do this for any crypto you want to seriously assess the true value and mechanics of: these documents (usually referred to by the blanket term whitepapers) are the cornerstone of any crypto and its development team. Everything that happens with a given cryptocurrency will always be tied back to the whitepaper, and although cryptocurrencies do evolve over time, they tend to stay true to these documents—though when a contentious change is made, which some people believe contradicts something laid out in the whitepaper, that’s when a fork tends to occur. And so, you get Bitcoin Cash and Ethereum Classic. It’s kind of like a religious schism caused by the varied interpretations of a sacred text. But that’s a different article altogether.

 

Gas Usage in More Depth

Now, let’s look at some more details surrounding Gas usage in Ethereum.

An Ethereum smart contract is written in code, in a programming language called Solidity, which uses basic if-then logical statements to run. Each line of code contained in a smart contract costs a certain amount of processing power, measured in Gas, to execute—the longer the contract, and the more complex the code is computationally, the more Gas it costs.

At minimum, a transaction attracts a fee of 21,000 Gas to be executed. Additional costs are determined based on the specifics of the code, and how computationally-intense a given process is.

 

What is the Current Market Rate of Ethereum Gas?

The price of Gas is measured in Gwei. 1 Gwei is a fraction of an Ethereum token—one billionth, or 1/1,000,000,000. For a quick comparison, 1 Satoshi, the smallest possible fraction of a bitcoin, is one millionth, or 1/1,000,000.

There is a great resource online called ETH Gas Station, which will not only give you an overview of the current market rate for an Ethereum transaction, but will also let you know how much you need to pay in order for your transaction to go through the network as fast as possible.

On the site, you can also enter how much you’re willing to pay for Gas, and the site will give an indication of how long the transaction will take given the price you’re willing to pay.

Again, because all of this is driven by decentralised supply and demand mechanisms, the price is not consistent, but at the time this article was written the price of Gas was sitting at 7.1 Gwei, or 71/10,000,000,000 Ethereum, or $0.00000143633 USD. For context, at this time one Ether cost $202.30 USD, and a base-level transaction on the Ethereum network cost 3 US cents—$0.03—to execute. This is pretty crazy cheap.

 

How and To Whom is Gas Sent?

For a transaction or contract to be executed, the sender must indicate how much they are willing to spend on Gas. Ether miners select contracts that pay enough Gwei per unit of Gas to make it worth executing, which is why a willingness to pay a higher amount for a given transaction allows a faster execution—miners, being economically motivated, will prioritise contracts that will make them more money.

This leads to how the economics of transaction fees are discussed by those in the Ethereum space. The lingo is as follows: Low Gas, Low Fee, High Gas, and High Fee.

Low Gas: Not even enough Gas to execute the contract. Miners won’t pick this up. Generally, this is user-error on the transactor’s end.

Low Fee: Enough Gas to execute the contract, but not much Gwei left over. Unappealing to miners, but is likely to eventually get picked up if a block needs filling.

High Gas: Indicates to miners that the contract is bloated and likely will not be worth the hashing relative to a given payout.

High Fee: Indicates to miners that they could make a lot of money from executing this contract. Miners will pick it up instantly.

 

How Do Gas Refunds Work?

Just when you think you’ve got this whole thing figured out, there’s yet another dimension to Gas: the refunding process.

See, you are able to over-allocate Gas. Even if a contract will only take so much processing power, you can allocate more to either incentivise a miner or to compensate for potential errors in the code. The amount a transaction will cost is the Gas amount multiplied by the Gas price. Any leftover Gas is then, hypothetically, subtracted from this amount when the miner is paid. But there are now elements of code that allow miners to keep at least a portion of the over-allocated Gas. You can parse this information in more depth below via a table from the Ethereum Stack Exchange which summarises it really nicely (you just might need to read it more than once).

The explanation from the Stack Exchange:

“At the start of a transaction, the Ether required for the startGas is set aside [1b], and the remainingGas is set to startGas [1a]. [ 2 ] With each operation of the transaction, Gas is consumed and remainingGas is lowered. [ 3 ] If there’s an Out of Gas exception, all operations are reverted and all the Ether that was initially set aside is given to the miner [ 4 ]. [ 5 ] If the transaction completes successfully, all the remainingGas is refunded to the originator and the rest is paid to the miner.”

Importantly, if you miscalculate the amount of Gas necessary to undertake a transaction, and the transaction fails, then the miner will still be paid for their hashing—there are no refunds for mistakes made by a transactor. It’s a dog-eat-dog world out there, friends. Better make sure you’re always double-checking your maths.

 

In Conclusion: Ethereum Gas is fuel

Is some of this more than a little confusing? Yes, yes it is. But if you want a quick set of touchstones in order to navigate gas, here are a few key things to remember.

  1. There is a difference between the amount of Gas allocated and the price set per unit of Gas.
  2. You cannot actually possess Gas—rather, Gas is a measurement of processing power required to execute code on the Ethereum network.
  3. The price of Gas is determined by market forces and fluctuates.
  4. The fee for a given transaction on the Ethereum network is Gas amount x Gas price.
  5. In order for your transaction to be executed, you need to ensure you have allocated enough—but not too much—Gas.
  6. Your contract will be picked up by miners in proportion to how competitive you’ve set the price per unit of Gas in Gwei/Ether.

Remember all this and you’ll be fine navigating the wild world of Ethereum contracts. If you want to write your own contracts, or understand them in more depth, then I suggest you begin by heading on over to give the Ethereum Yellowpaper a read-over with your own eyes.




Also in Crypto Market Insights

Six Things You Must Know Before Investing In Bitcoin
Six Things You Must Know Before Investing In Bitcoin

We here at Digital Currency Markets have a pretty good idea about bitcoin. In fact, we built a whole site around it. So we figured what this site could use is a nice little rundown of what we know that we think you need to know before you start your bitcoin journey.

Continue Reading

Top 5 Best Bitcoin Books You Must Read In 2019
Top 5 Best Bitcoin Books You Must Read In 2019

Reading books may feel antiquated when it comes to decentralisation and blockchain—after all, these are digital, post-paper terms which are laying the foundation for a future in which books are delivered exclusively from the cloud, or read primarily in a pre-condensed form. But don’t be fooled: to this day books and other long-form texts are still the best way to gain a nuanced understanding of any given topic. Yes, it’s a bit more of a time investment than Twitter, but as with cryptocurrency whitepapers, the time invested yields dividends in knowledge that, if utilised correctly, can in turn yield good amounts of capital.

Continue Reading

Trading Crypto: Centralised Exchanges vs. Decentralised Exchanges
Trading Crypto: Centralised Exchanges vs. Decentralised Exchanges

Most people involved in the cryptocurrency space who aren’t motivated purely by monetary gain will likely find themselves at some point saying something like this: “One thing I really like about cryptocurrency is that it’s decentralised, and that the currency isn’t owned or controlled by a bank or state.”

With all that in mind, this article will teach you to understand the key differences, successes, and failings of both centralised and decentralised crypto exchanges.

Continue Reading

Use Digital Currency – How it works

How our Bitcoin Gift Card works

What is a Bitcoin Gift Card?

A Bitcoin Gift Card is the perfect way for the newcomer to get their first Bitcoin. It comes with a paper wallet and simple instructions to set up a software wallet so that you can transact with Bitcoin over the internet. Bitcoin Gift Cards are available in AU$25, $50, $100 and $500 denominations.

Who should buy a Bitcoin Gift Card?

Anyone new to Bitcoin will find no easier way to get their first Bitcoin.

They can be gifted by an existing cryptocurrency enthusiast, or bought by anyone wanting to get involved for the first time themselves.

How can I pay for my Bitcoin Gift Card?

You can pay with either cryptocurrency through our coinpayments.net payment gateway, or you can use Australian Dollars through our POLI Pay facility.

Can I use a Bitcoin Gift Card to top up an existing software wallet?

Yes. When you receive your additional Bitcoin Gift Card, you can simply import the "Secret" wallet identifier from your Bitcoin Gift Card into your existing software wallet. This will move your Bitcoin from your Bitcoin Gift Card into your existing software wallet. 

What does my Bitcoin Gift Card include?

Your Bitcoin Deposit, wallet and key generation and network transfer.

How long does it take to receive my Bitcoin Gift Card?

Going through to checkout takes about 2 minutes. You won't find an easier process anywhere. Once you've placed your order, it can take between 10 and 60 minutes to receive your Bitcoin Gift Card depending on the speed of the Bitcoin network at time of purchase.

How our Flexi eGift Cards work

We have partnered with GiftPay, an aggregator of online deliverable eGift Cards in Australia.

Through our agreement with GiftPay, you are able to purchase a Flexi eGift Card from us, redeemable at a broad range of retailers in Australia.

Watch the Video to see how it works

What is a Flexi eGift Card?

A Flexi eGift Card is an electronic gift card that lets you choose where you'd like to shop! In the past if you were given a gift card for a particular shop but didn't want to buy anything from that shop, you were stuck. But now with a Flexi eGift Card, you get to choose at which shop you spend your gift. 

What's more, you may be able to split your Flexi eGift Card and spend it at different shops! For example, if you have a $30 Flexi eGift Card, you could choose to split it up into a $20 Myer eGift Card and a $10 iTunes eGift Card. 

Where can I spend it?

You can spend your eGift Card at a broad range of Australian retailers. For a full list of our retailers, click here. (page showing full list of retailer logos)

How do I redeem it?

Your Flexi eGift Card will be emailed to you. Click the link in the email to open your Flexi eGift Card.

Then convert your Flexi eGift Card into any combination of gift cards or vouchers up to the total available balance. How you redeem your chosen gift card depends on the card or voucher chosen.

Pay a BPay Bill

What Bills can I pay?

You can pay any bill that has the BPAY logo and Biller Code including credit cards.

Are there any payment limits?

Yes. You can pay a maximum of $1000 per transaction based on regulatory limits. You can however break up a bill into multiple $1000 tranches and enter the same biller and customer reference code.

How does the transaction work?

When you enter the amount you wish to pay, the BPAY biller code and your bill’s customer reference number, you will click through to our checkout.

At checkout, you will be asked to leave your details, which enables us to satisfy our legal requirements under the Anti-Money Laundering and Counter-Terrorism Financing Amendment Act 2017. This sounds ominous, but takes about 2 minutes.

When you proceed to payment, you will be shown the digital currency amount payable and the wallet address to send your digital currency to.

Once you have sent your digital currency to our payment gateway wallet, you will receive an email notifying you that your payment has been received. We then convert your digital currency to AUD and pay your BPAY bill on your behalf.

Are there any fees?

Yes. At checkout you will notice our 3% fee added to your bill amount. This is to help us manage the currency risk of a volatile digital currency market when converting to AUD for us to pay your bill. We use a third party payment gateway to enable the digital currency transaction. Our considerations when choosing a gateway was security, pricing (spread) and speed. You’ll note when at checkout (before proceeding to payment) that the price you receive on your digital currency is very competitive. Other digital currency BPAY facilitators charge up to 6% per transaction on the currency alone, which in our view is akin to highway robbery.

 

[Free PDF Download] 5 Costly Mistakes When Transacting in Crypto Cheat Sheet

Enter your details to access your cheat sheet.