On April 11, the Original Crypto Coin team held our first #CryptoEdOCC live online educational event about gas. This article includes the content that was shared during the free event.
The role gas plays on the Ethereum blockchain an be a major source of confusion for crypto beginners. Personally, I had more than a couple failed transactions where I was like “WHHHYYYY is this happening!?!” before I started to get gas figured out.
Gas, which is paid for in Ether (ETH), is the fuel for the Ethereum blockchain. When you send ETH, tokens, or interact with a contract, you have to pay for the computations performed by miners to execute that transaction. That payment is calculated in terms of “gas”. This entire fee is received by miners. Regardless of whether your transaction succeeds or fails, you need to pay the miners for the work they did to attempt to execute your transaction. Because of this, you pay gas even when a transaction fails.
To put this in terms relative to the original OCC token airdrop, all gas fees paid to receive your OCC tokens were sent to miners. The OCC team received no ETH or benefits from distributing the tokens.
You can see your transaction fee (amount of gas * gas price) in ETH and USD when you search for your transaction on Etherscan.io. Etherscan can also be a really useful tool for tracking transactions and figuring out problems too. Other coins have their own block explorers that have similar functions. If you’re new to block explorers, we’ve got some helpful info here: https://originalcryptocoin.com/knowledgebase/how-to-track-transactions-using-blockchain-explorers/.
The gas price sets the amount that you will pay for a unit of gas. Similar to the price for a gallon of gas at an actual gas/petrol station. This amount, measured in gwei, impacts how fast your transaction is processed. You can use ETH Gas Station to check on current gas prices, including the “safe low”. ETH gas station also has a transaction fee calculator you can play with to see how different gas settings impact your transaction fee.
The gas limit sets the max total amount of gas you are willing to use up to process a transaction. This entire amount (gas price * gas limit) is sent with the transaction, but the amount that is unused goes back in your wallet. The amount of gas needed to transfer ETH is 21,000. Tokens and other interaction with smart contracts use more gas (usually between 50,000 – 100,000).
If you imagine going to a gas station and paying cash, if you went inside to prepay and told them to put $20 on pump 5, that $20 is your gas limit. The clerk will set the pump so you can’t get more. If your tank really needs $30 worth of gas for a fill up, $20 won’t be enough. Thankfully cars still drive with partially filled tanks. Crypto transactions fail instead, meaning you use up all of your gas without completing the transaction.
When your transaction fails because the gas limit is too low, it looks like this on Etherscan.
One way crypto differs from the actual gas station is that you can choose your gas price. That screenshot of ETH Gas Station above shows gas prices on a slow day in crypto. They can get much higher, like we saw back in December/January! Changing your gas price (gwei) to a lower appropriate amount will save you money on transaction fees. However, if you set a gas price too low, your transaction may not be processed for a very long time. If you’ve sent multiple transactions from the same wallet, you could cause yourself a big backlog too! This is because the “nonce” indicates the order you sent your transactions, and lowest nonce must clear first.
If you get a message that says you don’t have enough ETH in your wallet when you attempt to perform a transaction, it usually means you don’t have enough ETH to cover your maximum transaction fee (plus the amount of ETH you want to send if it’s an Ether transaction). No gas is used in this case, and you don’t lose any ETH. So if you’re sending ETH to another address, you need to have that amount of ETH plus your transaction fees. This can get especially tricky on decentralized exchanges where you put some ETH in their contract, and keep some in your wallet.