// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; contract Reserve is ERC721Enumerable, Ownable { string _baseTokenURI; uint256 private _price = 0.04 ether; mapping(address => uint256) public claimMap; constructor(string memory baseURI) ERC721("Reserve", "R") { setBaseURI(baseURI); } // pay at the point of reserving // should stop ppl reserving and never claiming function reserve(uint256 num) public payable { require(num < 21, "You can adopt a maximum of 20"); require(msg.value >= _price * num, "Ether sent is not correct"); claimMap[msg.sender] += num; } // limit claim to help prevent gassing out function claim(uint256 num) public { uint256 supply = totalSupply(); uint256 claimCount = claimMap[msg.sender]; require(num >= claimCount, "Cant claim more than you own"); require(num < 21, "You can claim a maximum of 20"); for (uint256 i; i < claimCount; i++) { _safeMint(msg.sender, supply + i); } // account for the claim claimMap[msg.sender] -= num; } // standard minting function adopt(uint256 num) public payable { uint256 supply = totalSupply(); require(num < 21, "You can adopt a maximum of 20"); require(msg.value >= _price * num, "Ether sent is not correct"); for (uint256 i; i < num; i++) { _safeMint(msg.sender, supply + i); } } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { _baseTokenURI = baseURI; } function getReservedCount() public view returns (uint256){ return claimMap[msg.sender]; } }