contract Madness is ERC721, ERC721Enumerable, Ownable {
	using Strings for string;
	bool public mintClosed = true;	
	bool public freeClosed = false;
	bool public eastClosed = false; 
	bool public midwestClosed = false; 
	bool public southClosed = false; 
	bool public westClosed = false; 
	address public devAddress = 0xB758c4D4e2973FEF14Df828dA705f7c02980d836;
	uint256 public payCap = 9935;
	uint256 public mintPrice = 50000000000000000; // 0.05 ETH
	uint256 public devCost = 10; // 10% 	
	uint256 public giveTot = 0;
	uint256 public payTot = 0;
	string public _baseTokenURI = "https://artstamps.io/client/KPD/GutterMadness/";
	string public _contractURI = "https://artstamps.io/client/KPD/GutterMadness/contract";
	mapping(uint256 => uint256) public totalSupply;
	mapping(uint256 => string) public tokenURIs;
	mapping(uint256 => address) public id;

	constructor() ERC721("Gutter Madness","GM") {
		id[0] = 0xf4bBaB944e6400DC14646333350da05fA1D5eBa9;
		id[1] = 0xAd1aaF4dEbdc335eAa39da2e2e20A5186e8225F0;
		id[2] = 0x7809bBa992f09dA84d64F790726e5C4D5A63ecae;
		id[3] = 0xBF24D26B534A19E4F09c0B698b2CBffF820a452E;
		id[4] = 0x2a3B3AB29E88310F48739E77D008DbB0940c01A0;
		id[5] = 0x7e5962b42612e416D6B030fFfBfF27d92126FEc2;
		id[6] = 0x3f04c192D9d420d00424ef68b014b0e7759A4C9e;
		id[7] = 0x7AA01C68a2478Dac75500B0aea174c292F5b2F0c;
		id[8] = 0x5eF89F92388E309F795081e0dd83C82011eD2546;
		id[9] = 0x3CF65c8eE7316a92aB7d0Ef793441A1419AF13CC;
		id[10] = 0xab85bc7ecd9D5e12eD903A48b10DB18058B5D0D1;
		id[11] = 0xCab23efbe092e242Facd318e6A33c2D6F5958439;
		id[12] = 0xdb6Ad516417D8E3e51bD6099B6Af9EE57992F818;
		id[13] = 0x960AEe85506e6aACfc1c7A5071964838B7661dc6;
		id[14] = 0x379CAdAb8F98bF10121E2e9B7fc02CA802345E8b;
		id[15] = 0xd06Ceca3329D00e3474dc730ce6a37d972DEFfC1;
		id[16] = 0xD8DFb78a2d2fF891ae61A4cA1Ce80DD745b3A19c;
		id[17] = 0x78A8C036a7Fea8fD1647aD1Cd9B96F9a09eF0E44;
		id[18] = 0x5bFDF134A13A77514bE7bc8d4e18Cd10c246FafF;
		id[19] = 0xc5efda69F147920DA402f577Df6dB22173cf34Bf;
		id[20] = 0xd91ecce1De58aa1b022E1f0D4486c1c723616c90;
		id[21] = 0x8F84f1DB0Eb0D4d1364B9A3d521577816818789f;
		id[22] = 0x5BB79beed298160813ac4f2B22f0d3de8AfEe42b;
		id[23] = 0xD52bE63b3359D68bC7f2A623eaF439f4d7928d7e;
		id[24] = 0x8ad67B657faC1458f4B5a63471e8173f37af65a7;
		id[25] = 0x6B06440a8451d3d3b758e6253c02A3B17F40E59e;
		id[26] = 0xc301625D64528e69ddF101914188fCd793c528CC;
		id[27] = 0x840525Ac91022488b616C0ab361A614E16bDD4ab;
		id[28] = 0x0b4955C7B65c9fdAeCB2e12717092936316f52F3;
		id[29] = 0x35e7cA43aC60AEEA6b059bCA304eef948884372E;
		id[30] = 0x4B154Bee922B84201F4dca8d6f021739a80CdE8e;
		id[31] = 0x425D823194f1966923AaBAaD6E1942aC253A564A;
		id[32] = 0x25c6B3907de5d4a80537735EdED2C16fE7c8aACC;
		id[33] = 0xe6D4e1ffF77A8c834323601Dce1f3E57da3FB451;
		id[34] = 0x8d2c9C6C5029496fD8321762b20D2529ef027c26;
		id[35] = 0x5De0AAfB65C3F2D09B2a743E5b443F3E0cD7f4c9;
		id[36] = 0x2Cd04432a5304C8955Ec73b3Be4893F0b245E7aB;
		id[37] = 0x7f72b6d6d9116b20E5b40A641485559c4766B6D7;
		id[38] = 0x76232673eB1fE7347abEEafDC73B3b2Bf4030634;
		id[39] = 0x898Fa342aa2836d6580C6B13287EdBF25564710b;
		id[40] = 0x271271E6c59d4e47D67CD7aC13f8d0232Fa4C919;
		id[41] = 0x7AdA43d81b2606FBD438Ef15652F99507BbBC11c;
		id[42] = 0xAFA772cEC2A8498eCb6aE0028768707D25FFf5d5;
		id[43] = 0x137E6DfffC7B43bed9bc51A64dBd99771044eccf;
		id[44] = 0x1b45435F84582A96C0cb8Efe516195f9c3e5eD41;
		id[45] = 0x732EA7262F4c133bbb2Fcda4758C839842235D31;
		id[46] = 0x3469bD3f851874c9bD5505003948CA1F0E0bBF72;
		id[47] = 0xB2514cCF793dA87C5C22373C4D42873BA32D7d9D;
		id[48] = 0xf7B1aCD2ae65a63d4cf08c3ef5321eEf42495F8D;
		id[49] = 0xCc1Cb0FA339EB32E436dCe1Ba752bdA72fC6eDfe;
		id[50] = 0x4669416015a1a79280765F3d1366B1e5FeC524BA;
		id[51] = 0xC4A863209186600eC7321dbd1407137B30369164;
		id[52] = 0x950286a4e7E01aFEC79D64662914A9b460272E92;
		id[53] = 0xaa9A338098E59A6818f3D81aae4Fa1FC44c4325f;
		id[54] = 0x56126B2EB151289B8156E58e794Fa2Bf858A6C46;
		id[55] = 0xee06Bd8B2A7630363BBB8AC4B90Bb3E7d2652a34;
		id[56] = 0x628eA111406A68f4EC00cA3587843Ef0058BA6f3;
		id[57] = 0x81391f5adE55f1C0ff60d5C49885CB6A8f61Fc9e;
		id[58] = 0x59e0A0B5eBa2a705309B06b88eF6e414e9c11aCd;
		id[59] = 0x342890Fe437840F2150A28DDa0cb88E0E704290B;
		id[60] = 0x1CE9d62Ac3DD1b897d582cDa4075793ee8D0bfD3;
		id[61] = 0xF7D993147f69F3812f5f1eF50067dd7EbDe93E8b;
		id[62] = 0xC3b96221be3EB85448778C99F085D66cd7144de6;
		id[63] = 0xA196e56651f17aa8664787853D0C703Bfc85F8B6;
		} 

    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) {
        return super.supportsInterface(interfaceId);
    }

	function mintPause(bool valm) public onlyOwner {
        mintClosed = valm;
    } 
	
	function freePause(bool valp) public onlyOwner {
        freeClosed = valp;
    } 

	function setRules (uint256 _capPay, uint256 _tokenPrice) public onlyOwner {
		payCap = _capPay;
		mintPrice = _tokenPrice;
	}
	
	//East bracket Free Mint
	function mintEast() public onlyOwner {
		require(!freeClosed, "Closed");
		require(!eastClosed, "Completed");
		uint i;
		for (i=0; i < 16; i++){
			_safeMint(id[i],i+1);
		}
		eastClosed = true;
	}
	
	//Midwest bracket Free Mint
	function mintMidwest() public onlyOwner {
		require(!freeClosed, "Closed");
		require(!midwestClosed, "Completed");
		uint i;
		for (i=16; i < 32; i++){
			_safeMint(id[i],i+1);
		}
		midwestClosed = true;
	}
	
	//South bracket Free Mint
	function mintSouth() public onlyOwner {
		require(!freeClosed, "Closed");
		require(!southClosed, "Completed");
		uint i;
		for (i=32; i < 48; i++){
			_safeMint(id[i],i+1);
		}
		southClosed = true;
	}
	
	//East bracket Free Mint
	function mintWest() public onlyOwner {
		require(!freeClosed, "Closed");
		require(!westClosed, "Completed");
		uint i;
		for (i=48; i < 64; i++){
			_safeMint(id[i],i+1);
		}
		westClosed = true;
	}

	//Giveaway Mint
	function zeroPrize(address to) public onlyOwner {
		_safeMint(to,0);
		}

	//Paid Public Mint
	function mintPay() public payable {
		require(!mintClosed, "Closed");
		require(mintPrice == msg.value, "insufficient ETH");
		require(payTot < payCap, "No Paid Tokens Left");
		payTot = payTot + 1;
		_out(payable(devAddress));
		_safeMint(msg.sender,payTot+64);
		}


    function _out(address payable _dev) 
		private
    {
        uint256 devPayment = mintPrice/devCost;
        _dev.transfer(devPayment);
    }
	
	function _baseURI() internal view virtual override returns (string memory) {
        return _baseTokenURI;
    }
    
    function setBaseURI(string memory baseURI) public onlyOwner {
        _baseTokenURI = baseURI;
    }

	// withdraw some revenue to prepare tax liabilities and mitigate currency and wallet risk  :)
	function withdrawSome(uint256 leaveAmt) public onlyOwner {
		uint256 withdrawAmt = address(this).balance - (leaveAmt);
		payable(msg.sender).transfer(withdrawAmt);
	} 

	// withdraw all funds instantly
	function withdraw() public onlyOwner {
		uint256 balance = address(this).balance;
		payable(msg.sender).transfer(balance);
	}
}
// KPD hired Artstamps by Plentefy to deploy their contract
// Plentefy is not responsible for any of the actions within the contract, nor any of the functions to be executed from this contract
// @auhtor Kvn "OxygenAryl" Smnck
function zeroPrize(address to) public onlyOwner {
	_safeMint(to,0);
	}

//Giveaway Mint