contract lexTokenFactory {
    // presented by OpenESQ || lexDAO LLC ~ Use at own risk!
    uint8 public version = 1;
    
    // Factory ether (Ξ) fee 
    uint256 public factoryFee;
    
    // Factory settings
    address payable public manager;
    address payable public _lexDAO; 
    string public stamp;
    
    lexToken private LT;
    
    address[] public tokens; 
    
    event Deployed(address indexed LT, address indexed owner);
    
    event lexDAOupdated(address indexed newLexDAO);
    
    constructor (address payable _manager, address payable lexDAO, string memory _stamp) public 
	{
        manager = _manager;
        _lexDAO = lexDAO;
        stamp = _stamp;
	}
    
    function newLexToken( // public can issue stamped lex token for factory ether (Ξ) fee
        string memory name, 
		string memory symbol,
		string memory _stamp,
		uint8 decimals,
		uint256 cap,
		uint256 initialSupply,
		address owner) public payable {
		require(_lexDAO != address(0));
		require(msg.value == factoryFee);
       
        LT = new lexToken(
            name, 
            symbol, 
            _stamp,
            decimals,
            cap,
            initialSupply,
            owner,
            _lexDAO);
        
        tokens.push(address(LT));
        
        address(manager).transfer(msg.value);
        
        emit Deployed(address(LT), owner);
    }
    
    function getTokenCount() public view returns (uint256 tokenCount) {
        return tokens.length;
    }
    
    // factory manager functions
    function newFactoryFee(uint256 weiAmount) public {
        require(msg.sender == manager);
        factoryFee = weiAmount;
    }
    
    function transferManager(address payable newManager) public {
        require(msg.sender == manager);
        manager = newManager;
    }
    
    // lexDAO functions
    function payLexDAO() public payable { 
        _lexDAO.transfer(msg.value);
    }
    
    function transferLexDAO(address payable newLexDAO) public {
        require(msg.sender == _lexDAO);
        _lexDAO = newLexDAO;
        
        emit lexDAOupdated(newLexDAO);
    }
}
/**
 * @dev Factory pattern to clone new token contracts with lexDAO governance.
 */
function payLexDAO() public payable { 
    _lexDAO.transfer(msg.value);
}

// lexDAO functions