ERC20Capped.sol 587 B

12345678910111213141516171819202122232425262728
  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) public {
  10. require(cap > 0);
  11. _cap = cap;
  12. }
  13. /**
  14. * @return the cap for the token minting.
  15. */
  16. function cap() public view returns (uint256) {
  17. return _cap;
  18. }
  19. function _mint(address account, uint256 value) internal {
  20. require(totalSupply().add(value) <= _cap);
  21. super._mint(account, value);
  22. }
  23. }