Ledger Transfer operation not deducting transferFee from transfer amount?

Hi, I am trying to use LOCAL Ledger Transfer operation to transfer some ICP.
Able to get run it but somehow the transfer fee are not deducted from transfer amount but it’s being deducted from the account balance itself? is it suppose to work this way?

the flow,
i make 3 accounts = buyer (1000 ICP), seller (1000 ICP), broker (0 ICP)
buyer buy 3 items = item A (1 ICP), item B (2 ICP), item C (3 ICP)
buyer makes 3 transactions per item, 0.0001 ICP fee per tx, so 0.0003 ICP per item
so total fee would be

after all transactions are done
I expect buyer’s balance would be 1000 ICP - 1 - 2 - 3 = 994 ICP
but it’s not. the wallet balance becomes 993.9991.
image

and my cross calculation is right too
image

i remember transferring ICP from the CEX to NNS, or NNS to CEX, the transfers would deduct the fee from the ICP that is being transferred, not the wallet. Is this only happening on local ledger? couldnt be right? so do I have to deduct the fee from the amount before I transfer (i dont want the buyer to pay more than the agreed amount)? both remote ledger and local ledger should work similarly yes?

right now my implementation (js) is like below:

let me know if I should change the above to amount: { e8s: receiver.amount - transferFee.transfer_fee.e8s } so the buyer balance would be 994 after spending 6 ICP.

Thank you.

Hi @kayicp,

In the ICP ledger it is the source of the transfer that pays the transfer fee. So in your case it would be the buyer’s account that is charged the fee. You can checkout the specification of the “transfer” method in the ICP ledger spec.
Does this help?

1 Like

hi @bogwar
yea that is helpful

i shouldve read the spec first. silly me.

1 Like