Nft

是否可以同時創建白名單和公開發售?請幫忙!

  • August 22, 2022

是否可以同時創建白名單和公開發售?我需要為一個項目做這件事,但我被困住了。該項目有 3,000 Nft 的免費 nft 用於白名單,但同時它將是 7,000 Nft 的公開發售。我該怎麼做才能使公成本售的總供應量不影響白名單,並且他們可以在沒有時間限制的情況下鑄造 3000?非常感謝您!

uint16 private constant MAX_SUPPLY = 10000; //Max Supply
uint16 private constant MAX_WHITELIST = 3000; //Whitelist PASS
uint16 private constant MAX_PUBLIC = 7000;   //PUBLIC PASS


uint8 private maxMintPerWhitelist = 3; 

function whitelistMint(uint8 _quantity, bytes32[] calldata merkleproof) external payable callerIsUser{

   require(sellingStep == Step.PublicSale, "Sale is not activated");
   require(isValid(merkleproof, keccak256(abi.encodePacked(msg.sender))),"Not in whitelist List");
   require(amountNFTsperWalletWhitelistSale[msg.sender] + _quantity <= maxMintPerWhitelist, "You can only get 3 NFT on the Whitelist Sale");
   require(totalSupply() + _quantity <= MAX_WHITELIST, "Max whitelist supply exceeded");
   require(msg.value >= wlSalePrice * _quantity, "Not enought funds");
   amountNFTsperWalletWhitelistSale[msg.sender] += _quantity;
   _safeMint(msg.sender, _quantity);
   }

function publicSaleMint(uint256 _quantity) external payable callerIsUser {
   require(sellingStep == Step.PublicSale, "Public sale is not  activated");
   require(totalSupply() + _quantity <= MAX_WHITELIST + MAX_PUBLIC, "Max supply exceeded");
   require(msg.value >= publicSalePrice * _quantity, "Not enought funds");
   _safeMint(msg.sender, _quantity);
}

如何修改我的智能合約以使 Whitelistmint 獨立於 publicmint 的總供應量?此刻,當總供應量將是 3.000 人在白名單上時,不能再造幣了。請幫忙!謝謝!

該問題將通過添加一個保存創建的白名單計數的變數來解決

uint16 private whitelistMinted; //Add this variable that saves the count of the NFTs that the people in whitelist minted

function whitelistMint(uint8 _quantity, bytes32[] calldata merkleproof) external payable callerIsUser{
   require(sellingStep == Step.PublicSale, "Sale is not activated");
   require(isValid(merkleproof, keccak256(abi.encodePacked(msg.sender))),"Not in whitelist List");
   require(amountNFTsperWalletWhitelistSale[msg.sender] + _quantity <= maxMintPerWhitelist, "You can only get 3 NFT on the Whitelist Sale");

   //change this line
   require(whitelistMinted + _quantity <= MAX_WHITELIST, "Max whitelist supply exceeded");

   require(msg.value >= wlSalePrice * _quantity, "Not enought funds");
   amountNFTsperWalletWhitelistSale[msg.sender] += _quantity;
   _safeMint(msg.sender, _quantity);

  //add this line
  whitelistMinted = whitelistMinted + _quantity
}

引用自:https://ethereum.stackexchange.com/questions/134133