August 2019
Intermediate to advanced
486 pages
13h 52m
English
The bytes4 method signature code is used to identify that the onERC721Received() function is supported by the contract. This function is present in IERC721Receiver, which is used to receive the token callback call on the contract. We will discuss the ERC721Receiver contract in the next section in this chapter:
0x150b7a02 == bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
The bytes4 value for the variable is calculated as shown in the preceding code. The signature of the onERC721Received() function is first passed in the keccak256() built-in Solidity function. The output hash of the function is further passed to the bytes4() built-in Solidity function that ...