Why send ether to 0x0 if user accidentally sends to contract?

2018-04-16 14:54:53

I recently saw a fallback function, send ether to 0x0, if a user sends money to it accidentally. Is there a reason to send it to 0x0 and not just keep it in the contract itself?

I don't know why someone would do this. If you send ETH to the 0x0 address, that ETH is lost forever. Nobody owns this address.

The contract creator may not want to keep unexpected ETH in their contract because it could interrupt other functionality of the contract. So this could be why they didn't keep it.

But it is possible that the contract you saw was from an earlier version of Solidity, where the default fallback function we have in 0.4.21 (which automatically throws if msg.value > 0) wasn't in place. If the person didn't know what they were doing, they might have been trying to return the ETH.

  • I don't know why someone would do this. If you send ETH to the 0x0 address, that ETH is lost forever. Nobody owns this address.

    The contract creator may not want to keep unexpected ETH in their contract because it could interrupt other functionality of the contract. So this could be why they didn't keep it.

    But it is possible that the contract you saw was from an earlier version of Solidity, where the default fallback function we have in 0.4.21 (which automatically throws if msg.value > 0) wasn't in place. If the person didn't know what they were doing, they might have been trying to return the ETH.

    2018-04-16 16:06:24