About transaction fees in NEM NIS API documentation

7.10 Transaction fees

In this document(2018/01/28 now):

Fees for transferring a mosaic to another account:
mosaics with divisibility of 0 and a maximum supply of 10,000 are called small business mosaics.
0.05 XEM fee for any transfer of a small business mosaic.
For each mosaic that is transferred the fee is calculated the following way: given a mosaic with initial supply s, divisibility d and quantity q, the XEM equivalent is (round to the next smaller integer)
xemEquivalent = (8,999,999,999 * q) / (s * 10^d)
To take into account the total quantities for different mosaics, an adjustment term is calculated.
For a mosaic called m calculate
maxMosaicQuantity = 9,000,000,000,000,000
totalMosaicQuantity = mosaic m supply * 10 ^ (mosaic m divisibility)
supplyRelatedAdjustment = floor(0.8 * ln(maxMosaicQuantity / totalMosaicQuantity)
Then the unweighted fee is calculated as
unweightedFee = max(1L, xemFee - supplyRelatedAdjustment)
Finally, the weighted fee can be calculated:
fee = unweightedFee * feeUnit
Example:
Suppose you have a mosaic with 9,000,000 supply and divisibility of 3.
totalMosaicQuantity = 9,000,000 * 1,000 = 9,000,000,000
supplyRelatedAdjustment = floor(0.8 * ln(9,000,000,000,000,000 / 9,000,000,000)) = floor(11.052) = 11
transferring 150 such mosaics (i.e. a quantity of 150,000 smallest units) has
xemEquivalent = (8,999,999,999 * 150,000) / (9,000,000 * 10^3) = 149,999
xemFee = 14 XEM
So the transaction will have the following unweighted fee:
unweightedFee = 14 XEM - 11 XEM = 3 XEM
Weighted with the current fee unit of 0.05:
fee = 3 XEM * 0.05 = 0.15 XEM

I think there is no description how to calculate "xemFee."
What is this?
I think NIS should serve an API which calculates transaction fees.
Calculating transaction fees is very very complicated. :sob:

If you develop application maybe you should use for example wrapper like nem-sdk https://docs.nem.io/en/nem-sdk

I know, but I want to develop applications with C#.
A library called CSharp2Nem doesn’t support .NET Core.

So I want to implement the inner process.

Not really. Rules are pretty simple.

Pls take a look at function estimateTransactionFee in my PHP library.
You can make the same function in C#.

1 Like

Thank you very much! :blush:

Hello to all.

Can anyone explain how calculate xemFee from xemEquivalent? Where is the formula in documentation?

in docs I see only this

xemEquivalent = (8,999,999,999 * 150,000) / (9,000,000 * 10^3) = 149,999
xemFee = 14 XEM

thanks