Question about Non-zero address check for from and to address in different tokens.
🧐 Motivation We all know that the ERC20 721 777 1155 contracts are describing and recording burn operation through the event to=0x0.
And to prevent incomplete implementations by developers that would lead to some transfers also having burn functionality, leading to the risk of misleading off-chain facilities and balance supply (if it exists). openzeppelin team has restricted to and from not to be 0 addresses, which all makes sense.
But I'm not quite sure why from is also checked in this process, because as long as the 0x0 to address is checked. 0x0 from address is naturally required in the balance check.
And I see that ERC20 ERC721 ERC1155 and ERC777 do not use the same standard Non-0x0 check for to and from address, some will ensure that both from and to are not 0 addresses, while some will not(ERC1155). Some will check in the bottom transfer method, while others will not(ERC777).
📝 Details Therefore, I think there are the following optimization possibilities
-
Should ERC20, ERC721, ERC1155 and ERC77 be unified in the to and from checks, and if the check for from not being 0 is unnecessary, should all of them be removed? if the check for from not being 0 is necessary, should ERC1155‘s None-0x0 from-address check be added?
-
Should the check for from and to not be 0 be done in the bottom _move() method in ERC777 to better regulate the development of library users and provide higher security.
What do you mean by "bottom" methods?
some will not(ERC1155)
We noticed this recently and plan to add the checks we're missing for consistency.
One issue we have is that we want to check both from and to in the internal functions to see that they are not 0, because users can call the internal functions directly. This means that in the external function, even if we know that from = msg.sender is not 0, because we call the internal functions we will perform the check anyway.
We would appreciate benchmarks to understand if this is something worth reviewing. How much gas is saved if the checks are removed?