Untitled
unknown
plain_text
10 months ago
5.1 kB
13
Indexable
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; using Strings for uint256; contract PMFContract is ERC721, Ownable, ReentrancyGuard { // variables string public NAME = "PMF Contract"; string public SYMBOL = "PMF"; address public contractOwner; string private currentBaseURI; // uint256 public constant OWNERS = 1; // uint256 public constant CUSTOM_TOKENS = 2; // uint256 public constant PARTNER_PMF_TOKENS = 3; // uint256 public constant FOUNDER_PMF_TOKENS = 4; // uint256 public constant FUNDER_ASSOSIATE_TOKENS = 5; // uint256 public constant FUNDER_COMMUNITY_TOKENS = 6; // uint256 public constant SPONSOR_TOKENS = 7; // uint256 public constant PARTICIPANT_TOKENS = 8; // Active minting tiers uint256 private activeTierOne = 4; uint256 private activeTierTwo = 5; // Mapping for token supplies mapping(uint256 => uint256) private _tokenSupplies; // Mapping for token minting prices mapping(uint256 => uint256) private _tokenPrices; // Mapping for each tier current Index mapping(uint256 => uint256) private _tierCurentMintingIndex; // Modifier to check if the token corresponds to one of the current active tiers modifier isActiveTier(uint256 _tier) { require(_tier == activeTierOne || _tier == activeTierTwo, "This tier is not active for minting."); _; } constructor() ERC721(NAME, SYMBOL) Ownable(msg.sender){ contractOwner = msg.sender; // Initialize token supplies _tokenSupplies[1] = 2; _tokenSupplies[2] = 8; _tokenSupplies[3] = 180; _tokenSupplies[4] = 360; _tokenSupplies[5] = 101; _tokenSupplies[6] = 520; _tokenSupplies[7] = 52000; _tokenSupplies[8] = 101000; // Initialize token prices _tokenPrices[1] = 0.01 ether; _tokenPrices[2] = 0.05 ether; _tokenPrices[3] = 26.3 ether; _tokenPrices[4] = 7.0 ether; _tokenPrices[5] = 8.0 ether; _tokenPrices[6] = 1 ether; _tokenPrices[7] = 0.14 ether; _tokenPrices[8] = 0.08 ether; // Initialize each tier current minting index _tierCurentMintingIndex[1] = 1; _tierCurentMintingIndex[2] = 3; _tierCurentMintingIndex[3] = 11; _tierCurentMintingIndex[4] = 191; _tierCurentMintingIndex[5] = 551; _tierCurentMintingIndex[6] = 652; _tierCurentMintingIndex[7] = 1172; _tierCurentMintingIndex[8] = 53172; } // functions: function publicMint(uint256 _tier) public payable isActiveTier(_tier) { require(_tokenSupplies[_tier] > 0, "No more tokens available to mint in this tier."); require(msg.value == _tokenPrices[_tier], "Insufficient funds sent."); _mint(msg.sender, _tierCurentMintingIndex[_tier]++); _tokenSupplies[_tier]--; } function adminMint(uint256 _tier, address account) public onlyOwner { require(_tokenSupplies[_tier] > 0, "Insufficient token supply."); _tokenSupplies[_tier]--; _mint(account, _tierCurentMintingIndex[_tier]++); } // To change the current minting tier: function setActiveTiers(uint256 _tierOne, uint256 _tierTwo) public onlyOwner { require(_tierOne != _tierTwo, "Tiers must be different."); require(_tierOne >= 1 && _tierOne <= 8 && _tierTwo >= 1 && _tierTwo <= 8, "Invalid tier."); activeTierOne = _tierOne; activeTierTwo = _tierTwo; } // admin can withdraw funds from contract: function withdrawFunds() external nonReentrant onlyOwner { payable(contractOwner).transfer(address(this).balance); } function setBaseURI(string memory _newBaseURI) public onlyOwner { currentBaseURI = _newBaseURI; } function _baseURI() internal view virtual override returns (string memory) { return currentBaseURI; } function tokenURI(uint256 tokenId) public view virtual override(ERC721) returns (string memory) { _requireOwned(tokenId); return string(abi.encodePacked(currentBaseURI, tokenId.toString(), ".json")); } // Get the current active minting tiers function getCurrentMintingTiers() public view returns (uint256, uint256) { return (activeTierOne, activeTierTwo); } // To retrieve the remaining supply for a token function getTokenSupply(uint256 _tier) public view returns (uint256) { return _tokenSupplies[_tier]; } // To retrieve the minting price for a currenttier function getTokenPrice(uint256 _tier) public view returns (uint256) { return _tokenPrices[_tier]; } // To retrieve the current tier minting tokenId function getTierMintingTokenId(uint256 _tier) public view returns (uint256) { return _tierCurentMintingIndex[_tier]; } }
Editor is loading...
Leave a Comment