Some functions from ERC-721 interface contain payable
modifiers.
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
I was wondering why it is payable
and found from EIP-721 that explains why.
Solidity issue #3412: The above interfaces include explicit mutability guarantees for each function. Mutability guarantees are, in order weak to strong: payable, implicit nonpayable, view, and pure. Your implementation MUST meet the mutability guarantee in this interface and you MAY meet a stronger guarantee. For example, a payable function in this interface may be implemented as nonpayble (no state mutability specified) in your contract. We expect a later Solidity release will allow your stricter contract to inherit from this interface, but a workaround for version 0.4.20 is that you can edit this interface to add stricter mutability before inheriting from your contract.
Does this mean that when a function in the interface includes payable
and when it is implemented, it can be changed to anything? such as public
, view
, pure
? or did it mean that it can only be changed to nonpayable which is nothing
? I don't get why it is not
function transferFrom(address _from, address _to, uint256 _tokenId) external;
in the first place. Also the definition Mutability guarantees
is hard to understand. Can someone explain this in a simpler way please?
Lastly (since I think it is related to the subject), why do I need to change external
to public
in order to avoid compile error?
function transferFrom(address _from, address _to, uint256 _tokenId) public { }