ERC721 NFT在Opensea中未显示(与元数据有关)

发布于 2025-01-27 04:56:05 字数 1172 浏览 3 评论 0 原文

我正在创建DAPP,并成功地使用IPFS(Pinata)& nethereum(C#)。

现在,我可以在erc721uristorage.sol中使用tokenuri函数获得tokenuri,例如 ipfs:// qmrh9pttads3bcqmlqxeamp83foaemd83foaemd8cukngtxz5hktlq

以下是元数据的链接大约相同的NFT。 (

但是,在opensea testnet中,我可以' t请参阅有关我的NFT的信息。 (我可以看到我的nft,但是没有图像,名称,描述等等..)

要解决此问题,我检查了我的合同是否有效https://testnets-api.opensea.io/asset/0x1770A249C9743F1493C55fE505BC17beAB772cD5/4/validate/.有一些错误:“ attributeError:'str'对象没有属性'get'”,但是我不知道它是什么。

即使我可以得到tokenuri,为什么不opensea?在此文档中( https://docs.opensea.io/docs/docs/metadata-standard- >),他们说,如果我想使用IPF托管我的元数据,则URL应该以IPFS://的格式(例如 ipfs:// qmrh9pttads3bcqmlqxeamp83foaeamd83foaeamd8cukngtxzz5hktlq 。)工作。

I was creating the DApp and succeeded to mint NFT in Rinkeby using IPFS (pinata) & Nethereum (C#).

Now, I can get TokenURI using tokenURI function in ERC721URIStorage.sol, like ipfs://QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq.

Below is link of the metadata about same NFT.
(https://ipfs.io/ipfs/QmRH9pTTADs3BCqMLqXEAMP83FoaeMD8CUkNgtxZ5HKTLq)

But, in opensea testnet, I can't see the information about my NFT. (I can see my NFT, but there is no image, name, description, and so on..)

To solve this problem, I checked if my contract is valid or not in 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..

Even though I can get TokenURI, why doesn't 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久光 2025-02-03 04:56:05

哦,我发现我在IPFS中的JSON不是JSON,因为它被“”包围。

这意味着Opensea将无法从我的元数据中获得一些东西,因为它是字符串。

我使用了另一个样品元数据()不是我的,而且效果很好!

因此,我必须修复将元数据上传到IPF的代码。

我尚未完全解决问题,但我找到了原因,所以我会退出这个问题。解决此问题后,我将再次发布。

Oh, I find that my json in ipfs is not a json, because it is surrounded with "".

It means that opensea will fail to get something from my metadata because it is string.

I used another sample metadata (https://ipfs.io/ipfs/bafybeibnsoufr2renqzsh347nrx54wcubt5lgkeivez63xvivplfwhtpym/metadata.json) which is not mine, and it worked very well!

Therefore, I have to fix the code for uploading metadata to 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.

穿透光 2025-02-03 04:56:05

只需将其放在智能合同中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")) : "";
    }```

just put this in smart contract tada its solved



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")) : "";
    }```
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文