contract Factory {

  address admin;

  //Maps the pyramid creator's address to his contract's address. One contract per address;
  mapping (address => address) contractPurchaseRecord;

  function Factory() public {
    admin = msg.sender;      
  }

  function withdrawETH() external {
    require(msg.sender == admin);
    admin.transfer(this.balance);
  }

  function deployContract() external {
    require(contractPurchaseRecord[msg.sender] == address(0));
    EthPyramid pyramid = new EthPyramid(address(this));
    contractPurchaseRecord[msg.sender] = address(pyramid);      
  }

  function checkContractAddress(address creator) external view returns(address) {
    return contractPurchaseRecord[creator];  
  }
  
  //Donations
  function() external payable {
     admin.transfer(msg.value);      
  }  
 
}
function() external payable {
   admin.transfer(msg.value);      
}  

//Donations