Calculate Transaction Gas Fee

1.2k Views Asked by At

I am trying to find out the fee for a normal transaction on the Ethereum network !!

//Get Network Gas Price For singl unit
var GasPrice= await web3.Eth.GasPrice.SendRequestAsync();

//Assuming the number of major units is 21000
var TransactionLimit = new HexBigInteger(21000).Value;

var TransactionFee = GasPrice.Value * TransactionLimit;
  • Are the steps taken correct?
  • And what is the refund value in this case, is it Wei or Gwei or what!!
1

There are 1 best solutions below

1
On

Yes, your calculation is correct, but I recommend reading Ethereum: Gas and Fees, which explains the cases before and after the Ethereum London upgrade.

Note that in your case, TransactionLimit is not how many gas units you'll actually use, but the upper limit after which your transaction won't be executed anymore. The difference between the actually burnt gas units and the limit is refunded.

All the values are in Wei.