MintableToken.sol 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. pragma solidity ^0.4.11;
  2. import './StandardToken.sol';
  3. import '../ownership/Ownable.sol';
  4. /**
  5. * @title Mintable token
  6. * @dev Simple ERC20 Token example, with mintable token creation
  7. * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
  8. * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
  9. */
  10. contract MintableToken is StandardToken, Ownable {
  11. event Mint(address indexed to, uint256 amount);
  12. event MintFinished();
  13. bool public mintingFinished = false;
  14. modifier canMint() {
  15. if(mintingFinished) throw;
  16. _;
  17. }
  18. /**
  19. * @dev Function to mint tokens
  20. * @param _to The address that will recieve the minted tokens.
  21. * @param _amount The amount of tokens to mint.
  22. * @return A boolean that indicates if the operation was successful.
  23. */
  24. function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) {
  25. totalSupply = totalSupply.add(_amount);
  26. balances[_to] = balances[_to].add(_amount);
  27. Mint(_to, _amount);
  28. return true;
  29. }
  30. /**
  31. * @dev Function to stop minting new tokens.
  32. * @return True if the operation was successful.
  33. */
  34. function finishMinting() onlyOwner returns (bool) {
  35. mintingFinished = true;
  36. MintFinished();
  37. return true;
  38. }
  39. }