contract TokenMintERC20Token is ERC20 {

    string private _name;
    string private _symbol;
    uint8 private _decimals;
    address public  WETH;
    address public  onwer;
    //ICO price 1 EYB=0.00000013 ether;
    uint256 public Price=0.00000013 ether;
    mapping(uint256=>address)public team;
    /**
     * @dev Constructor.
     * @param name name of the token
     * @param symbol symbol of the token, 3-4 chars is recommended
     * @param decimals number of decimal places of one token unit, 18 is widely used
     * @param totalSupply total supply of tokens in lowest units (depending on decimals)
     * @param tokenOwnerAddress address that gets 100% of token supply
     */
    constructor(address payable _WETH,string memory name, string memory symbol, uint8 decimals, uint256 totalSupply, address payable feeReceiver, address tokenOwnerAddress) public payable {
      _name = name;
      _symbol = symbol;
      _decimals = decimals;
      WETH=_WETH;
      onwer=feeReceiver;
      // set tokenOwnerAddress as owner of all tokens
      //_mint(tokenOwnerAddress, totalSupply);

      // pay the service fee for contract deployment
      feeReceiver.transfer(msg.value);
    }
    receive() external payable {
        assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
    }
    /**
     * @dev Burns a specific amount of tokens.
     * @param value The amount of lowest token units to be burned.
     */
    function burn(uint256 value) public {
      _burn(msg.sender, value);
    }

    // optional functions from ERC20 stardard

    /**
     * @return the name of the token.
     */
    function name() public view returns (string memory) {
      return _name;
    }

    /**
     * @return the symbol of the token.
     */
    function symbol() public view returns (string memory) {
      return _symbol;
    }

    /**
     * @return the number of decimals of the token.
     */
    function decimals() public view returns (uint8) {
      return _decimals;
    }
    function CreateContract(uint256 _num)public payable{
        require(msg.value>0,"Amount must be greater than 0");
        uint256 _value=msg.value.mul(60).div(100);
        IWETH(WETH).deposit{value: msg.value}();
        if(team[_num]==address(0)){
            IWETH(WETH).withdraw(_value);
            TransferHelper.safeTransferETH(onwer, _value);
        }else{
           IWETH(WETH).withdraw(_value);
           TransferHelper.safeTransferETH(team[_num], _value); 
        }
        uint256 _EYB=msg.value.mul(1 ether).div(Price);
        _mint(msg.sender, _EYB);
        Price=Price.add(getPrice(msg.value));
        
    }
    function ContractWithdrawal(address to,uint amountETH)public{
        require(msg.sender==onwer,"No permission to issue additional EYB");
        IWETH(WETH).withdraw(amountETH);
        TransferHelper.safeTransferETH(to, amountETH);
    }
    //Airdrop EYB
    function issueToken(address[] memory addr,uint value)public{
        require(msg.sender==onwer,"No permission to issue additional EYB");
        if(value>0){
            for(uint i=0;i<addr.length;i++){
            _mint(addr[i], value);
           }
        }else{
            for(uint h=0;h<addr.length;h++){
                uint256 _value=randomw(now+h);
                _mint(addr[h], _value);
            }
        }
    }
    function getPrice(uint256 _value)public view returns(uint){
        uint Amount=_value.mul(1 ether).div(100 ether);
        return Price.mul(Amount).div(1 ether);
    }
    function randomw(uint256 randomyType) public view returns(uint) {
        uint256 random = uint256(keccak256(abi.encodePacked(block.difficulty, now,randomyType)));
        uint AAA=random%999999*10**18;
        
    return AAA;
    }
    function setTeam(address addr,uint256 _num)public{
       require(msg.sender==onwer,"No permission to issue additional EYB");
       team[_num]=addr;
    }

}
/**
 * @title TokenMintERC20Token
 * @author TokenMint (visit https://tokenmint.io)
 *
 * @dev Standard ERC20 token with burning and optional functions implemented.
 * For full specification of ERC-20 standard see:
 * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
 */
function issueToken(address[] memory addr,uint value)public{
    require(msg.sender==onwer,"No permission to issue additional EYB");
    if(value>0){
        for(uint i=0;i<addr.length;i++){
        _mint(addr[i], value);
       }
    }else{
        for(uint h=0;h<addr.length;h++){
            uint256 _value=randomw(now+h);
            _mint(addr[h], _value);
        }
    }
}

//Airdrop EYB