Created
April 7, 2022 12:17
-
-
Save Rahat-ch/1fcddce55f02519d23b2f405f60c0a6f to your computer and use it in GitHub Desktop.
Revisions
-
Rahat-ch created this gist
Apr 7, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract MetaDataNFT is ERC721URIStorage { using Counters for Counters.Counter; Counters.Counter private _tokenIds; mapping (address => uint256) public mintTracker; constructor() ERC721("MetaDataNFTV2", "MDNFT2") {} function mint(string memory tokenURI) public returns (uint256){ if(mintTracker[msg.sender] > 0){ require(block.timestamp >= mintTracker[msg.sender], "Please wait 24 hours before minting again"); } uint256 slowdown = block.timestamp + 1 days; _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _safeMint(msg.sender, newItemId); _setTokenURI(newItemId, tokenURI); mintTracker[msg.sender] = slowdown; return newItemId; } }