Created
February 14, 2022 01:29
-
-
Save AtotheY/6912e873277e812459a39291ed75ccf1 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
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 SimpleMint 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('EZ mint', 'EZMINT') { | |
maxSupply = 10; | |
} | |
function toggleIsMintenabled() external onlyOwner { | |
isMintEnabled = !isMintEnabled; | |
} | |
function setMaxSupply(uint256 maxSupply_) external onlyOwner{ | |
maxSupply = maxSupply_; | |
} | |
function mint() external payable { | |
require(isMintEnabled, 'minting not enabled'); | |
require(mintedWallets[msg.sender] < 1, 'exceeds max per wallet'); | |
require(msg.value == mintPrice, 'wrong value'); | |
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