I built an ERC721 smart contract and successfully minted 10 NFTs on the Polygon network. The artwork files are hosted on my personal server instead of using IPFS. I also set up the proper JSON metadata structure for each token.
The contract deployment and minting process worked fine through Remix IDE. However, I’m facing an issue where the NFT images don’t appear anywhere - not in my MetaMask wallet when I import the token address, not on PolygonScan block explorer, and not on OpenSea marketplace either.
Here’s my contract code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract DigitalArtV2 is ERC721URIStorage, Ownable {
uint256 public tokenCounter;
uint256 public constant TOTAL_SUPPLY = 10;
string public metadataBaseURI;
event TokenCreated(address indexed owner, uint256 tokenId, string metadataURI);
constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) Ownable(msg.sender) {
metadataBaseURI = "https://192.168.1.100/metadata/";
}
function createToken(address _recipient) external onlyOwner {
require(_recipient != address(0), "Invalid recipient address");
require(tokenCounter < TOTAL_SUPPLY, "All tokens have been minted");
uint256 nextTokenId = ++tokenCounter;
_safeMint(_recipient, nextTokenId);
string memory metadataURI = string(abi.encodePacked(metadataBaseURI, Strings.toString(nextTokenId), ".json"));
_setTokenURI(nextTokenId, metadataURI);
emit TokenCreated(_recipient, nextTokenId, metadataURI);
}
function updateBaseURI(string memory _newBaseURI) external onlyOwner {
require(bytes(_newBaseURI).length > 0, "URI cannot be empty");
metadataBaseURI = _newBaseURI;
}
function _baseURI() internal view virtual override returns (string memory) {
return metadataBaseURI;
}
receive() external payable {}
fallback() external payable {}
}
Any ideas what might be causing this? I expected the NFT images to be visible across all these platforms but I only see generic placeholder icons instead.