Help with SafeMath subtraction

can you please help me out in the following snippet, I want to take 3 fractions of 10% each from the transaction for burning, transaction fee and for charity but when I’m deploying the code using truffle and ganache and transferring the tokens it’s only taking the first 10% call only.

Because in your code you are doing
value.sub(tokensForFee)
twice.

When you do .sub, the value of that is not changing. You should instead change value to
tokensToTransfer.sub(tokensForFee);
in your second and 3rd value.sub lines of code.

Does that make sense? Your value isn’t changing when doing .sub what’s changing is what you assign it to.

2 Likes