-
-
Save AlbertLin0327/938e196c980c9717678aa61740f93e4f to your computer and use it in GitHub Desktop.
Smart Contract whitelist implementation with primitive storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.11; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract PrimitiveWhiteList is ERC721Enumerable, Ownable { | |
uint256 public constant MINT_PRICE = 0.1 ether; | |
mapping(address => bool) public whitelist; | |
constructor() ERC721("Primitive Whitelist", "PW") {} | |
function whitelistMint(uint256 amount) external payable { | |
require(msg.value == amount * MINT_PRICE, "Ether send below price"); | |
require(whitelist[msg.sender], "Not in whitelist"); | |
// start minting | |
uint256 currentSupply = totalSupply(); | |
for (uint256 i = 1; i <= amount; i++) { | |
_safeMint(msg.sender, currentSupply + i); | |
} | |
} | |
function addWhitelist(address _newEntry) external onlyOwner { | |
whitelist[_newEntry] = true; | |
} | |
function removeWhitelist(address _newEntry) external onlyOwner { | |
require(whitelist[_newEntry], "Previous not in whitelist"); | |
whitelist[_newEntry] = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment