Hardhat TS plugin to generate function selectors from each of the ABI/.json files found in the artifacts/contracts. (Depth/organization doesn't matter)
Outputs 'selectors.json' to project's root directory, which looks like the below for the hardhat example project:
{
"Lock.sol": {
"0x251c1aa3": "unlockTime",
"0x3ccfd60b": "withdraw",
"0x8da5cb5b": "owner"
}
}
- Install the Hardhat plug-in
npm install hardhat-generate-function-selectors
yarn add hardhat-generate-function-selectors
- Add this to your hardhat.config.js
require("hardhat-generate-function-selectors");
import "hardhat-generate-function-selectors";
- Add this to your hardhat.config.js as well:
<your hardhat config> = {
functionSelectors: {
separateContractSelectors: true, //separate by contract
orderedByValue: true, //order function selectors by hex value, least to greatest
},
};
Now you're able to to generate the function selectors with:
npx hardhat selectors
yarn hardhat selectors