0

Can someone explain the algorithm to compute Monero transaction fee?

I have seen somewhere it is based transaction size (or something called "weight"?), and some other vague explanation. But I would like to know more deeply how it works.

EDIT: This is basically the same question as How does the dynamic fee calculation work? but the answer to that question looks out of date. I would like to know how it works in the protocol today.

1 Answers1

2

Can someone explain the algorithm to compute Monero transaction fee?

The computation of the current dynamic fee algorithm is explained, in detail, here: https://web.getmonero.org/2017/12/11/A-note-on-fees.html.

I have seen somewhere it is based transaction size (or something called "weight"?), and some other vague explanation.

"weight" is just another term for size. However, It's not just tx weight that is used in the calculation.

But I would like to know more deeply how it works.

https://web.getmonero.org/2017/12/11/A-note-on-fees.html

jtgrassie
  • 19,111
  • 4
  • 14
  • 51
  • This was the type explanation I was looking for. That post is old, does it still correspond to the Monero code? – PyrolitePancake May 13 '19 at 08:24
  • It's not that old and it's the most recent write-up. Some parameters I think may have been tweaked but it's largely current. – jtgrassie May 13 '19 at 11:36
  • But seems wrong. Example, this transaction https://xmrchain.net/tx/b87f6fbe15e4ccf408f8995a35b7073ce0d90e06d8335b6a96ee00f0c9ceef73 fee is 0.0000331xmr, size is 1,73kB, median block is 293kB, and block reward is 2.8xmr (says xmrchain.net). But above formula says fee/kB should be (2.8/10)(300/293)0.002(60/300)4 = 0.000459xmr, so the fee should be 0.0007935xmr. That is almost 25 times more than on xmrchain.net! – PyrolitePancake May 14 '19 at 06:39
  • No, the numbers you are using in your calculation are wrong. Re-read the article. – jtgrassie May 14 '19 at 11:33
  • Can you give a hint what is wrong? Im puzzled. – PyrolitePancake May 14 '19 at 11:57
  • NewReward and BaseReward. – jtgrassie May 14 '19 at 17:56
  • Maybe I am being stupid, sorry about that. As I understand the note, in this case the BaseReward = NewReward because the blocksize is < 300kB, so there is no penalty. And the reward for the block was ~2.8XMR. That is why I have 2.8 as the value for R. – PyrolitePancake May 14 '19 at 18:43
  • And by R I am talking about the formula "Fee per kB = (R/R0) * (M0/M) * F0 * (60/300) * 4" ... is this not used when there is no penalty? – PyrolitePancake May 14 '19 at 18:48
  • But how are you calculating BaseReward? For that block it should be: BaseReward = 2 * ((S - A) * 2^-20 * 10^-12) where S is 2^64-1 and A is 16979545.930907253176e12 – jtgrassie May 14 '19 at 19:50
  • Yes. And this is 2 * (2^64- 1 - 16979545.930907253176e12) * 2^-20 * 10^-12 = ~2.8? – PyrolitePancake May 14 '19 at 20:03
  • The tx you reference has a fee per kb as 0.000019106201. And the block size is 1.8330kb. I don't know what a) the median block size is for the prev 100 blocks to that block or b) what priority level was selected for that tx. – jtgrassie May 14 '19 at 20:27
  • 1
    Hmm, looking at the source code, this article does indeed look a little out of date. Apologies. The source for the base fee per byte can be seen calculated here – jtgrassie May 14 '19 at 20:43