Closed ph101pp closed 1 year ago
seems it will works well too, and save more gas? if u have logic in the _beforeTokenTransfer
It seems the downside of using _beforeTokenTransfer
instead is that _beforeTokenTransfer
is also called when minting, thus unnecessarily increasing gas fees on mints.
_beforeTokenTransfer
is not part of EIP-721, it's only on some implementations of it
On top of that, in most of those implementations, if you are already in _beforeTokenTransfer
, it means you already used quite some more gas to come there than if applied on a modifier
It seems the downside of using
_beforeTokenTransfer
instead is that_beforeTokenTransfer
is also called when minting, thus unnecessarily increasing gas fees on mints.
Oh, yes, watse when minting, tkx for ur explain
As mentioned in this thread, _beforeTokenTransfer
is not part of the EIP-721 specification, so the examples do not use them.
Developers are free to implement registry logic however they'd like, and can ensure compliance with the included validation tests.
@operatorfilterer EIP-721 conformity is irrelevant because your example includes an import for the OpenZeppelin ERC721 which DOES implement _beforeTokenTransfer
.
import {ERC721} from "openzeppelin-contracts/token/ERC721/ERC721.sol";
As such the real issue is that _beforeTokenTransfer
is called on Mint.
The example implementations for
ERC721
andERC1155
are restrictingsafeTransferFrom
andsafeBatchTransferFrom
like this:is there a reason to not restrict via
_beforeTokenTransfer
?