Created
October 22, 2025 15:44
-
-
Save gwmccubbin/21645e0eed9a423510052c7c49225629 to your computer and use it in GitHub Desktop.
Simple Mint
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.20; | |
| import "@openzeppelin/contracts@5.0.2/token/ERC721/extensions/ERC721URIStorage.sol"; | |
| import "@openzeppelin/contracts@5.0.2/access/Ownable.sol"; | |
| // This contract is for educational demo purposes only. Do not put this on the mainnet. | |
| contract SimpleMintNFT is ERC721URIStorage, Ownable { | |
| uint256 private _nextId = 1; | |
| bool public mintingEnabled = true; | |
| constructor(string memory name_, string memory symbol_) | |
| ERC721(name_, symbol_) | |
| Ownable(msg.sender) | |
| {} | |
| function mint(string calldata tokenURI_) external returns (uint256 tokenId) { | |
| require(mintingEnabled, "Mint disabled"); | |
| tokenId = _nextId++; | |
| _safeMint(msg.sender, tokenId); | |
| _setTokenURI(tokenId, tokenURI_); | |
| } | |
| function setMintingEnabled(bool enabled) external onlyOwner { | |
| mintingEnabled = enabled; | |
| } | |
| function totalMinted() external view returns (uint256) { | |
| return _nextId - 1; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment