-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing Usage of payable
#184
Comments
The design takes into account three goals:
The "handle message value" callback system is the only approach I've found that addresses all three of these points. I agree that the pattern is unusual, and even disagreeable, but not confusing. Most developers don't even seem to be aware that ERC721 allows |
While I understand the points raised, most if not all EIP-721 implementations do not use the The OpenZeppelin implementation clearly defines the functions as "non-payable" whilst the solmate implementation simply defines them as virtual (which does break the SS code style convention). The former of the two is cited as a direct influence on whether ethereum/solidity#11253 will be accepted which permits a I think that until ethereum/solidity#11253 is properly accepted into the language, the interface should define the functions as "non-payable". Code such as the following I have observed in security audits is very counter-intuitive and prone to errors: function transferFrom(address from, address to, uint256 tokenId) public payable virtual override {
require(msg.value == 0, "ERC721: transfer must have no value");
// ...
} Alternatively, given that the only "standard" solution right now is to install |
Description
The
payable
modifier appears to be enforced by the interfaces of@solidstate
'sIERC721
, however, the actualSolidStateERC721
implementation contains a dedicated hook system to prohibit non-zeromsg.value
transactions.Recommendation
The
payable
modifier should either be removed from theinterface
definition or the internal hook system should be removed (i.e._handleApproveMessageValue
) to actually take advantage of the gas optimization provided bypayable
.Rationale
Currently, the system simply imposes additional checks on itself significantly increasing the gas cost of the contract whilst retaining the same behaviour as if
payable
was never defined. A little bit more background as to whypayable
is specified in theinterface
would greatly help in judging the correct action.To note, removing
payable
is still compliant with the EIP-721 standard. For more background, consult first bullet point in: https://eips.ethereum.org/EIPS/eip-721#caveatsThe text was updated successfully, but these errors were encountered: