I am unsure how to view my NFT on Opensea testnet. Really Confusing
I created an NFT using Solidity with Hardhard for testing and deployed it on the Polygon Mumbai Testnet.
I am able to deploy my NFT and then mint it with the URI which is metadata coming in from an IPFS Pinata pin address.
I am also able to add the token to my Metamask wallet and it shows.
But how can I view it on Opensea testnet?
I would like to test it on Opensea testnet to see how the image looks.
Opensea does not complain about it being an invalid address so the address is valid but for some reason it states:
We couldn't find this contract. Please ensure that this is a valid ERC721 or ERC1155 contract deployed on Mumbai and that you have already minted items on the contract.
Here is the error Opensea testnet gives me:
Do I have to somehow add it to the Matic mainnet?
If so then can someone point me in the right direction
I've seen some articles about using a sort of bridge but am still unclear on if that's the right path to solve my issue. None the less I will eventually have to post it upon the Matic Mainnet as well.
Below is the code and the outputs. I changed some things around for privacy issues (URI, Wallet address, Contract address)
Code
Here is my NFT.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract ScoreCoin is ERC721, Ownable {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenIds;
mapping(uint256 => string) private _tokenURIs;
constructor() ERC721("ScoreCoin", "SC") {
}
function _setTokenURI(uint256 tokenId, string memory _tokenURI)
internal
virtual
{
_tokenURIs[tokenId] = _tokenURI;
}
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];
return _tokenURI;
}
function mint(address recipient, string memory uri)
public
returns (uint256)
{
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, uri);
return newItemId;
}
}
Environment
I am using Hardhat version 2.3.0 to deploy my scripts.
Here is my deploy script
const hre = require("hardhat");
async function main() {
const NFT = await hre.ethers.getContractFactory("ScoreCoin");
const nft = await NFT.deploy();
await nft.deployed();
console.log("NFT deployed to:", nft.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Deploy Script Output:
NFT deployed to: 0xB57e1kA6kknknkbEEfe913Eb9E658Ak93cd4f
Here is my Mint script:
const hre = require("hardhat");
async function main() {
const NFT = await hre.ethers.getContractFactory("ScoreCoin");
const URI = "ipfs://QmUbUyEFbdjg7i4DjVFznza9CQSUbeWWnQarmiCpCjt2tKiPdC";
const WALLET_ADDRESS = "MY_WALLET_ADDRESS";
const CONTRACT_ADDRESS = "0xB57e1kA6kknknkbEEfe913Eb9E658Ak93cd4f";
const contract = NFT.attach(CONTRACT_ADDRESS);
await contract.mint(WALLET_ADDRESS, URI);
console.log("NFT minted:", contract);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Mint Script Output:
NFT minted: Contract {
interface: Interface {
fragments: [
I cut out the rest of the output above because I printed out the contract which showcases the events, interfaces, and functions.