Created
August 10, 2018 20:51
-
-
Save carolplay/b547d54f39c7d4d35f9a6aa71a1df1e3 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
contract Token { | |
mapping(address => uint256) balances; | |
uint256 totalSupply; | |
function Token(uint256 _initialAmount) public { | |
balances[msg.sender] = _initialAmount; | |
totalSupply = _initialAmount; | |
} | |
function transfer(address _to, uint256 amount) | |
public returns (bool) { | |
require(balances[msg.sender] >= amount); | |
balances[msg.sender] -= amount; | |
balances[_to] += amount; | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
import "./Token.sol"; | |
contract TokenFactory { | |
mapping(address => address[]) created; | |
function createToken(uint256 _initialAmount) | |
public returns(address) | |
{ | |
Token newToken = new Token(_initialAmount); | |
created[msg.sender].push(address(newToken)); | |
newToken.transfer(msg.sender, _initialAmount); | |
return address(newToken); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment