Hello @RenanSouza2
The fallback alone would indeed be enough. Unlike what @barakman says, faillback is not limited to msg.value == 0
(if its marked payable). Both function can support value.
The difference between receive
and fallback
is in the msg.data
. If the calldata is empty and if there is a receive function, it fill be used. Otherwize, fallback is used. This means that regardless of the value, fallback will be called if there is some data. fallback is also the one that is called if there is no data, but receive is not defined.
So why do we have a receive
function that is not really needed? To silent solidity warnings that sometimes happen when you have a fallback function but no receive function.
Note that I'm not able to reproduce this warning in remix, so we may change that in the code.