Loading...
// SPDX-License-Identifier: MIT
//By Rishabh Yadav
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract CompleteNFT is ERC721, ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
uint MAX_SUPPLY = 10;
bool private allowListOpen;
bool private publicOpen;
mapping (address => bool ) public allowList;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("CompleteNFT", "CNFT") {}
function _baseURI() internal pure override returns (string memory) {
return "ipfs://QmQjznhxmG6EJbRb913TvkSxY7DGeMcuQSsyLicCCmvkNi";
}
function allowListMint() public payable {
require(allowListOpen , "mint is not open");
require(allowList[msg.sender] , "you are not on the allowlist");
require(msg.value == 0.001 ether , "Insufficient funds");
internalMint();
}
function publicMint() public payable {
require(publicOpen , "Mint is not open");
require(msg.value == 0.01 ether , "Insufficient funds");
internalMint();
}
function internalMint() internal {
require(totalSupply() < MAX_SUPPLY , "We sold out");
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(msg.sender, tokenId);
}
function editMintWindows(bool _alloeListOpen , bool _publicMintOpen) external onlyOwner{
publicOpen = _publicMintOpen;
allowListOpen = _alloeListOpen;
}
function setAllowList(address[] memory addresses) external onlyOwner{
for(uint i = 0 ; i < addresses.length; i++){
allowList[addresses[i]] = true;
}
}
function withdraw() external onlyOwner{
uint bal = address(this).balance;
payable(msg.sender).transfer(bal);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
internal
override(ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}