13

I'm in the process of learning blockchain technology for a client of mine. I understand the concept of "gas" in computational costs. We are looking at creating a crypto-currency as an alternative to using a traditional payment platform for a closed loop solution. I want to get a feel for the "transaction cost" associated with a simple payment transaction using the ethereum network. I find the calculation method not totally clear. Can anyone help?

  • is the cost of a simple transaction the same 21,000 for sending any number of ethers? the same for sending 1 ether as for sending 500 ether? – brosen Jul 22 '17 at 22:30
6

The calculation is gas*gascost, so a simple transaction will cost 21,000 gas * 20 GWei/gas = .00042 ETH

4

Simple transaction that transfers value but have no additional data and not triggers any EVM code (the recipient is not a smart contract) consumes exactly 21000 units of gas. You just need to know the gas price to calculate the cost of the transaction.

The default gas price was 20 Gwei (20 * 10-9 ETH), but it is recommended to use lower value now. Check out ETH Gas Station service for up-to-date statistics about gas price.

You can also optimize costs by sending multiple payments in a single transaction, using a simple smart contract. Not going into the details, a single payment within such transaction will cost you ~10000 units of gas.

  • How would you send multiple payments in a single transaction, using simple transactions. I know this is easily done from a smart contract, but have not seen any code for combined simple transactions. – Bokky WeAreAllAssange PooBah Jun 10 '16 at 8:29
  • 1
    @BokkyPooBah, you have to use a contract for this, there is not other option. – Paweł Bylica Jun 8 '17 at 10:13
  • How can the price of sending via a contract be constant (10000 units)? Each send instruction will consume some gas so it should go linearly with the number of sends? Care to elaborate? – Jus12 Oct 24 '17 at 16:25
1

I have created a private Ethereum testnet and initiated a transaction of 5 ether from one account to another. The balance in both the accounts is 20 Ether before the transaction. After the transaction: enter image description here

So, the transaction cost is 0.0004575186 Ether which is approximately 0.00663 USD as of today's exchange rates.

More information about prices can be found at “Appendix G. Fee Schedule” of the Ethereum yellow paper.

1

The transaction fee is determined by (gasConsumed * gasPrice). For a simple transaction the amount of gasConsumed is always 21,000 and you can set the gas limit to 21,000 to abort the transaction if a node tries to exceed the expected 21,000 gas.

Right now the suggested gasPrice by MyEtherWallet.com is 21 Gwei, which is basically the "market price" of gas. So you are looking at (21,000 * 21) = 441,000 Gwei to send any amount of Ether today. That's one heck of a deal if you want to send 1 Ether (1,000,000,000 Gwei) which is valued at about $330 dollars right now!

To send 1 Ether you are paying a mere (441,000/1,000,000,000) or .0441% in transaction fees! The great thing about this is if you send 2 Ether the (gasConsumed * gasPrice) remains the same and your transaction cost can be cut in half (441,000/2,000,000,000) .02205%, because it's still just one transaction.

Personally that's an absolutely ridiculous value and I wrote some c# code to pay all the hard working miners 1.5% transaction fees. This way I don't have to care about what I believe others are paying at any given time and what the value of Ether is at any given time.

You're probably better off getting the average if you are a normal user, but with an air-gapped computer your only insecurity is misunderstanding the value of what you hold, so I'm planning on dealing with any possibilities with locally signed transactions at a fixed percentage rate of the wealth I'm transferring.

    decimal gasLimit = 30000;
    decimal etherToSend = .4m;
    decimal desiredFeePercentage = .015;

    decimal 1.5GetGasPriceInWeiForTransactionFeePercentage(gasLimit, desiredFeePercentage, etherToSend); // 200000000000 wei gasPrice for a transaction costing a max of 30,000 gas

    public decimal GetGasPriceInWeiForTransactionFeePercentage(
        decimal gasLimit,
        decimal desiredTransactionFeeAsPercent,
        decimal amountOfEtherToSend)
    {
        decimal transactionFeesInEther = amountOfEtherToSend * desiredTransactionFeeAsPercent;
        decimal transactionCostInWei = transactionFeesInEther * AMOUNT_OF_WEI_IN_ETHER;
        decimal requiredGasPriceInWei = transactionCostInWei / gasLimit;
        return requiredGasPriceInWei;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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