Skip to content

Instantly share code, notes, and snippets.

@johnnyshankman
Last active February 24, 2024 18:20
Show Gist options
  • Save johnnyshankman/2661d8fcb7e037c02d1d2ce634e138b7 to your computer and use it in GitHub Desktop.
Save johnnyshankman/2661d8fcb7e037c02d1d2ce634e138b7 to your computer and use it in GitHub Desktop.
How to find your ERC165 interface bytes4 using Remix IDE
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
// @dev: replace this interface with your ERC165 interface
interface SomeInterface is IERC165 {
function someFunction(uint256 id) external view returns (string memory);
}
// @dev: put this whole file in Remix and compile it.
// after, deploy this Helper contract to any network.
// lastly, call getInterface() to get your bytes4 value.
contract Helper {
function getInterface() public view virtual returns (bytes4) {
// @WARN: update this to refer to YOUR interface
return type(SomeInterface).interfaceId;
}
}
@johnnyshankman
Copy link
Author

Since this is a predictable static call, you can use any network including the simulated shanghai network bundled with Remix to save time and money.

ss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment