ERC165 Explained in Detail
ERC165 defines a standard way to ask a contract whether it supports an interface. The contract answers through supportsInterface(bytes4 interfaceId).
Interface IDs are built from function selectors. ERC721, ERC1155, receiver hooks, registries, and modular contracts often depend on these answers.
Smart contract example
function supportsInterface(bytes4 interfaceId) public view returns (bool);
The ERC165 interface ID itself is 0x01ffc9a7.
ERC165 in Auditing
ERC165 is not access control, but integrations often trust it before calling a contract. Wrong interface answers can break token transfers, registry checks, receiver hooks, and marketplace integrations.
Auditors verify that advertised interfaces match real behavior.
Red flags in code
-
supportsInterface(0xffffffff)returns true. -
The contract claims an interface it does not implement.
-
Inherited interfaces are missing from the override.
-
Proxy calls expose different interface support than direct implementation calls.
-
Interface checks revert or are too gas-heavy.
How to test or review it
-
Test
0x01ffc9a7,0xffffffff, expected IDs, and random unknown IDs. -
Test through the proxy address when the contract is upgradeable.
-
Confirm receiver hooks and token standards match their expected interface IDs.
-
Check that
super.supportsInterface(interfaceId)is used when inheritance requires it. -
Treat ERC165 as a compatibility signal, not proof that behavior is safe.
Keep learning this topic
supportsInterface
supportsInterface is the ERC165 function that returns whether a contract claims support for a given interface ID.
Function Selector
A function selector is the first 4 bytes of calldata that tells an EVM contract which function should handle a call.
ERC721
ERC721 is the Ethereum token standard for non-fungible tokens where each token ID represents a unique asset with one owner.
Practice this in real audit scenarios
Definitions help, but auditors need reps. SCH turns concepts like ERC165 into exploit labs, code review habits, and report-writing practice.
Start the free trial or see the full smart contract auditing course.