A simple question on gas spent on a transaction here.

I'm experimenting with testnet transaction on a simple contract that stores a value, trying to figure out how much a client would pay. What would be exact cost of gas in ETH of this transaction?


Would it be 0.0024565 testnet Ethers, i.e. 0.0024565*336$ (price of 1 ETH when I write this) = 0.82 dollars in real network?

So the fee for 33 cents transaction would be 82 cents if it were on the production blockchain, is this so?


1 Answer 1


The transaction cost is calculated on the basis of gas and gas price. The formula is -


From the documentation -

The way the fee works is as follows. Every transaction must contain, alongside its other data, a GASPRICE and STARTGAS value. STARTGAS is the amount of "gas" that the transaction assigns itself, and GASPRICE is the fee that the transaction pays per unit of gas; thus, when a transaction is sent, the first thing that is done during evaluation is subtracting STARTGAS * GASPRICE wei plus the transaction's value from the sending account balance. GASPRICE is set by the transaction sender, but miners will likely refuse to process transactions whose GASPRICE is too low.

Take a look at this question to understand the concept of Gas.

So you may end up losing extra amount once your transaction is completed because of the transaction fee. You can decrease the GAS value to lower the transaction fee but in that case, miner may give low priority to your transation and that will delay transaction completion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.