contract SimpDAO is ERC721A, Ownable {

    uint256 public mintPrice = 0.01 ether;
    uint32 constant public maxSupply = 1111;
    uint32 constant public freeMintMax = 500;
    uint256 public freeMintCount = 0;
    uint256 public saleStartTimestamp;

    constructor() ERC721A("SimpDAO", "Simp", 2, maxSupply) {
    }

    function mint(uint256 _quantity) external payable {
        require(msg.value >= mintPrice * _quantity, "Insufficent ethereum amount sent");
        _safeMint(msg.sender, _quantity);
    }

    function freeMint(uint256 _quantity) external {
        require(freeMintCount +_quantity < freeMintMax, "Free mint limit reached");
        _safeMint(msg.sender, _quantity);
        freeMintCount += _quantity;
    }

 
    function withdraw() public onlyOwner {
        uint256 balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
    function tokenURI(uint256 tokenId) override public view returns (string memory) {
	
        string memory image = string(abi.encodePacked('<svg width="512pt" height="512pt" version="1.0" viewBox="0 0 512.000000 512.000000" xmlns="http://www.w3.org/2000/svg"> <g transform="translate(0 512) scale(.1 -.1)"> <path d="m465 5104c-228-45-406-225-450-458-22-117-23-4054 0-4173 44-235 222-413 459-458 117-22 4054-23 4173 0 235 44 413 222 458 459 22 117 23 4054 0 4173-44 235-222 413-459 458-112 22-4072 21-4181-1zm2409-943c280-57 470-163 532-296 50-105 24-256-58-349-64-74-105-91-218-91-89 0-105 3-245 52-227 79-369 92-494 44-114-43-172-105-193-203-16-79 0-129 61-189 61-59 156-99 426-179 113-33 241-74 284-90 372-137 572-321 657-605 36-120 45-357 20-484-79-388-360-677-765-785-140-38-263-50-445-43-488 17-848 151-947 353-35 71-39 188-9 268 25 67 83 130 145 161 33 16 60 20 145 19 102 0 111-2 287-62 212-72 278-89 389-98 210-17 388 65 461 214 24 50 28 69 28 149 0 85-2 94-30 135-37 53-129 116-221 152-38 14-181 60-319 100-404 120-546 188-691 331-130 129-190 272-201 476-28 526 341 950 903 1039 96 15 384 4 498-19z"/> </g> </svg> '));
        string memory output = string(abi.encodePacked(image));
        string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Simp #', toString(tokenId),'","attributes": [ { "trait_type": "Simp", "value": "','True','" }]',', "description": "Certified Simp - ', toString(tokenId),'/1000','", "image": "data:image/svg+xml;base64,',Base64.encode(bytes(output)),'"}'))));
		output = string(abi.encodePacked('data:application/json;base64,', json));
        return output;
    }
    	
	 /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

}
function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }
/**
 * @dev Converts a `uint256` to its ASCII `string` decimal representation.
 */