contract PIXA is ERC20 {
    using SafeMath for uint256;
    uint256 public tokenPrice = 10000000000000; // 0.00001 ETH
    uint256 public tokensSold = 0; // At deployment, zero tokens sold.
    address payable wizarDAOtemp = 0x717e63BF905fF0f433333B6f0a289b66462Cd8a1; //temporary DAO wallet
    address payable pixadeploywallet = 0x6936Ec090eEB012A81Ada463FCf55BB3dFd86264; // deployment wallet
    bool public saleStatus = false;
    event Sell(address _buyer, uint256 _amount); // Purchase during ICO

    /**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */
    constructor(
        uint256 initialSupply //define initial supply of 3 mil. tokens.

    ) ERC20() {
        _mint(address(this), 500000); // initial mint 1/4 for ICO
        _mint(pixalyfewallet, 500000); // initial mint 1/4 for airdrops & marketing
        _mint(wizarDAOtemp, 1000000); // initial mint 1/2 to DAO
    }// 2 million PIXA initial supply, priced at 0.00001 ETH per for ICO, market cap est. 20 ETH.

    function multiply(uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x);
    }

    // start ICO
    function startSale() public {
        require(msg.sender == pixalyfewallet);
        saleStatus = true;
    } 

    // close ICO
    function endSale() public {
        require(msg.sender == pixalyfewallet);
        saleStatus = false;
    } 

    // Function to buy tokens during ICO, need sale toggle on.
    function buyTokens(uint256 _numberOfTokens) public payable {
        require(saleStatus);
        require(msg.value == multiply(_numberOfTokens, tokenPrice));
        require(balanceOf(address(this)) >= _numberOfTokens);
        require(_transfer(address(this), msg.sender, _numberOfTokens));

        tokensSold += _numberOfTokens;

        emit Sell(msg.sender, _numberOfTokens);
    }

    function getBalance() public view returns (uint256) {
        return address(this).balance;
    }

    // withdraw eth from ico deposited in contract to pixalyfe wallet
    function withdrawAmount() public {
        require(msg.sender == pixalyfewallet);
        uint256 amount = getBalance();
        msg.sender.transfer(amount);
    }    

    // leftover PIXA from ICO goes to WizarDAO
    function withdrawPixa(uint256 amount) public {
        require(msg.sender == pixalyfewallet);
        address wizarDAOwith = read_address();
        _transfer(address(this), wizarDAOwith, amount);
    }    




}
function endSale() public {
        require(msg.sender == pixalyfewallet);
        saleStatus = false;
    }
// close ICO