0 ? string(abi.encodePacked(ipfsBaseURI, tokenId.toString(), ".json")) : ""; } }"> 0 ? string(abi.encodePacked(ipfsBaseURI, tokenId.toString(), ".json")) : ""; } }"> 0 ? string(abi.encodePacked(ipfsBaseURI, tokenId.toString(), ".json")) : ""; } }">
// SPDX-License-Identifier: MIT
pragma solidity 0.8.12;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract ProjectNFT is ERC721 {
uint256 private totalSupply;
string private ipfsBaseURI;
constructor(string memory _name, string memory _symbol, string memory baseURI)
ERC721(_name, _symbol) {
ipfsBaseURI = baseURI;
}
function mint() public {
totalSupply++;
_safeMint(msg.sender, totalSupply);
}
function _baseURI() internal view override returns (string memory) {
return ipfsBaseURI;
}
//In order to see the unique uri of the NFT
//return uri for certain token
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "Nonexistent token");
return bytes(ipfsBaseURI).length > 0 ? string(abi.encodePacked(ipfsBaseURI, tokenId.toString(), ".json")) : "";
}
}