Last active
March 14, 2017 10:20
-
-
Save izqui/375f257432a96cf55c980db20aa00d3f to your computer and use it in GitHub Desktop.
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
contract TheContractFactory is LiveFactory { | |
function uploadCode(string identifier, bytes o_code) | |
onlyOrNone(deployer[identifierHash(identifier)]) | |
returns (bytes32) { | |
bytes32 h = identifierHash(identifier); | |
code[h] = o_code; | |
deployer[h] = msg.sender; | |
NewCode(identifier); | |
return h; | |
} | |
function deploy(string identifier) { | |
bytes c = code[identifierHash(identifier)]; | |
if (c.length == 0) throw; | |
NewContract(deployCode(c), msg.sender, identifier); | |
} | |
function identifierHash(string identifier) returns (bytes32) { | |
return sha3(identifier); | |
} | |
modifier onlyOrNone(address x) { | |
if (x != 0x0 && x != msg.sender) throw; | |
_; | |
} | |
mapping (bytes32 => address) public deployer; | |
mapping (bytes32 => bytes) public code; | |
event NewContract(address x, address indexed owner, string identifier); | |
event NewCode(string identifier); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment