Why the internal _burn function is virtual in ERC721 but not in ERC20 and ERC1155

I was just wondering while going through the code.

In ERC20, there is clearly this message in the comments above the function.

But for 721 and 1155, there is no mention of this, and only in ERC721 the function is marked as virtual.

Would be curious to know and understand. If anything should be changed for consistency, I am happy to open a PR.

Function _burn is virtual where function _update is NOT implemented (ERC721).

Function _burn is NOT virtual where function _update is implemented (ERC20 and ERC1155).

The only "flaw" here is the comment appearing in the ERC20 code but not in the ERC1155 code:

 * NOTE: This function is not virtual, {_update} should be overridden instead
1 Like

Code in the master branch is in development. The same change will be made in ERC721 shortly.

The lack of virtual is because overrides should be done in the _update function so they are consistently applied to mints and burns as well.

1 Like