Created
July 31, 2022 18:36
-
-
Save eftalyurtseven/b8687adc7a20453929030ef6575e4540 to your computer and use it in GitHub Desktop.
Awesome NFT minting contract file
This file contains 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
pragma solidity ^0.8.4; | |
import '@openzeppelin/contracts/token/ERC721/ERC721.sol'; | |
import '@openzeppelin/contracts/access/Ownable.sol'; | |
contract AwesomeNFTContract is ERC721, Ownable { | |
uint256 public mintPrice = 0.05 ether; | |
uint256 public totalSupply; | |
uint256 public maxSupply; | |
bool public isMintEnabled; | |
mapping(address => uint256) public mintedWallets; | |
constructor() payable ERC721("AWESOMENFT", "AWENFT") { | |
maxSupply = 2; | |
} | |
function toggleIsMintEnabled() external onlyOwner { | |
isMintEnabled = !isMintEnabled; | |
} | |
function setMaxSupply(uint256 maxSupply_) external onlyOwner { | |
maxSupply = maxSupply_; | |
} | |
function mint() external payable { | |
require(isMintEnabled, 'minting is not enabled for now!'); | |
require(mintedWallets[msg.sender] < 1, 'exceed max per wallet'); | |
require(msg.value == mintPrice, 'please send 0.05 ether!'); | |
require(maxSupply > totalSupply, 'sold out!'); | |
mintedWallets[msg.sender]++; | |
totalSupply++; | |
uint256 tokenId = totalSupply; | |
_safeMint(msg.sender, tokenId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment