Tokens,Gas and Gas limit in Ethereum

Arun Rajeevan
5 min readFeb 11, 2019

--

Figure states a simple Blockchain flow.

Ethereum is the network, also known as the blockchain.

The primary difference between Ethereum and any other cryptocurrency is that it’s not just a currency, it’s an environment. Here anyone can take advantage of the blockchain technology to build their own projects and DAPPS (decentralized applications) through smart contracts. This is a very important distinction because this very thing shows you the true scope of what is possible in Ethereum.

Tokens:

Think of Ethereum like the internet and all the DAPPS as websites that run in it. There is something really interesting about these DAPPS, they are all decentralized and not owned by an individual, they are owned by people. The way that happens is usually by a crowd-sale called the “ICO” (more on that later). Basically, you buy certain tokens of that DAPP in exchange of your ether.
Note:An Initial Coin Offering (ICO) is the cryptocurrency space’s rough equivalent to an IPO in the mainstream investment world. ICOs act as fundraisers of sorts; a company looking to create a new coin, app, or service launches an ICO.

These tokens are usually of 2 varieties:

  • Usage Tokens.
  • Work Tokens.

Usage Tokens: These are the tokens that act like native currency in their respective DAPPS. Golem is a pretty good example of this. If you want to use the services in Golem then you will need to pay with Golem Network Token (GNT). While these tokens have monetary value they won’t give you any particular rights or privilege within the network itself.

Work Token: These are the tokens that identify you as a sort of shareholder in the DAPP. Because of that, you have a say in the direction that that DAPP takes. A perfect example of this is the DAO tokens. If you were a DAO token holder then you had the right to vote on whether a particular DAPP could get funding from the DAO or not.

Why Do We Need Tokens?

Right now you must be wondering, if all these DAPPS are made in the Ethereum Network, then why don’t we simply use Ether to pay for every transaction within those DAPPS? Why do we need a native currency for them? The answer to that is pretty simple, even in real life, there are tons of places where we use a form of token over cash.

Examples:
Remember that time you went to the water park? Remember how they took your money and tied a band around your wrist which you used to gain access to all the rides in the park and to buy food as well? In this example the water park is the DAPP, your money is ether and the band is the token.

Okay, how about the time you bought those movie tickets for Wonder Woman and included an extra popcorn and coke in your ticket? The moment you entered the theater how did you get in the hall? You showed them the ticket. How did you buy your popcorn and coke? Again, by showing them the ticket. In this case, the cinema theater is the DAPP, your money is Ether and the ticket is the token.

By using tokens to execute certain functions in the smart contract of the DAPPS you make the process much more simple and seamless. Plus, tokens are also great for the overall value of ether as well (more on that later).

Ether and Gas:

You have to pay for the computation, regardless of whether your transaction succeeds or fails. Even if it fails, the miners must validate and execute your transaction (compute) and therefore you must pay for that computation just like you would pay for a successful transaction.

Ether (ETH) is the fuel for that network. When you send tokens, interact with a contract, send ETH, or do anything else on the blockchain, you must pay for that computation. That payment is calculated in Gas and gas is paid in ETH.

The total cost of a transaction =Gas Limit * Gas Price.

Typically, if someone just says “Gas”, they are talking about the “Gas Limit”.

Analogy:

You can think of the Gas Limit like the amount of liters/gallons/units of gas for a car. You can think of the Gas Price as the cost of that liter/gallon/unit of gas.

  • With a car, it’s $2.50 (price) per gallon (unit).
  • With Ethereum, it’s 20 GWEI (price) per gas (unit).

To fill up your “tank”, it takes…

  • 10 gallons at $2.50 = $25
  • 21000 units of gas at 20 GWEI = 0.00042 ETH.

Therefore, the total TX fee will be 0.00042 Ether.

Sending tokens will typically take ~50000 gas to ~100000 gas, so the total TX fee increases to 0.001 ETH - 0.002 ETH.

Gas Limit

It's the maximum amount of units of gas you are willing to spend on a transaction.

However, the units of gas necessary for a transaction are already defined by how much code is executed on the blockchain. If you do not want to spend as much on gas, lowering the gas limit won’t help much. You must include enough gas to cover the computational resources you use or your transaction will fail due to an Out of Gas Error.

Note: All unused gas is refunded to you at the end of a transaction. So if you go to MyEtherWallet, send 1 ETH to our donation address ( ? ), and use a gas limit of 400000 you will receive 400000–21000* back. But, if you were sending 1 ETH to a contract and your transaction to the contract fails , you will use the entire 400000 and receive nothing back.

Gas Price

If you want to spend less on a transaction, you can do so by lowering the amount you pay per unit of gas. The price you pay for each unit increases or decreases how quickly your transaction will be mined.

During normal times:

  • 40 GWEI Gas Price will almost always get you into the next block.
  • 20 GWEI will usually get you within the next few blocks.
  • 2 GWEI will usually get you within the next few minutes.

Will increasing the gas price get it mined faster? Does setting a low gas price mean it won’t ever be mined?

The transaction fees go to the miner who mines your block. When miners mine a block, they have to decide which transactions to include. They can choose to include no transactions, or they can choose to randomly select transactions. In order to encourage miners to include transactions in blocks you want to set a “Gas Price” that is high enough to make them want to include it (since it is entirely up to them).

Most miners follow a very simple strategy for inclusion. They include transactions they received sorted from highest Gas Price to lowest, then include them until either the block is full or they reach one that has a Gas Price set lower than they are willing to bother with.

You want to set the Gas Price high enough so that a miner includes your transaction in a block. If you are in a hurry, you can set the Gas Price higher, so that you jump ahead of everyone in line. If you are not in a hurry, you just need to set a number high enough so that someone eventually includes your transaction.

--

--

Responses (5)