MintableToken.sol 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. pragma solidity ^0.4.8;
  2. import './StandardToken.sol';
  3. import '../ownership/Ownable.sol';
  4. /**
  5. * Mintable token
  6. *
  7. * Simple ERC20 Token example, with mintable token creation
  8. * Issue:
  9. * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
  10. * Based on code by TokenMarketNet:
  11. * https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
  12. */
  13. contract MintableToken is StandardToken, Ownable {
  14. event Mint(address indexed to, uint value);
  15. event MintFinished();
  16. bool public mintingFinished = false;
  17. uint public totalSupply = 0;
  18. modifier canMint() {
  19. if(mintingFinished) throw;
  20. _;
  21. }
  22. function mint(address _to, uint _amount) onlyOwner canMint returns (bool) {
  23. totalSupply = totalSupply.add(_amount);
  24. balances[_to] = balances[_to].add(_amount);
  25. Mint(_to, _amount);
  26. return true;
  27. }
  28. function finishMinting() onlyOwner returns (bool) {
  29. mintingFinished = true;
  30. MintFinished();
  31. return true;
  32. }
  33. }