Problems with NFT visibility on OpenSea testnet
I’ve successfully deployed my code on the Rinkeby network, and it functions as expected. However, the images and descriptions of my NFTs aren’t visible on the OpenSea testnet. When I checked the validation URL, it returned Valid: "false".
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract MyCollection is ERC721URIStorage, Ownable {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenCounter;
event NewNFTMinted(address owner, uint256 tokenId);
uint256 public presalePrice = 0.01 ether;
uint256 public publicSalePrice = 0.02 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintablePerUser = 10;
string public baseMetadataURI;
string public unexposedMetadataURI;
bool public mintingPaused = false;
bool public isRevealed = true;
address payable public admin = payable(0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2);
constructor(string memory name, string memory symbol, string memory initialBaseURI, string memory hiddenURI)
ERC721(name, symbol) {
setBaseURI(initialBaseURI);
setUnvealedURI(hiddenURI);
}
function setBaseURI(string memory newBaseURI) public onlyOwner {
baseMetadataURI = newBaseURI;
}
function mintNFT() public payable {
uint256 tokenId = _tokenCounter.current();
require(!mintingPaused, "Minting is currently paused");
require(msg.value >= publicSalePrice, string(abi.encodePacked("Must send at least ", publicSalePrice.toString(), " ether to mint")));
require(balanceOf(msg.sender) < maxMintablePerUser, "You can only mint a limited number of NFTs");
payable(admin).transfer(msg.value);
emit NewNFTMinted(msg.sender, tokenId);
_safeMint(msg.sender, tokenId);
_tokenCounter.increment();
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "Token does not exist");
if(!isRevealed) {
return unexposedMetadataURI;
}
string memory baseURI = baseMetadataURI;
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: "";
}
}
Here’s a link to one of the NFTs I minted: NFT Link
My IPFS CID is: ipfs://QmaoMZ19zhpC6T4id6jdBP1Qz5dQSmRZMkQZU7Zt8hyFNQ/
Has anyone else faced issues with OpenSea not displaying NFT metadata correctly? What could be causing the validation error?