Skip to content

Instantly share code, notes, and snippets.

@izqui

izqui/thefactory.sol

Last active Mar 14, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.