RBACMintableToken.sol 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. pragma solidity ^0.4.24;
  2. import "./ERC20Mintable.sol";
  3. import "../../access/rbac/RBAC.sol";
  4. /**
  5. * @title RBACMintableToken
  6. * @author Vittorio Minacori (@vittominacori)
  7. * @dev Mintable Token, with RBAC minter permissions
  8. */
  9. contract RBACMintableToken is ERC20Mintable, RBAC {
  10. /**
  11. * A constant role name for indicating minters.
  12. */
  13. string private constant ROLE_MINTER = "minter";
  14. /**
  15. * @dev override the Mintable token modifier to add role based logic
  16. */
  17. modifier hasMintPermission() {
  18. checkRole(msg.sender, ROLE_MINTER);
  19. _;
  20. }
  21. /**
  22. * @return true if the account is a minter, false otherwise.
  23. */
  24. function isMinter(address _account) public view returns(bool) {
  25. return hasRole(_account, ROLE_MINTER);
  26. }
  27. /**
  28. * @dev add a minter role to an address
  29. * @param _minter address
  30. */
  31. function addMinter(address _minter) public onlyOwner {
  32. _addRole(_minter, ROLE_MINTER);
  33. }
  34. /**
  35. * @dev remove a minter role from an address
  36. * @param _minter address
  37. */
  38. function removeMinter(address _minter) public onlyOwner {
  39. _removeRole(_minter, ROLE_MINTER);
  40. }
  41. }