Skip to content

Instantly share code, notes, and snippets.

@ToJen
Last active August 31, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToJen/046ee107fbe2e507f412487cd32a3539 to your computer and use it in GitHub Desktop.
Save ToJen/046ee107fbe2e507f412487cd32a3539 to your computer and use it in GitHub Desktop.
Example factory contract
pragma solidity ^0.4.9;
contract Cookie {
bool public hasChocolate;
function Cookie(bool _hasChocolate) public {
hasChocolate = _hasChocolate;
}
}
contract Bakery {
address public baker;
address[] public cookies;
function Bakery() {
baker = msg.sender;
}
function bakeCookie(bool _isChocolateChip) public {
Cookie c = new Cookie(_isChocolateChip);
cookies.push(c);
}
function addCookie(address _cookie) public {
cookies.push(_cookie);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment