Skip to content

Instantly share code, notes, and snippets.

@gwmccubbin
Created October 22, 2025 15:44
Show Gist options
  • Select an option

  • Save gwmccubbin/21645e0eed9a423510052c7c49225629 to your computer and use it in GitHub Desktop.

Select an option

Save gwmccubbin/21645e0eed9a423510052c7c49225629 to your computer and use it in GitHub Desktop.
Simple Mint
// 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