Granular permissions can be setup in smart contracts by defining specific roles, using AccessControl.sol. In the OpenZeppelin docs, the following example is given for defining granular permissions to the following MINTER_ROLE
and BURNER_ROLE
:
...
contract MyToken is ERC20, AccessControl {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
...
However, I do not understand why we must hash the name of the role using keccak256
.
What is achieved by hashing the name of the role with keccak256?