Skip to content

Instantly share code, notes, and snippets.

@joeykrug
Created July 17, 2017 02:34
Show Gist options
  • Save joeykrug/3207c8f0b29441f87f0834def918d187 to your computer and use it in GitHub Desktop.
Save joeykrug/3207c8f0b29441f87f0834def918d187 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.11;
import './StandardToken.sol';
import './Ownable.sol';
import './ERC20Basic.sol';
/**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
ERC20Basic constant legacyRepContract = ERC20Basic(0x48c80F1f4D53D5951e5D5438B54Cba84f29F32a5);
mapping(address => bool) mintedToAddress;
modifier canMint() {
if(mintingFinished) throw;
_;
}
/**
* @dev Function to mint tokens
* @param _to The addresses that will recieve the minted tokens.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address[] _to) onlyOwner canMint returns (bool) {
for (uint i = 0; i < _to.length; i++) {
address destinationAddress = _to[i];
if(mintedToAddress[destinationAddress] == false) {
mintedToAddress[destinationAddress] = true;
uint256 amount = legacyRepContract.balanceOf(destinationAddress);
totalSupply = totalSupply.add(amount);
balances[destinationAddress] = balances[destinationAddress].add(amount);
Mint(destinationAddress, amount);
}
}
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment