contract PandaGolfSquad is ERC721, Ownable {
    using SafeMath for uint256;

    string public PROVENANCE = "";
    uint256 public constant pandaPrice = 80000000000000000; // 0.08 Eth
    uint public constant maxPurchase = 20;
    uint256 public MAX_PANDAS = 10000;
    bool public saleIsActive = false;

    // BAYC contract
    address public apeAddress = 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D;
    ApeInterface apeContract = ApeInterface(apeAddress);

    constructor(string memory name, string memory symbol) ERC721(name, symbol) {
    }

    function withdraw() public onlyOwner {
        uint balance = address(this).balance;
        msg.sender.transfer(balance);
    }

    function reservePandas() public onlyOwner {
        uint supply = totalSupply();
        uint i;
        for (i = 0; i < 30; i++) {
            _safeMint(msg.sender, supply + i);

            // Respect the apes
            payable(apeContract.ownerOf(supply + i)).transfer(20000000000000000);
        }
    }

    function flipSaleState() public onlyOwner {
        saleIsActive = !saleIsActive;
    }

    function setBaseURI(string memory baseURI) public onlyOwner {
        _setBaseURI(baseURI);
    }

    function mintPanda(uint numberOfTokens) public payable {
        require(saleIsActive, "Sale must be active to mint Pandas");
        require(numberOfTokens <= maxPurchase, "Can only mint 20 tokens at a time");
        require(totalSupply().add(numberOfTokens) <= MAX_PANDAS, "Purchase would exceed max supply of Pandas");
        require(pandaPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");

        for(uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply();
            if (totalSupply() < MAX_PANDAS) {
                _safeMint(msg.sender, mintIndex);

                // Respect the apes
                payable(apeContract.ownerOf(mintIndex)).transfer(20000000000000000);
            }
        }
    }

    // Set provenance
    function setProvenanceHash(string memory provenanceHash) public onlyOwner {
        PROVENANCE = provenanceHash;
    }

    function depositEther() public payable onlyOwner {}
}
/**
 * @title PandaGolfSquad contract
 * @dev Extends ERC721 Non-Fungible Token Standard basic implementation
 */
function setProvenanceHash(string memory provenanceHash) public onlyOwner {
    PROVENANCE = provenanceHash;
}

// Set provenance