CappedToken.sol 696 B

12345678910111213141516171819202122232425262728293031
  1. pragma solidity ^0.4.11;
  2. import "./MintableToken.sol";
  3. /**
  4. * @title Capped token
  5. * @dev Mintable token with a token cap.
  6. */
  7. contract CappedToken is MintableToken {
  8. uint256 public cap;
  9. function CappedToken(uint256 _cap) public {
  10. require(_cap > 0);
  11. cap = _cap;
  12. }
  13. /**
  14. * @dev Function to mint tokens
  15. * @param _to The address that will receive the minted tokens.
  16. * @param _amount The amount of tokens to mint.
  17. * @return A boolean that indicates if the operation was successful.
  18. */
  19. function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
  20. require(totalSupply_.add(_amount) <= cap);
  21. return super.mint(_to, _amount);
  22. }
  23. }