Created
March 29, 2023 01:36
-
-
Save nxt3d/2204a119ff35404edc34e25b245f5672 to your computer and use it in GitHub Desktop.
Generate a function selector. (can be cut and pasted into Remix)
This file contains 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.17; | |
contract FunctionSelector { | |
/* | |
"transfer(address,uint256)" | |
0xa9059cbb | |
"transferFrom(address,address,uint256)" | |
0x23b872dd | |
*/ | |
function getSelector(string calldata _func) external pure returns (bytes4) { | |
return bytes4(keccak256(bytes(_func))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment