Skip to content

Instantly share code, notes, and snippets.

@ramvi
Last active August 28, 2017 12:22
Show Gist options
  • Save ramvi/65e0a7a6a988ce9ce8f0d775155f3615 to your computer and use it in GitHub Desktop.
Save ramvi/65e0a7a6a988ce9ce8f0d775155f3615 to your computer and use it in GitHub Desktop.
import "browser/My1stToken.sol";
pragma solidity ^0.4.16;
contract TokenFactorySolution {
mapping(address => address[]) public created;
mapping(address => bool) public isMy1stToken; //verify that given address is of this token type
function createToken(uint256 _initialAmount, string _name, uint8 _decimals, string _symbol) returns (address) {
My1stToken newToken = (new My1stToken(_initialAmount, _name, _decimals, _symbol));
created[msg.sender].push(address(newToken));
isMy1stToken[address(newToken)] = true;
newToken.transfer(msg.sender, _initialAmount); //the factory will own the created tokens. You must transfer them.
return address(newToken);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment