Metadata integration with OpenSea

Hi,

I have an issue with metadata. I am using Openzeppelin ERC 721 preset, complied and deployed the contract via Remix to Rinkeby and want to see it in testnet on OpenSea.
I established a IPFS folder with metadata files 0.json, 1.json etc.; next, I minted token with tokenURI “ipfs://-CID-/0”; however I cannot see this on a testnet validate check which throws me an error: “TokenUrl404ResponseException: Received 404 response for: https://ipfs.io/ipfs/-CID-/0”. I am using OpenSea metadata standard.
When I click on the ipfs link, it says: “ipfs resolve -r /ipfs/-CID-/0: no link named “0” under -CID-”

Can you please help me how to resolve this one?

Thanks!

P.

Hi @SolidityDevPrague,

If you have a directory uploaded to IPFS, each file should be 0, 1 etc with no extension.

Your baseURI can be ipfs://[IPFS Hash]/ and then your token URI for token ID 0 is ipfs://[IPFS Hash]/0

See my example:
ipfs://QmUm25XMSnUvxvi7XE9Xr8XwRdkNosmTDyKDDyxMajjytv/0

1 Like

Hi @abcoathup , thanks for a quick reply!

When I tried that (I removed the “.json” so that only 0, 1, … remains in the name of the files) and I created new contract and minted new token, I received this error: "TokenUrlTimedOutException: " and when opening the IPFS link itself, it does not load.

Any thoughts on what I might be doing wrong welcomed! I minted some tokens, but this is the first time with metadata, so might be an amateur mistake.

Hi @SolidityDevPrague,

Try creating a simple ERC721 (you can use Contracts Wizard https://zpl.in/wizard) and then you can iterate from there with your own metadata.

Set the baseURI to: ipfs://QmUm25XMSnUvxvi7XE9Xr8XwRdkNosmTDyKDDyxMajjytv//
Mint a token and try to view on OpenSea.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

contract MyToken is ERC721, AccessControl {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    constructor() ERC721("MyToken", "MTK") {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(MINTER_ROLE, msg.sender);
    }

    function safeMint(address to, uint256 tokenId) public {
        require(hasRole(MINTER_ROLE, msg.sender));
        _safeMint(to, tokenId);
    }

    function _baseURI() internal pure override returns (string memory) {
        return "ipfs://QmUm25XMSnUvxvi7XE9Xr8XwRdkNosmTDyKDDyxMajjytv/";
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, AccessControl)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}
1 Like

Thank you @abcoathup !

I still cannot see the metadata there, but at least I got a different error :smiley:

When checking validation, I get: “InvalidTokenUrlResponseException: Invalid JSON response for URL: https://ipfs.io/ipfs/-CID-/0”.
However, I can open the link and I see the json file.

What do you think I am doing wrong?

Thanks, P.

Can the issue be with the way I constructed the file?
MS Notepad where I put the JSON structure as a pure text, saved it as All files and changes the name to 0.json. Windows got that this is JSON file and labeled it like that. Later, after uploading to IPFS, I changed the name back to 0

Hi @SolidityDevPrague,

You need to remove the extension before uploading to IPFS.

Can you share your JSON in the following format, where it is ipfs://[IPFS Hash of the directory]/[token ID]?
e.g. ipfs://QmUm25XMSnUvxvi7XE9Xr8XwRdkNosmTDyKDDyxMajjytv/0

Using the Brave browser you can open that IPFS link.

Hi @abcoathup , thanks!
It started working after a while. If there would be a rookie looking for the same issue, 2 things helped me to get this working - 1) wait a bit, couple of minutes, it takes time IPFS to be reflected in the opensea; 2) click Refresh metadata on OpenSea and wait a bit again.

So @abcoathup your advice was good, just me doing it for the first time was doing it wrong.

1 Like

Hi @SolidityDevPrague,

Glad to help. Good luck with your project.

Hello abcoathup,

Thank you for your sharing.
I am facing the same problem recently.
But I couldn't load mine without the extension.
ipfs://QmfBpV3eA6TK3JU12MCgqmcHgVUWhu5cLurkwL2Fqsfnb8/1.jpg
ipfs://QmNy7m6KVrw1sBaErq6Y8yPm4yDuQ7DnDzcm2MXrDDo4rZ/test.json

The image and metadata file have been uploaded to IPFS Desktop.
May I have your suggestions?
Thank you,
Ankko

For me, it was because the Closing Brace in my JSON file on IPFS was one space too much to the right.

Something that could help is to use vscode to autoformat it for you or you can install a JSON formatter extension.

It formats the JSON I am viewing and gives color to it. It was showing grey for me so once I noticed that and found the extra space for the closing bracket and fixed it - it showed as colored formatted json.

After that Opensea was reading it correctly. SO MAKE SURE YOUR JSON FILE IS CORRECTLY FORMATTED - EVEN THE OPENING/CLOSING BRACES.

Hope this helps :slight_smile: Cheers !

2 Likes

Hmm, aren't drafts saved?

Wrote an important and cool sheet with nuances, tips and non-obvious features ...

And he "buzzed" and made "empty in the field, do you want to enter the card number in the form?" ...

Um, it's bad, very bad. It's not cool if the text disappears like that, which I don't want to write for the second time, well, guys! ; ((

I subscribed to the post. I'll rewrite it later, maybe again. If there's a reason, I'll drop it.

But briefly - without validation from opensea - bad, bad and everyone doesn't understand you.

Royalties and other specifications are better to sharpen for all the point nuances of each of the popular popular ones at once: opensea, rarible, foundation.

Then I'll write how and what kind of nuances when using each one.

Here.

And, yes, the cached opensea layer is an Internet addiction (total. In the world of all Internets,... yeah. Do you know?) From Cloudflare servers. That's how nft depends on cached content and api opensea. It can be criticized, rejoiced... taken or not taken seriously, but it's a fact. This is not such an "unimportance" thing that can be ignored if you want to stop "showing" very quickly, if you can't ignore various other tools in different DeFi wallets / marketplaces / muzzles.

There are such short but important features of "nucks" and features (in order not to leave a completely "useless" comment, I wrote the most important short).

Ru:
Хм, а черновики не сохраняются?

Написал важный и классный листок с нюансами, советами и неочевидными особенностями ...

И он "гудел" и сделал "пустое в поле, вы хотите ввести номер карты в форму?" ...

Эм, это плохо, очень плохо. Это не круто, если так пропадает текст, который потом второй раз писать не хочется, ну ребята! ; ((

Я подписался на пост. Позже перепишу, возможно, заново. Если будет повод, закину.

Но коротко - без валидации от opensea - плохо-плохо и все тебя не понимают.

Роялти и прочие спецификации лучше сразу под все точечные нюансы каждой из популярных популярных заточить: opensea, rarible, foundation.

Потом напишу как и что за нюансы при использовании каждой.

Вот.

И, да, кэшированный слой opensea - это зависимость интернета (всего. В мире всех интернетов,… ага. Вы в курсе?) От серверов Cloudflare. Вот так nft зависит от кэшированного контента и api opensea. Это можно критиковать, радоваться… принимать или не принимать всерьез, но это - факт. Это не такое «не важное» что-то, что можно игнорировать, если ты хочешь очень быстро перестать «показать», если ты не можешь игнорировать в разных там в DeFi кошельках / маркетплейсах / мордах различных еще других инструментов.

Есть такие вот короткие, но важные особенности «нюкнсы» и особенности (чтобы совсем «бесполезный» комментарий не оставлять, написал самое важное коротко).