Skip to Content
Mastering Blockchain Programming with Solidity
book

Mastering Blockchain Programming with Solidity

by Jitendra Chittoda
August 2019
Intermediate to advanced
486 pages
13h 52m
English
Packt Publishing
Content preview from Mastering Blockchain Programming with Solidity

The ERC165 interface code for the ERC721, _INTERFACE_ID_ERC721

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)')) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood
Complete Cryptocurrency and Blockchain Course | Learn Solidity

Complete Cryptocurrency and Blockchain Course | Learn Solidity

Ravinder Deol, Codestars By Rob Percival, Thomas Wiesner

Publisher Resources

ISBN: 9781839218262Supplemental Content