Gas, Gas Price and Gas Limit

What is Gas?

By definition, gas is a unit that measures the amount of computational effort that it will take to execute certain operations on the Ethereum blockchain. The operations include sending tokens, deploying a smart contract, interacting with a contract, sending some ETH, launching an ICO, or anything else on the blockchain. Gas is needed to power the Ethereum Ecosystem, just like fuel is needed to power a car.

What is Gas Price?

As I have mentioned earlier, we need to use gas for every operation made on ethereum, regardless of whether your transaction succeeds or fails. Gas does not come free, we need to pay for it, just like paying for the gasoline in order to drive our cars. How much transaction fee we need to pay depends on the gas price and the gas limit.

Gas price is the amount of Ether you need to pay per unit of gas. It is measured in Gwei (1Gwei=0.0000000001 ETH).  Its value is determined by the miners, who can refuse to process the transaction with less than a certain gas price. The transaction fee is paid to the successful miner as a form of incentive that motivates the miners to maintain the nodes. Therefore, they have the controlling power over the gas price. We must have enough ether in our wallet to pay for the gas fees.

The transaction fee is calculated using the following formula

Transaction fee= Gas unit used x Gas price

For example, for a certain transaction,

gas unit used=103631

Gas price= 1Gwei or 0.000000001 Eth

So transaction fee= 103631×0.000000001 Eth=0.000103631 Eth  

You can see the actual output in a smart contract deployment on Etherescan, as shown in the figure below:

In addition, you can “bribe” the miners to do your work first by paying more gas fees. In this way, you can jump to the front of the queue so that your transaction can be processed first.  Even if the transaction fails, you still need to pay for the transaction fee because the miners must validate and execute your transaction.

Gas Limit

The Gas Limit is an estimation of the total amount of work to perform a transaction. It is not easy to compute the gas limit. Fortunately, there are many apps that set the limit for us. Typically, 21,000 Gas will satisfy most transactions. However, for more complex transactions such as sending ETH to an ICO smart contract, the gas limit will be much higher. The reason is such a transaction requires much more computational power.

If you set the limit is too low, your transaction may take too long to process and even fail. As a result, you will lose ETH for nothing. On the other hand, if your transaction was completed before reaching the gas limit, you get back the balance ETH. The Gas Limit protects you from spending unlimited ETH, just like what banks set your credit card limit so that you will not overspend.

What is Ethereum?

According to the Ethereum Foundation, 

Ethereum is a decentralized platform that runs smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference.

These apps run on a custom built blockchain, an enormously powerful shared global infrastructure that can move value around and represent the ownership of property.

Definition of Ethereum

Based on the above descriptions, Ethereum is an open-source blockchain-based decentralized platform featuring smart contracts.  Indeed, Ethereum is a programmable blockchain that enables developers to build and deploy decentralized applications. Rather than providing users with a set of predefined applications like bitcoin, Ethereum allows users to create any kind of applications they wish. In this way, it serves as a platform for many different types of decentralized blockchain applications, including but not limited to cryptocurrencies.

Ethereum Virtual Machine

At the core of the Ethereum platform is the Ethereum Virtual Machine (“EVM”), which possesses its own programming language, known as the ‘EVM bytecode’.  It is the runtime environment that executes all of the smart contracts on the Ethereum network.

The Smart Contract code is written in high-level programming languages such as Solidity. The code is compiled to the EVM bytecode so that the Ethereum Virtual Machine can understand what has been written.

Decentralized Applications(dapps)

The Ethereum Virtual Machine makes the process of creating decentralized applications much easier than ever before. Instead of having to build an entire blockchain for each new application, the EVM enables users to develop decentralized applications all on one platform.

Cryptokitties  is one of the most well known decentralized application (dapp) among many dapps developed so far. You can check out lots of interesting dapps at https://www.dapp.com/.  I have also developed a prototype dapp that I named it Kittychain Shop. In this virtual pet shop, the user can adopt a kitty, as shown in the figure below.

The Ethereum Architecture

Ethereum runs on a distributed public blockchain network. Each and every node connected to the Ethereum network helps to maintain and update the blockchain database. The nodes of the network run the EVM and execute the instructions according to the smart contracts.   Ethereum node runs the EVM in order to maintain consensus across the blockchain.

Ethereum peers achieve consensus via the proof of work algorithm, which is similar to bitcoin. However, they are planning to shift to the proof of stake algorithm in near future to improve scalability. The consensus gives Ethereum a high level of fault tolerance, ensures zero downtime, and makes data stored on the blockchain immutable and secure.

Like Bitcoin, Ethereum allows individuals to exchange cash without involving any middlemen like financial institutions and others. However, Ethereum is more than just cryptocurrency. Beyond financial applications, we can create decentralized applications where trust, security, and permanence are considered important. Among the potential applications are asset registries, voting, governance, Internet of things, supply chain management and more. 


Similar to Bitcoin, we can also carry out mining activity in Ethereum. However, In the Ethereum blockchain, instead of mining for bitcoin, miners work to earn Ether, the default currency of Ethereum. Beyond a tradeable cryptocurrency, Ether is also used by application developers to pay for transaction fees and services on the Ethereum network. For example, the user needs to pay for acquiring a crypto asset in a dapps marketplace using Ether.