What is '.selector'

I was going through ERC721.sol contract and I saw this code at line 402

"IERC721Receiver.onERC721Received.selector"

What is '.selector' in this line? I understand what rest of the code means. I can't find anything on this '.selector' on the internet.

If you can then please help me out.

A function selector is the 4 first bytes of its name and its args hashed with keccak256, for example, the hash of the ERC20 balanceOf function is bytes4(keccak256(abi.encodePacked"balanceOf(address)")) which is 0x70a08231

you mean the balanceOf fucntion and its args, Right?

Oops, of course. Edited :slight_smile:

1 Like

Thanks for helping out :smiley: