Skip to content

Instantly share code, notes, and snippets.

@NFhbar
Created March 9, 2018 19:21
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 NFhbar/ce4b22d5fc3a65559f694ab3bf9ab418 to your computer and use it in GitHub Desktop.
Save NFhbar/ce4b22d5fc3a65559f694ab3bf9ab418 to your computer and use it in GitHub Desktop.
pragma solidity 0.4.19;
contract Factory {
/*
* Events
*/
event ContractInstantiation(address sender, address instantiation);
/*
* Storage
*/
mapping(address => bool) public isInstantiation;
mapping(address => address[]) public instantiations;
/*
* Public functions
*/
/// @dev Returns number of instantiations by creator.
/// @param creator Contract creator.
/// @return Returns number of instantiations by creator.
function getInstantiationCount(address creator)
public
constant
returns (uint)
{
return instantiations[creator].length;
}
/*
* Internal functions
*/
/// @dev Registers contract in factory registry.
/// @param instantiation Address of contract instantiation.
function register(address instantiation)
internal
{
isInstantiation[instantiation] = true;
instantiations[msg.sender].push(instantiation);
ContractInstantiation(msg.sender, instantiation);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment