I created an ERC721 token on the Ethereum testnet (Rinkeby), a collection of 20 NFTs for now. I then proceeded to reserve some for myself so I could check it out on Opensea before deploying it to the Ethereum Mainnet. The tokens showed in my collection on Opensea but the images for them were not showing. I checked the CIDs for the images and json files and found them to be correct. The functions used to set the tokenURI are shown below.
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory _tokenURI = _tokenURIs[_tokenId];
if (revealState == false) {
return hiddenMetadataUri;
} else {
return _tokenURI;
}
}
function setTokenURI(uint256 _tokenId) public virtual onlyOwner{
require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');
uint img_no = _tokenId + 1;
string memory tokenid = Strings.toString(img_no);
string memory currentBaseURI = _baseURI();
string memory result = '';
if (bytes(currentBaseURI).length > 0) {
result = string(abi.encodePacked(currentBaseURI, tokenid, uriSuffix));
} else {
result = string(abi.encodePacked(tokenid, uriSuffix));
}
_tokenURIs[_tokenId] = result;
}
Any suggestions would be highly appreciated