Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prtk418/9eed7b9c2d5826033ffb0c3f9921d09f to your computer and use it in GitHub Desktop.
Save prtk418/9eed7b9c2d5826033ffb0c3f9921d09f 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 "forsale"
mapping (string => bool) public forSale;
constructor(string memory assetForSale) public ERC721(NAME, SYMBOL) {
forSale[assetForSale] = true;
}
function mintItem(string memory tokenURI) external returns (uint256) {
// only "forsale" items are up for minting
require(forSale[tokenURI],"NOT FOR SALE");
forSale[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