ERC20Capped.sol 813 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. /**
  22. * @dev Function to mint tokens
  23. * @param to The address that will receive the minted tokens.
  24. * @param value The amount of tokens to mint.
  25. * @return A boolean that indicates if the operation was successful.
  26. */
  27. function mint(
  28. address to,
  29. uint256 value
  30. )
  31. public
  32. returns (bool)
  33. {
  34. require(totalSupply().add(value) <= _cap);
  35. return super.mint(to, value);
  36. }
  37. }