I’m currently creating NFTs using an ERC721 smart contract and encountered a frustrating issue with OpenSea. My contract is based on OpenZeppelin and it works fine for both minting and transferring NFTs.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.6.0/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts@4.6.0/utils/Counters.sol";
contract PIXELS is ERC721, ERC721Enumerable, ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _idTracker;
uint256 TOTAL_LIMIT = 3000;
constructor() ERC721("PIXELS", "PXL") {}
function createToken(address recipient, string memory tokenUri) public {
uint256 newId = _idTracker.current();
require(newId <= TOTAL_LIMIT, "Maximum tokens reached!");
_idTracker.increment();
_safeMint(recipient, newId);
_setTokenURI(newId, tokenUri);
}
function _beforeTokenTransfer(address sender, address receiver, uint256 id)
internal
override(ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(sender, receiver, id);
}
function _burn(uint256 id) internal override(ERC721, ERC721URIStorage) {
super._burn(id);
}
function tokenURI(uint256 id)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(id);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
Here’s what happened: I successfully minted two NFTs and they appeared in my OpenSea testnet account. After that, I transferred one NFT (token ID 1) to another wallet using the safeTransferFrom function. The blockchain confirmed that the transfer was successful and shows that the new address owns the token. However, when I check OpenSea, the NFT has vanished from my collected items, and it doesn’t appear in the new owner’s account either. Only the NFT that I didn’t transfer (ID 0) is still visible in my collection. Has anyone else experienced this issue?