FREE SHIPPING ON ORDERS OVER $50



What is Gas in Ethereum and how much should I pay for an Ethereum transaction?

Posted by Taras Lanchev on

"I didn't have enough gas to complete a transaction! What does that mean? How do I get around it?"

I hear those questions asked very often by the people who are into Ethereum. And it's fair enough. I only recently learnt what Gas, Gwei and Contracts are. We already talked about how much you should pay for a Bitcoin transaction, but this time the challenge is a bit harder. So let's get down to it!

1 ETH = 1000000000000000000 wei = 1000000000 gwei (shannon) = 1000000 szabo = 1000 finney

This is how Vitalik and Co trolled the whole Ethereum community. Still don't get it? They called Ether denominations after prominent cryptocurrency figures.

Hal Finney - the first user of Bitcoin (after Satoshi Nakamoto, of course)

Nick Szabo - the guy who came up with the idea of smart-contracts

Wei Dai - a creator of b-money (essentially Bitcoin's grandfather) 

Want to know more about the names? Read this.

If you are a new Ethereum user you will probably be amazed and annoyed at the same time about the names and concept of Gas. Bitcoin was much easier - you set the transaction fee and wait for the transaction to go through. If the fee is small - it takes longer for the transaction to go through. If the fee is large - it goes through quicker.

The thing is, Bitcoin was created as a currency to allow people to transact with each other. The difference with Ethereum is that it has a Decentralised Virtual Machine which allows people to launch decentralised applications/smart-contract(s) if there is enough time and memory left. For all the nerds out there - they use Solidity to do it. You can also read more about the Decentralised Virtual Machine here. In a nutshell, Ethereum was created not as a currency, but rather as a platform to create applications with which would use Ether for payments.

How does Ethereum work?

In my post about Ethereum wallets, I mentioned that the official wallet is super resource-intensive. This happens because your computer is running that exact Virtual Machine which processes all the decentralised application.

What can you make on Ethereum's network? Gas

For simplicity purposes, let's look at the 3 things you can do on the Ethereum network:

1. Transfer ETH to another user

2. Create a smart-contract (application) and write it to the blockchain

3. Run a smart-contract (application)

You have to pay for each one of these actions on the network. "Gas" is a unit of payment on Ethereum's network and each action costs a certain amount of Gas. You can make a parallel with a car. If you need to drive to the shops - you need to pay for a small amount of gas, but if you want to drive to a different city you will need to pay for much more gas.

Therefore:

1. In order to transfer Ether from one wallet to another, you will need to pay 21000 gas.

2. The amount of Gas will vary depending on what kind of smart-contract (application) you will need to create. Let's use a random contract, for an example:

A screenshot of a randon transaction on Etherscan Block Explorer as an example of how gas is used to create smart-contracts

Each contract has a "Contract Creator" section where you will be able to see the address of a person who created the contract and a transaction which initiated the contract on the blockchain (highlighted in red). If we look at our example contract we'll see that whoever created the contract spent 219780 Gas on it.

3. In order to execute a contract, you also need a certain amount of Gas. The thing to remember here is that each contract requires a different number of operations to run and therefore the amount of Gas to run the contract varies. If we look at the example contract we've chosen above we can see that each user paid 22968 Gas to execute it. You can check it for yourself by clicking on any TxHash records:

How to check how much Gas it takes to run each Ethereum contract on Etherscan Block Explorer

You can also check out the Ethereum's Yellow Paper (page 20) to learn more about how much Gas is needed for each operation. For example, in order to write something on the Ethereum's blockchain, you will need much more Gas than for multiplying two numbers together.

The whole smart-contract concept is super interesting, but it is even more interesting to developers. By the way, you can even check the transaction code on Etherscan and see what is happening there.

Transactions on the Ethereum network

Every transaction on the Ethereum network consists of 4 parts:

1. The address of the receiver

2. The amount you want to transfer (it could be 0)

3. The maximum amount of Gas for a transaction

4. Additional info

This is a screenshot from MyEtherWallet:

A screenshot of a transaction screen on MyEtherWallet

A screenshot from the official Ethereum Wallet:

A screenshot of a transaction screen from the Official Ethereum Wallet

When you put the transaction into the block you run a piece of code (if it is a request to the smart-contract) and whatever Gas the contract uses is transferred into Ethereum from you to the miner in a form of the reward.

The Gas limit (maximum gas per transaction) is a way of restricting the amount of Gas you are willing to spend on a transaction. If, for example, you put your gas limit at 1,000,000 gas, but the smart-contract only needs 50,000 gas to run you will only spend 50,000 gas. The limit was developed as a way of protecting users from spending more than they actually have. For example, if a contract started running an infinite loop and the user would've been losing money without a stop.

Also, if the smart-contract needs 1,000,050 gas to run, but you put your limit at 1,000,000 then the contract won't finish running and won't give you the desired result. Saying that, developers typically say how much gas is needed to execute a contract.

- Sooo, how much does gas cost?

- It depends because the users set the price themselves in ETH

How to calculate how much Gas in Ethereum costs on MyEtherWallet

If you look at the top right on MyEtherWallet you will find a slider where you will be able to change the price of gas starting from 1 to 99 Gwei = from 0.000000001ETH to 0.000000099ETH.

Transfering Ether from one wallet to another

This kind of transaction costs 21,000gas. If you put the price of 1gas = 20Gwei you'll pay:

21000 × 0.00000002 = 0.00042ETH (0.12$)

Why pay more? Just like Bitcoin, Ethereum has a transaction pool. This image from MyEtherWallet describes the process well:

How do transactions get approved from the transaction pool for Ethereum

You adjust your gas price dependent on how quickly you would want your transaction to go through. There is this awesome service called ETH Gas Station which allows you to pick an optimal price for your Gas.

If you put the price of 1gas = 0.1Gwei the service promises that the transaction will clear in around 22 blocks. Don't forget, that the current Ethereum Block time is around 14-15 seconds meaning that with the smallest (0.1gwei) fee you transaction should clear in just under 5 minutes!

I don't really get the whole point of paying 50Gwei per transaction. If you look at the mining pool you'll see that there are tons of people doing that. Additionally, ETH Gas Station has a small table at the bottom right with some useful information on the past 1500 blocks. At the time of writing, the maximum gas someone spent on the transaction was 21000 (21000 x 0.000000996ETH = $17.85). You can check the transaction here.

For the record, the maximum someone has ever paid for one transaction was in 2016 when they paid 761ETH. Ether was much cheaper back then, but still, $6000.

Can I not pay?

Fair question, to be honest. Weirdly enough, the answer is "yes" (well, almost).

The thing is, Ethereum's transaction pool is not huge, but it'll grow in the future. Let's look at the last blocks:

Ethereum Blocks are not necessarily full

On the Ethereum network, the maximum block size is measured not in bytes like on Bitcoin's network, but in Gas. Currently, one block holds around 8,000,459Gas which means blocks are not always full.

  • Look at the column in red on the left-hand side. It shows a number of transactions in one block.
  • On the right-hand side, you can see an exclamation point next to the block which was only full up to 3%.

The transaction queue is super small right now, so I did a small experiment. I tried to do a transaction where 1gas = 1wei and it went through!

Even transactions with very low fees can currently go through on the Ethereum network

If the price of Gas is 1Wei, it won't matter how much gas your transaction needs (just as a reminder it is 21,000 for a simple transaction) your fee will still be extremely extremely low.

By the way, the Gas price is 0wei won't work.

How do I use all of this?

Let's assume you want to make a transaction.

  • Receiver's address - this is obvious
  • Gas limit - 21,000 if you want to transfer ETH. If you are transferring to a smart-contract or to an ICO read carefully what the developers say and what amount they specify. I wouldn't be experimenting with it.
  • Gas price - you are free to set any gas price (as mentioned above, you can even set 1wei and it'll work). Just remember that the greater the price the quicker the transaction will go through.

Just to mention, the official Ethereum Wallet has a crap way of choosing your gas price. You can move the slider, but the minimum price will be 1gwei. MyEtherWallet also has 1gwei as a minimum.

How to cheat the system and pay less for gas in MyEtherWallet?

Method 1.

How to pay less for a transaction on the Ethereum network. Solution 1

Go to "Send Offline" tab. From there you can set the price in wei and not in gwei.

Method 2.

Another way to pay less fees for an Ethereum transaction

 

In Chrome, open the "inspect" window (right-click anywhere on the page -> "Inspect"), click on the gas price slider and change the minimum value from 1 to 0.000000001 (= 1 wei).

P.S. Don't mix up gas limit and gas price! You might end up like that guy who paid thousands for a simple transaction.

P.P.S.

I promised I'll do this for Ethereum? I'm a man of my word, so...

Let's look at the last 10 blocks. Let's say between 5195551 and 5195542. They had 994 transactions in them.

The reward for the miners was 30.9ETH (26,362.61USD)

Therefore, on average, each transaction cost around $26-27.

So, are cryptos still a ponzi scheme?

Related Posts

How do I store Ethereum and other altcoins? More about cryptocurrency wallets
Let's look at the wallets for altcoins and in particular for Ethereum. However, before you start reading this, you fi...
Read More
How to store Bitcoin? Creating a Bitcoin wallet
- How do I store Bitcoin? - You need to get a cryptocurrency wallet - How do I do it? - Listen up! -- It's weird, but...
Read More
What is the difference between a fork and a hard fork?
The majority of cryptos have been created as a result of a fork. The number of forks is increasing day by day, but it...
Read More