MintableToken.sol 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. bool public mintingFinished = false;
  16. uint public totalSupply = 0;
  17. modifier canMint() {
  18. if(mintingFinished) throw;
  19. _;
  20. }
  21. function mint(address _to, uint _amount) onlyOwner canMint returns (bool) {
  22. totalSupply = safeAdd(totalSupply, _amount);
  23. balances[_to] = safeAdd(balances[_to], _amount);
  24. Mint(_to, _amount);
  25. return true;
  26. }
  27. function finishMinting() onlyOwner returns (bool) {
  28. mintingFinished = true;
  29. return true;
  30. }
  31. }