Answers for "how to do a reveal for metadata with IPFS on an nft"

0

how to do a reveal for metadata with IPFS on an nft

// I put this as javascript syntax hylighting because it is simular to solidity
	using Counters for Counters.Counter;
    Counters.Counter internal _tokenIds; // from openzeppelin

	string private baseURIcid;

    function setBaseURIcid(string memory cid) public onlyOwner {
        baseURIcid = cid;
    }

    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        return bytes(baseURIcid).length > 0 ? 
        string(abi.encodePacked("ipfs://", baseURIcid, "/", tokenId.toString(), ".json")) : 
        "ipfs:// some other ipfs CID with the temperary uri";
    }
Posted by: Guest on October-01-2021

Code answers related to "how to do a reveal for metadata with IPFS on an nft"

Code answers related to "Javascript"

Browse Popular Code Answers by Language