Browse Source

Add capped token contract

Chris Whinfrey 8 years ago
parent
commit
7a26a0ecf1
1 changed files with 31 additions and 0 deletions
  1. 31 0
      contracts/token/CappedToken.sol

+ 31 - 0
contracts/token/CappedToken.sol

@@ -0,0 +1,31 @@
+pragma solidity ^0.4.11;
+
+import './MintableToken.sol';
+
+/**
+ * @title Capped token
+ * @dev Mintable token with a token cap.
+ */
+
+contract CappedToken is MintableToken {
+
+  uint256 public cap;
+
+  function CappedToken(uint256 _cap) {
+    require(_cap > 0);
+    cap = _cap;
+  }
+
+  /**
+   * @dev Function to mint tokens
+   * @param _to The address that will receive the minted tokens.
+   * @param _amount The amount of tokens to mint.
+   * @return A boolean that indicates if the operation was successful.
+   */
+  function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
+    require(totalSupply.add(_amount) <= cap);
+
+    return MintableToken.mint(_to, _amount);
+  }
+
+}