I deployed an ERC721 smart contract on Polygon to create 10 NFTs. The artwork files are hosted on my personal server instead of IPFS. I also set up the metadata JSON files properly.
I used Remix to compile and deploy everything to Polygon network. The minting process worked fine, but the actual images don’t appear anywhere. They’re missing from MetaMask when I import the token address, missing from PolygonScan, and missing from OpenSea too.
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://45.67.89.123/metadata/";
}
function createToken(address owner) external onlyOwner {
require(owner != address(0), "Invalid owner address");
require(tokenCounter < TOTAL_SUPPLY, "All tokens minted");
uint256 tokenId = ++tokenCounter;
_safeMint(owner, tokenId);
string memory metadataURI = string(abi.encodePacked(metadataBaseURI, Strings.toString(tokenId), ".json"));
_setTokenURI(tokenId, metadataURI);
emit TokenCreated(owner, tokenId, metadataURI);
}
function updateBaseURI(string memory newURI) external onlyOwner {
require(bytes(newURI).length > 0, "URI cannot be empty");
metadataBaseURI = newURI;
}
function _baseURI() internal view virtual override returns (string memory) {
return metadataBaseURI;
}
receive() external payable {}
fallback() external payable {}
}
Anyone know what might be wrong? I want the images to show up properly in wallets and marketplaces instead of just placeholder icons.