August 2019
Intermediate to advanced
486 pages
13h 52m
English
As discussed in the previous section, where we looked into the ERC165 interface and implementation, the API requires a four-byte method signature, which is supported by the contracts. In the ERC721 implementation, the _INTERFACE_ID_ERC721 constant state variable is assigned a hardcoded value, 0x80ac58cd, which is generated by doing an Exclusive OR (XOR) operation of each function signature present in the IERC721 interface. In Solidity, the ^ (caret) operator is used to perform bitwise XOR operations. The constant value generation is shown in the following code:
0x80ac58cd == bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint256)')) ^ bytes4(keccak256('approve(address,uint256)')) ...