Discover the crypto universe in depth

How to calculate the cost of an Ethereum / ERC20 transaction in dollars

Some basics to know before calculating the cost of an ethereum transaction

Ethereum, like Bitcoin, is an ecosystem of its own that does not depend on the American
dollar. It is important to understand that we first calculate the cost in Ether (the currency of the Ethereum network) in order to calculate the final value in dollar.

The purpose of this tutorial is to help you understand how to calculate by yourself the cost of an ETH transaction. The fee depends on Ethereum price in dollars at that time as well as the supply and demand on the Ethereum network.

A transaction in ETH does not have the same price as one of an ERC20 token or the execution of a smart contract such as Uniswap (UNI), Sushiswap (SUSHI) or Curve (CRV).

Useful tools that estimate the costs for you

These tools allow you to visualize the costs but also the congestion of the Ethereum
network. It is practical to know if you are going to pay expensive fees for your SWAP uniswap for example because the prices are dynamic !

TXStreet – A tool to visualize pending transactions as well as the value of prioritized ones on Ethereum, Bitcoin, Bitcoin Cash and Monero.

Fees.Watch – A simple tool to visualize Ethereum and Bitcoin transaction fees.

Etherscan Gas Tracker – Quickly see an estimate of fees on ETH, ERC20 Token and Uniswap in addition to a complete history of all the transactions in real time on a
blockchain explorer Ethereum.

GAS Now – Monitor the gas cost for the most used decentralized applications (dAPPS).

How to calculate the transaction fees on Ethereum

Calculation for a simple transaction in Ether (ETH)

21000 is the standard GAS limit for regular ETH transactions. Reference on page 25 of the Ethereum YellowPaper.

To obtain the price of an ETH transaction in dollars we first calculate the cost in cryptocurrency. To do this, we need to multiply the number of GWEI that we will set, by the required number of GAS to execute it which is 21000 units of gas.

For example, if I want my transaction to be prioritized I can see with the TxStreet or GasNow
tools that it should be priced at approximately 52 Gwei. This price is set in real time by users worldwide on the Ethereum network.

Example for TxStreet : The prioritized bus at the top right represents the next Block on the
Ethereum blockchain. In this exemple, you would have to pay 52 units of Gwei to get to the next Block.

TxStreet Ethereum gwei calculator

Example for GASNow : the estimated cost by GASNOW to see your transaction get
prioritized in the next block is 53 units of Gwei.

Gasnow ethereum cost of a transaction

These tools search for information in the Ethereum blockchain, it is public information, I will not explain to you in this tutorial how to do it yourself, to avoid giving us the headache.

What is the gwei ?

It is a measurement unit representing 0.000000001 or 10^-9 Ether and therefore 1
000 000 000 gwei = 1 Ether.

Table with the value of Gwei

Let’s move on to the calculation

In order to calculate the price of a transaction in ETH, you simply multiply the number of
gwei by the number of GAS, remember that it is 21000 of GAS for ETH.

If Gwei = 52 and GAS = 21000 then 52*21000 = 1092000 Gwei.

1092000 Gwei = 0.001092 Ether.

The price is therefore 0.001092 Ether ! You can use an online Gwei to ETH
to check it yourself.

Now we only have to multiply the transaction price in ETH by its current price : it is May 4, 2021 at 14:32 when I write this article.

Ethereum current price is : $3,439 USD.

If 1 Ether = $3439 and my cost is 0.001092 Ether then 3349*0.001092 = $3.755388 which is rounded to ~$3.75. I will have to pay ~$3.75 to perform my transaction toward an Ethereum address.

Calculation for an ERC20 token transaction

A transaction of an ERC20 token has a dynamic asking price. Unfortunately it depends on certain parameters such as : does the recipient already own this token or not. Since all the addresses on the Ethereum network are ETHEREUM addresses, you can receive any type of ERC20 token on this address.

We will remain on something simple and unfortunately approximative for this calculation,
but it helps to have a clearer mind.

From what I have seen on Etherscan Gas tracker and GasNow the ERC transactions are
priced between 30000 and more than 80000 of GAS with an average of 65000 of GAS.

We then have to repeat the calculation by changing the GAS value, we take as an example
an average of 65000.

If Gwei = 52 and GAS = 65000 then 52*65000 = 3380000 Gwei which is 0.0338 Ether.

If 1 Ether = $3439 and my cost is 0.00338 Ether then 3439*0.00338 = ~$11.62

Real time example of ERC20 transfer costs estimated by GASNOW

Estimated cost of transactions depending on Gas in dollars

Calculation for a Uniswap transaction

Same logic as for the ERC20 transactions but even more complex. The GAS fee of Uniswap transactions depends on numerous parameters for example : what type of action you execute on Uniswap.

Examples of actions on Uniswap and their estimated gas prices by GASNOW.

Uniswap transactions fees by Gasnow

We could say here that a UNISWAP transaction costs on average between 100000 and 200000 units of gas, we can then reproduce the same calculation.
But I will make it short :

If Gwei = 52 and GAS = 100000 then 52*100000 = 5200000 Gwei which is 0.0052 Ether.

If 1 Ether = $3439 and my cost is 0.052 Ether then 3439*0.0052 = ~$17.88.

In this, I calculate the price for a simple swap in the best case, you understood the idea. 🙂

  1. Did you write the article yourself or you hired someone
    to do it? I was wondering because I am a site
    owner too and struggle with writing new content all the time.
    Someone told me to use AI to do create articles which I am
    kinda considering because the output is almost written by human. Here is the sample content they sent me –

    Let me know if you think I should go ahead and use AI.

  2. Cool. I spent a long time looking for relevant content and found that your article gave me new ideas, which is very helpful for my research. I think my thesis can be completed more smoothly. Thank you.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Related Posts