-
Yes, otherwise we would just have a payable function in the root contract and send ether to that function.
-
Yes, that is correct. You can do that. But it might not make sense from a design perspective. The contract might be an external one, that you haven’t built. So you might not want to inherit from it necessarily.
3 and 4. Not really, I think you are missing one thing. The deposit function doesn’t only need the information about how much was transferred, it needs the actual ether. It needs to receive the cryptocurrency. It’s not enough just increasing the balance variable, that is only created to help us see the balance. The contract needs to get the currency, the ether, and that can only be done with the value function. So you can’t send it as a parameter, because it’s not like an integer, it’s actual money. If we had it as a paramter, I could input whatever I want regardless of how much money I have in my account. The value function actually sends money, cryptocurrency.
-
I’m not 100% sure of what you are asking. But we need the payable modifier if the function in question is going to be receiving cryptocurrency. It doesn’t matter what that function then do with the currency. If it is receiving currency, then we need the payable modifier. Otherwise the function cannot receive it.
-
msg.value is related to the transaction itself. So here we are talking about two different transactions. One between the user and the kennel contract and one between the kennel contract and the bank contract. So each of those transactions will have it’s own msg.value. They are not connected in any way. You could for example choose to only send 50% of the funds received in the kennel contract to the bank contract. So the msg.value does not have to be the same.