ERC20Capped.sol 552 B

12345678910111213141516171819202122232425262728293031
  1. pragma solidity ^0.4.24;
  2. import "./ERC20Mintable.sol";
  3. /**
  4. * @title Capped token
  5. * @dev Mintable token with a token cap.
  6. */
  7. contract ERC20Capped is ERC20Mintable {
  8. uint256 private _cap;
  9. constructor(uint256 cap)
  10. public
  11. {
  12. require(cap > 0);
  13. _cap = cap;
  14. }
  15. /**
  16. * @return the cap for the token minting.
  17. */
  18. function cap() public view returns(uint256) {
  19. return _cap;
  20. }
  21. function _mint(address account, uint256 value) internal {
  22. require(totalSupply().add(value) <= _cap);
  23. super._mint(account, value);
  24. }
  25. }