0

I made NFT's, following this tutorial

I deployed the smart contract via Remix to my Metamask on the Rinkeby Testnet. OpenSea detected the assets in my wallet after they were minted, but the pictures and metadata in the json files was not there. Here is my smart contract:

pragma solidity ^ 0.8.10;

//import Open Zepplin contracts
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol";

contract NFT is ERC721 {
    uint256 private _tokenIds;
    
    constructor() ERC721("Name", "Symbol") {}
    
//use the mint function to create an NFT
    function mint() public returns (uint256) {
        _tokenIds += 1;
        _safeMint(msg.sender, _tokenIds);
        return _tokenIds;
    }
    
//in the function below include the CID of the JSON folder on IPFS
    function tokenURI(uint256 _tokenId) override public pure returns(string memory) {
        return string(
            abi.encodePacked(
                "ipfs://QmYiWynKnLwAPPEYdEhtPH5YhqKhq8wsnXZ6FKFBoi2G5t",
                Strings.toString(_tokenId),
                ".json"
            )
        );
    }
}

The ipfs URL contains the CID generated from the JSON files on Pinata. I am sure I did not use the jpeg CID. When I tried to debug my data via OpenSea's tool, I got the following:

HTTP 200 OK Allow: OPTIONS, GET Content-Type: application/json Vary: Accept

{ "valid": false, "token_uri": "https://ipfs.io/ipfs/QmYiWynKnLwAPPEYdEhtPH5YhqKhq8wsnXZ6FKFBoi2G5t/2.json", "errors": [ "TokenUrl404ResponseException: Received 404 response for: https://ipfs.io/ipfs/QmYiWynKnLwAPPEYdEhtPH5YhqKhq8wsnXZ6FKFBoi2G5t/2.json" ] } enter image description here

3 Answers 3

0

OpenSea sends the response "TokenUrl404ResponseException: Received 404 response for: https://ipfs.io/ipfs/QmYiWynKnLwAPPEYdEhtPH5YhqKhq8wsnXZ6FKFBoi2G5t/2.json" which means that it can't find that file.

If you paste the address in your browser you'll see that indeed the you can't access this link.

By removing the file name and going to the directory, you'll see that your file names are different - token number 2's file name is nft2.json. But your smart contract is returning "2.json" - that's a part of the problem.

But even if you would link to nft2.json, actually all the files in that directory are empty. So something also went wrong in your upload to IPFS.

7
  • Hi and thank you for replying. That URL was manually produced via OpenSea by manually entering my contract address and tokenID. At no point in my process did I go to IPFS and upload any data. Does that happen automatically? Or do I need to go to IPFS and upload it myself?
    – e n
    Dec 25, 2021 at 18:21
  • Depends what you want to do I guess... If you wanna do what probably most people do, yes you need to upload it yourself. What you would do is upload your metadata and images to IPFS (usually also using Pinata to make sure it's always available), set the IPFS metadata URI in your contract, then upload the contract as a collection (without specific token ID) to OpenSea. There might be ways to do it without uploading yourself that I'm not aware off. You can search for HashLips or Hustle Millenial videos on youtube for guides on how to do this. Dec 26, 2021 at 2:08
  • I followed a HashLips tutorial EXACTLY and still had the same problem. I had to fix a forward slash after the json CID in the smart contract. But I still cannot get the meta-data to appear on the open sea test net. Extremely frustraing. My current images are .jpg's with numbers scrawled in MS Paint with a blank white background. My JSON files are simple with name, description, and image with the CID from pinata as well. The smart contract mints the NFTs exactly as shown in the video, but open sea only shows a generic blank background with a gray image placeholder.
    – e n
    Dec 26, 2021 at 4:34
  • Is open sea test-net rejecting my images becasue they don't have layers?
    – e n
    Dec 26, 2021 at 4:34
  • It shouldn't be an issue of the layers. Sometimes OpenSea takes some time to update the images though. When you run your json metadata from the HashLips tutorial in OpenSea's tool, do you still get "valid": false? + Are you able to see the images from the .json in ipfs when you put it in the browser? Cause as I mentioned above in your original scenario both problems are there. Dec 26, 2021 at 5:42
0

man you are missing a slash /

pragma solidity ^ 0.8.10;

//import Open Zepplin contracts
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol"; 
contract NFT is ERC721 {
    uint256 private _tokenIds;
    
    constructor() ERC721("Name", "Symbol") {}
    
//use the mint function to create an NFT
    function mint() public returns (uint256) {
        _tokenIds += 1;
        _safeMint(msg.sender, _tokenIds);
        return _tokenIds;
    }
    
//in the function below include the CID of the JSON folder on IPFS
    function tokenURI(uint256 _tokenId) override public pure returns(string memory) {
        return string(
            abi.encodePacked(
                "ipfs://QmYiWynKnLwAPPEYdEhtPH5YhqKhq8wsnXZ6FKFBoi2G5t/",
                Strings.toString(_tokenId),
                ".json"
            )
        );
    }
}

ipfs://QmYiWynKnLwAPPEYdEhtPH5YhqKhq8wsnXZ6FKFBoi2G5t/0.json now uri will come correct

0

OpenSea seems to have issue parsing the .json extension. Try uploading without the extension, i.e. CID/1 instead of CID/1.json. Also, tokenURI needs a slash as mentioned in some of the other answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.