I came across published smart contracts (like this one from ConsensSys) that check whether msg.value
is strictly larger than zero in their payable functions.
After wondering whether msg.value
can be negative, I found this question whose answer says that it's not possible.
These checks, therefore, seem unnecessary to me. Is this to make sure not to fall victim to another negative transaction value bug? Do zero-value transactions pose a threat?
msg.value
cannot be negative but it can be zero or a strictly positive (I.e.,msg.value
is always>= 0
). So,msg.value > 0
checks if at least 1 Wei was sent along with the invocation (it is possible to send 0 Weis)..