3

ERC-20 says transfer and transferFrom should allow 0-value transfer and fire Transfer event. What's the main benefit of allowing 0-value transfer? Is there any use case?

2

Usually you will not see a hardcoded transfer(0).

But there are use cases like transfer(b-c). If 0 value transfers were not allowed and generated an exception, developers would have to explicitly handle the case when c equals b. Allowing 0 value transfers is safe from bugs, but disallowing them can create more work for developers, and standards should be easy to use correctly.

1
  • 1
    Hard to think someone doing that without knowing in detail what he is transferring. At least knowing c >= b... – Rick Park Jan 18 '19 at 9:24
1

There's no reason to prevent it. If you want to transfer 0 tokens it is meaningless operation but it doesn't produce any harm. You will be paying the transaction fee.

For example it is allowed to transfer 0 ethers. It doesn't make much sense but you still have to pay the transaction fee. They are used to override stuck transactions with lowers fees.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.