Last active
February 24, 2024 18:20
-
-
Save johnnyshankman/2661d8fcb7e037c02d1d2ce634e138b7 to your computer and use it in GitHub Desktop.
How to find your ERC165 interface bytes4 using Remix IDE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.