After reading through the docs and through this post, I understand the concept and need for gas, but I do not understand why each transaction can have a variable fee associated with it. It seems to be a way for the rich to get priority over the poor, or those willing to pay a premium to get their transactions confirmed before anyone else. To me, this sounds unsustainable. Is there another reason for these changeable fees?
[Ethereum] the point of variable transaction fees in Ethereum (and Bitcoin as well)
feesgas
Related Solutions
Every computation on the Ethereum network cost gas, so do value transfers like on the bitcoin blockchain.
Every computational step, or OPCODE requires a specific amount of gas (which is hardcoded). You pay for gas using ether. To determine the fee you pay you calculate:
required gas * gas price = fee
For example a simple value transfer cost 21000 gas, the current gas price is dynamically set by users and miners and is currently ~0.00000005 ether, so the value transaction would cost ~0.00105 ether or $0.001 to $0.002 USD at current prices. Current BTC transaction fees vary anywhere from $0.01 to $0.09 USD
Users can set the gas price they are willing to pay and and miners can set the minimum gas price they are willing to accept. This creates a dynamic market, which allows ethers "fee" to be dynamic and adopt to ether price swings.
I wrote the following script to calculate the results:
#!/bin/sh
# ------------------------------------------------------------------------------
# Find Daily Transactions On The Ethereum Blockchain
#
# Works on Linux and OS/X. May work on Windows with Cygwin.
#
# Usage:
# 1. Download this script to findDailyTransactions
# 2. `chmod 700 findDailyTransactions`
# 3. Run `geth console` in a window.
# 4. Then run this script `./findDailyTransactions` in a separate window.
#
# History:
# * Jan 05 2017 - Version 1.0
#
# Enjoy. (c) BokkyPooBah 2016. The MIT licence.
# ------------------------------------------------------------------------------
OUTPUTFILE=findDailyTransactions.out
TSVFILE=findDailyTransactions.tsv
TSVSUMMARY=findDailyTransactionsSummary.tsv
# geth attach << EOF
geth attach << EOF > $OUTPUTFILE
var blocksPerDay = 24 * 60 * 60 / 14;
console.log("Blocks per day: " + blocksPerDay);
// Get extra day
var blocksPerMonth = blocksPerDay * 32;
console.log("Blocks per month: " + blocksPerMonth);
var endBlock = eth.blockNumber;
var startBlock = parseInt(endBlock - blocksPerMonth);
// Testing
// startBlock = parseInt(endBlock - 10);
console.log("Start block: " + startBlock);
console.log("End block: " + endBlock);
var count = {};
var costMap = {};
console.log("Data: Day\tTime\tHash\tGasPrice\tGasUsed\tCost");
for (var i = startBlock; i <= endBlock; i++) {
var block = eth.getBlock(i, true);
if (block != null) {
block.transactions.forEach(function(t) {
var date = new Date(block.timestamp * 1000);
var day = date.toJSON().substring(0, 10);
var time = date.toJSON().substring(11, 19);
// var key = date.toJSON().substring(11, 16);
var key = day;
var tx = eth.getTransaction(t.hash);
var txR = eth.getTransactionReceipt(t.hash);
var gasUsed = txR.gasUsed;
var gasPrice = tx.gasPrice;
var cost = new BigNumber(gasUsed).mul(gasPrice).div(1e18);
if (count[key]) {
count[key]++;
} else {
count[key] = 1;
}
if (costMap[key]) {
costMap[key] = costMap[key].plus(cost);
} else {
costMap[key] = new BigNumber(cost);
}
console.log("Data: " + day + "\t" + time + "\t" + t.hash + "\t" + gasPrice + "\t" + gasUsed + "\t" + cost);
});
}
}
var keys = [];
for (var key in count) {
keys.push(key);
}
keys.sort();
console.log("Summary: Date\tTxCount\tSumCost");
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var num = count[key];
var cost = costMap[key];
console.log("Summary: " + key + " " + num + " " + cost);
}
EOF
grep "Data:" $OUTPUTFILE | sed "s/Data: //" > $TSVFILE
grep "Summary:" $OUTPUTFILE | sed "s/Summary: //" > $TSVSUMMARY
Here are the first few lines of the detailed results:
Day Time Hash GasPrice GasUsed Cost
2016-12-03 15:35:10 0x15a9b8dae315f12a6f0ee915fe98df4360d1862b86a5d5643ae782136572afde 20000000000 30416 0.00060832
2016-12-03 15:35:10 0x1aee9737476e99139d1dbac25248252c04f79e62e69f5ab6d7cf90c3d01e9bd5 20000000000 30416 0.00060832
2016-12-03 15:35:10 0x2f5bb05eab245082449fca28f1cf8179c82bb11e3d3026b782177c2db4a31621 20000000000 30416 0.00060832
2016-12-03 15:35:10 0x475591c2c02482b8c4410b9cb6e21f84311bc93a49b278baf4c9da9dd3ab9940 20000000000 30416 0.00060832
2016-12-03 15:35:10 0xefebae78a289e5e637835418b8b105cccc8add376777099fb2f446003b4760e1 20000000000 30416 0.00060832
2016-12-03 15:37:28 0xd39d3f343a84df8a155eb4e4b1907d2835445b23690b75066c3350ce2508e463 60000000000 21000 0.00126
2016-12-03 15:37:28 0x5b223cafd94bbb55e50e6f25dcda278b806e2f33a59d9b86cf8db5a1cc3037dc 55000000000 65600 0.003608
2016-12-03 15:37:28 0x952e33c725aab06d2f84cf90c3880e177e43f1d1cba3032839e2d20ee54c975d 21000000000 21000 0.000441
2016-12-03 15:37:28 0x2ec12796c790700dbbb678344f1030901f3666406e81b096dd5658f50076562f 20000000000 21000 0.00042
2016-12-03 15:37:28 0x3429d7477ba1953917b270662922e0e33b7ef99c62a8c1e8aacbde1cc781f705 20000000000 21000 0.00042
2016-12-03 15:37:28 0x4f4939bbe3b3764ca343c50d87896aba3daede24e6d0d7019bc10bcd610540fc 20000000000 37744 0.00075488
2016-12-03 15:37:28 0x653b95af57d7d5ea871d628ba42dfe74e92316519cc574108c8127c770e8cf17 20000000000 22900 0.000458
2016-12-03 15:37:28 0x758f5d0ff2e6ba7ff358f6e448c558bb44e84462817471b5f08ba9be28856f1f 20000000000 21000 0.00042
Here are the summary results. SumCost
is the sum of the transaction fees for the day. Ignore the first and last entries as these are statistics for part days:
Date TxCount SumCost
2016-12-03 13652 9.031858962045600786
2016-12-04 39643 26.2590678522622502
2016-12-05 41613 31.260227778687816479
2016-12-06 48200 34.724190362202270091
2016-12-07 41757 34.986830893400990279
2016-12-08 39587 792.488980472847617318
2016-12-09 41444 31.427944831704979055
2016-12-10 40564 29.027316459710687448
2016-12-11 39164 36.802824752362151712
2016-12-12 38741 31.236666299979217642
2016-12-13 44664 30.96445138376004775
2016-12-14 47294 34.886653378922419663
2016-12-15 46102 34.427867607164909959
2016-12-16 43953 30.59438815455709639
2016-12-17 39442 32.801700786191403698
2016-12-18 36640 27.723246559895049134
2016-12-19 45599 36.451357768973606076
2016-12-20 44241 43.901597465334609193
2016-12-21 50793 54.747365402673830874
2016-12-22 55173 38.844405597480919257
2016-12-23 44391 29.67366918963357803
2016-12-24 37757 25.81752534909212622
2016-12-25 36601 24.217901540017729787
2016-12-26 34565 23.120413010232811283
2016-12-27 42370 36.398134576455099831
2016-12-28 43386 31.575304426588826066
2016-12-29 46546 40.700293206458891043
2016-12-30 44561 44.81091076572642845
2016-12-31 41220 28.598800805711720561
2017-01-01 38730 25.262224854177027598
2017-01-02 39652 28.118341055529409329
2017-01-03 45883 40.245343098687603577
2017-01-04 50673 39.504583436605983867
2017-01-05 12948 9.243102890131226982
Here are the calculated averages:
Compare the stats above to Bitcoin at Cost per Transaction - Blockchain.info:
And Confirmed Transaction Per Day - Blockchain.info:
Excessively High Fee Transaction
Did you see the odd looking number on 2016-12-08? What happened here?
Sorting the individual transactions by cost, the following transaction showed up as costing 761.62326635721637 Ether ($7,639.08).
From 0xeda3bf566ae21fbc7bbfcb805d73181b0037036d700d57695e28f1e9bfe0d69c:
I had to double check the gasPrice in geth
:
> eth.getTransaction("0xeda3bf566ae21fbc7bbfcb805d73181b0037036d700d57695e28f1e9bfe0d69c")
{
blockHash: "0x9b92631efb5a96157d4bac9ef8b795df2d22ece167f923498d5e226578c00665",
blockNumber: 2770908,
from: "0xf0f3589042f8e74b1c060fe9aa8e320c8d907708",
gas: 21000,
gasPrice: 36267774588438875,
hash: "0xeda3bf566ae21fbc7bbfcb805d73181b0037036d700d57695e28f1e9bfe0d69c",
input: "0x",
nonce: 0,
r: "0x251c1c08d8a4a4c98bbb11563cad6f5d9b1535bde692ae7812be84dae5c71cb5",
s: "0x623dc847eee1911e4f087173075475f3e0ad3ef267c681dc1f72f6ff62aee6ac",
to: "0x2b62ecf08052e90980d41ba588593e841bee5ecf",
transactionIndex: 0,
v: "0x25",
value: 350000000000000000000
}
> eth.getTransaction("0xeda3bf566ae21fbc7bbfcb805d73181b0037036d700d57695e28f1e9bfe0d69c").gasPrice/1e18
0.03626777458843887
From the Ethereum GasPrice History - Etherscan.io, you can see the large blip on the chart:
From block #2770908, DwarfPool1 collected the mining fees:
And it seems that DwarfPool refunded the account with the excessive fees in 0x92cde2e39dfc604ede142810736a1fcadce5b925da8d957dcc4e881f34d7c513:
Best Answer
From the Yellow Paper
Also found from Vtalik:
https://blog.ethereum.org/2016/10/31/uncle-rate-transaction-fee-analysis/
In my view it provides an elegant form of price discovery during periods of high contention for finite resources. For example, if we are hovering near the block gasLimit this is a mechanism for both users and miners to prioritize transaction urgency. I'm unsure what is unsustainable about that.