MinterRole.sol 781 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. pragma solidity ^0.4.24;
  2. import "../Roles.sol";
  3. contract MinterRole {
  4. using Roles for Roles.Role;
  5. event MinterAdded(address indexed account);
  6. event MinterRemoved(address indexed account);
  7. Roles.Role private minters;
  8. constructor() public {
  9. minters.add(msg.sender);
  10. }
  11. modifier onlyMinter() {
  12. require(isMinter(msg.sender));
  13. _;
  14. }
  15. function isMinter(address account) public view returns (bool) {
  16. return minters.has(account);
  17. }
  18. function addMinter(address account) public onlyMinter {
  19. minters.add(account);
  20. emit MinterAdded(account);
  21. }
  22. function renounceMinter() public {
  23. minters.remove(msg.sender);
  24. }
  25. function _removeMinter(address account) internal {
  26. minters.remove(account);
  27. emit MinterRemoved(account);
  28. }
  29. }