Role Generatorbitwise

Source

ROLE GENERATOR

another usecase for bitwise operator in solidity programming in ROLE base smartcontract's.

what is

in this example, developer can set user role easily.

where to use, any smartcontract like CRUD dapp's.


Review

  • SmartContract
uint private immutable ADMIN_ROLE;      // = tmp << 1;
uint private immutable VICE_ROLE;       // = tmp << 2;
uint private immutable MODERATOR_ROLE;  // = tmp << 3;

function shiftLeft(uint x, uint bits) internal pure returns (uint y) {
    y = x << bits;
}