简体   繁体   English

ERC721 NFT 未在 opensea 中显示(与元数据相关)

[英]ERC721 NFT not showing in opensea (related to the metadata)

I was creating the DApp and succeeded to mint NFT in Rinkeby using IPFS (pinata) & Nethereum (C#).我正在创建 DApp 并成功使用 IPFS (pinata) 和 Nethereum (C#) 在 Rinkeby 中铸造 NFT。

Now, I can get TokenURI using tokenURI function in ERC721URIStorage.sol, like ipfs://QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq .现在,我可以在 ERC721URIStorage.sol 中使用 tokenURI function 获取 TokenURI,例如ipfs://QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq

Below is link of the metadata about same NFT.以下是有关相同 NFT 的元数据的链接。 ( https://ipfs.io/ipfs/QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq ) https://ipfs.io/ipfs/QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq

But, in opensea testnet, I can't see the information about my NFT.但是,在 opensea 测试网中,我看不到有关我的 NFT 的信息。 (I can see my NFT, but there is no image, name, description, and so on..) (我可以看到我的 NFT,但是没有图像、名称、描述等..)

To solve this problem, I checked if my contract is valid or not in https://testnets-api.opensea.io/asset/0x1770A249C9743F1493C55fE505BC17beAB772cD5/4/validate/ .为了解决这个问题,我在https://testnets-api.opensea.io/asset/0x1770A249C9743F1493C55fE505BC17beAB772cD5/4/validate/中检查了我的合同是否有效。 There is some error: "AttributeError: 'str' object has no attribute 'get'", but I don't know what it is..有一些错误:“AttributeError: 'str' object has no attribute 'get'”,但我不知道它是什么..

Even though I can get TokenURI, why doesn't opensea?即使我可以得到 TokenURI,为什么没有 opensea? In this docs ( https://docs.opensea.io/docs/metadata-standards ), they say if I want to use IPFS to host my metadata, URL should be in the format ipfs:// (like ipfs://QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq .) I followed that, but it doesn't work.在这个文档( https://docs.opensea.io/docs/metadata-standards )中,他们说如果我想使用 IPFS 来托管我的元数据,URL 应该采用 ipfs:// 格式(如ipfs://QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq 。)我跟着那个,但它不起作用。

Oh, I find that my json in ipfs is not a json, because it is surrounded with "".哦,我发现我ipfs中的json不是json,因为是用""包围的。

It means that opensea will fail to get something from my metadata because it is string.这意味着 opensea 将无法从我的元数据中获取某些内容,因为它是字符串。

I used another sample metadata ( https://ipfs.io/ipfs/bafybeibnsoufr2renqzsh347nrx54wcubt5lgkeivez63xvivplfwhtpym/metadata.json ) which is not mine, and it worked very well!我使用了另一个示例元数据( https://ipfs.io/ipfs/bafybeibnsoufr2renqzsh347nrx54wcubt5lgkeivez63xvivplfwhtpym/metadata.json ),它不是我的,而且效果很好!

Therefore, I have to fix the code for uploading metadata to ipfs.因此,我必须修复将元数据上传到 ipfs 的代码。

I have not solved the problem completely, but I find the cause, so I will quit this question.我还没有完全解决问题,但是我找到了原因,所以我将退出这个问题。 After I solve this problem, I will post again.解决这个问题后,我会再次发布。

just put this in smart contract tada its solved只需将其放入智能合约 tada 即可解决



function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, Strings.toString(tokenId),".json")) : "";
    }```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM