Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prtk418/f456e2501fbdb8d5694ce22afc5dc727 to your computer and use it in GitHub Desktop.
Save prtk418/f456e2501fbdb8d5694ce22afc5dc727 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.7.0+commit.9e61f92b.js&optimize=false&runs=200&gist=
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract YourCollectible is ERC721URIStorage {
string NAME = "Abstract Collectibles";
string SYMBOL = "ABS";
uint256 private _tokenId = 1;
// this marks an item as available for minting
mapping (string => bool) public notMinted;
constructor(string memory assetForSale) public ERC721(NAME, SYMBOL) {
notMinted[assetForSale] = true;
}
function mintItem(string memory tokenURI) external returns (uint256) {
// only "notMinted" items are up for minting
require(notMinted[tokenURI],"NOT FOR SALE");
notMinted[tokenURI] = false;
_mint(msg.sender, _tokenId);
// set tokenURI for plugging in our metadata to NFT
_setTokenURI(_tokenId, tokenURI);
return _tokenId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment