Hi again @gaio,
I’ve just noticed that your questions and discussion with @thecil for this assignment are related to your other questions in the Payable Functions discussion topic, which I’ve answered for you there. Hopefully, you can now see the key difference between…
- Transfers of ether/wei value between the Bank contract address and external (wallet) addresses; and
- “Internal accounting adjustments” to the separate Bank account holder balances within the Bank contract (recorded in the mapping), which do not involve any actual movement of ether/wei between Ethereum addresses, but instead record the changes in the entitlement each Bank account holder has to withdraw ether from the Bank contract.
Once you’ve understood the key difference I’ve described above, you should be able to see that the transfer function is different to the deposit and withdraw functions, in that it doesn’t involve any ether/wei entering or leaving the Bank contract. It handles internal transfers of funds between existing Bank account holders. So, the net effect to the contract balance is zero. However, the contract still needs to adjust the amount each of the parties involved in the internal transfer is entitled to withdraw from the contract (their share of the total pooled funds) i.e. increase the receiver’s entitlement (balance) by the same amount the sender’s entitlement is reduced, with the code…
balance[from] -= amount;
balance[to] += amount;
Just let me know if you still have any uncertainties or questions about any of these points