-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making sense of total fees #55
Comments
Transaction has multiple phases (storage, compute, action). |
@Trinketer22 thanks for the reply. Then could you break the fees in the first transaction down for me?: |
Well, the totalFees should be compute+action_fees+storage+external import(in case of transaction triggered by external message). In order to get to the bottom of what is happening, you can print the blockchainLogs of this transaction. In case of transactions, triggered by external message, the fees are deducted from contract balance, so (valueIn - valueOut) is not valid logic here. There is also a gotcha in the fact that totalFees represent the amount of fees collected at this point. What printTransaction displays as outForwardFee is in fact the totalForwardFee, and that's likely a bug. |
@Trinketer22 wow thank you so much for the explanation. Now I kinda get the hang of it. Appreciate the help. |
@9oelM, you can also go through this attempt to explain fees in detail, if you haven't already. Bare in mind that there is slight naming confusion when reading about fwd_fees. fwd_in/fwd_out vs fwd_mine/fwd_remain. |
I have a question about
tx.totalFees.coins
. I genuinely cannot understand what this value is supposed to represent. In my case, I want to write a test on how much gas is spent for a series of transactions.I've provided an example at https://github.com/9oelM/ton-sandbox-totalfees-bug.git. The test setup is simple:
In code, it is as simple as:
printTransactionFees(increaseResult.transactions);
prints:But I couldn't wrap my head around these numbers. I thought totalFees is supposed to be the sum of all total fees for a tx. In other words,$valueIn - valueOut = totalFees$ . But this simply isn't the case:
valueIn = 0.05 TON
(we started with 0.05 TON) andvalueOut = 0.0496 TON
.valueIn - valueOut = 0.0004
. ButtotalFees = 0.001613
???valueIn = 0.0496 TON
andvalueOut = 0.046978 TON
.valueIn - valueOut = 0.002622
. ButtotalFees = 0.002296
???If totalFees were correctly calculated as total gas for the tx,
toNano('0.05') - allFees
would simply match the TON balance transferred to a contract, which iscontractBTONBalanceAfter - contractBTONBalanceBefore
. But this is not the case. In fact,lastTx.value - lastTx.totalFees == contractBTONBalanceAfter - contractBTONBalanceBefore != toNano('0.05') - allFees
:lastTx.value! - lastTx.totalFees!
=45904800n
contractBTONBalanceAfter - contractBTONBalanceBefore
=45904800n
toNano('0.05') - allFees
=45020139n
cc @krigga
The text was updated successfully, but these errors were encountered: