创建 ERC1155 代币 - 似乎是 opensea 上的元数据问题

发布于 2025-01-10 13:51:51 字数 1600 浏览 0 评论 0原文

我尝试创建标准 ERC1155 合约,如下所示:

contract Bbum is ERC1155, Ownable {
    uint256 public constant GOLD = 0;
    uint256 public constant THORS_HAMMER = 1;
    uint256 tokenCounter = 0;
    mapping(uint256 => string) private _uris;

//root uri with the specific for each token id
constructor()
    ERC1155(
        "https://gateway.pinata.cloud/ipfs/QmWAcb89p9kiELQQ36px9PSErVE97FVqSTBNpCWtB5WzxB/{id}.json"
    )
{
    _mint(msg.sender, GOLD, 5, "");
    _mint(msg.sender, THORS_HAMMER, 3, "");
    tokenCounter = 1;
}

function setURI(string memory newuri) public onlyOwner {
    _setURI(newuri);
}

function mint(
    address account,
    uint256 id,
    uint256 amount,
    bytes memory data
) public onlyOwner {
    _mint(account, id, amount, data);
}

function mintBatch(
    address to,
    uint256[] memory ids,
    uint256[] memory amounts,
    bytes memory data
) public onlyOwner {
    _mintBatch(to, ids, amounts, data);
}

}

在使用元数据部署它后,出现错误。我知道可能需要重写 uri 函数或类似的东西。

两个令牌的元数据:

{
"name": "Backgammon",
"description": "An Amazing Backgammon board!",
"image": "ipfs://QmTh7fEL3iMfBfBwCTwsJzy9HodcNrxqBtWoSDkuMpHcFG?filename=Backgammon.png",
"attributes": [
    {
        "trait_type": "kind",
        "value": 100
    }
]

}

第二个

{
"name": "Spades",
"description": "An Amazing cards game!",
"image": "https://ipfs.io/ipfs/QmWfUiKjJYPs67jAycxYq8c8cJSPq31v1wLRhMcNbvaqDe?filename=spade.png",
"attributes": [
    {
        "trait_type": "card rarity",
        "value": 1
    }
]

}

Im trying to create standard ERC1155 contract like the follow:

contract Bbum is ERC1155, Ownable {
    uint256 public constant GOLD = 0;
    uint256 public constant THORS_HAMMER = 1;
    uint256 tokenCounter = 0;
    mapping(uint256 => string) private _uris;

//root uri with the specific for each token id
constructor()
    ERC1155(
        "https://gateway.pinata.cloud/ipfs/QmWAcb89p9kiELQQ36px9PSErVE97FVqSTBNpCWtB5WzxB/{id}.json"
    )
{
    _mint(msg.sender, GOLD, 5, "");
    _mint(msg.sender, THORS_HAMMER, 3, "");
    tokenCounter = 1;
}

function setURI(string memory newuri) public onlyOwner {
    _setURI(newuri);
}

function mint(
    address account,
    uint256 id,
    uint256 amount,
    bytes memory data
) public onlyOwner {
    _mint(account, id, amount, data);
}

function mintBatch(
    address to,
    uint256[] memory ids,
    uint256[] memory amounts,
    bytes memory data
) public onlyOwner {
    _mintBatch(to, ids, amounts, data);
}

}

after I deploy it with the metadata there is an error. I understood there can be a need to override the uri function or somthing like that.

metadata of the two tokens:

{
"name": "Backgammon",
"description": "An Amazing Backgammon board!",
"image": "ipfs://QmTh7fEL3iMfBfBwCTwsJzy9HodcNrxqBtWoSDkuMpHcFG?filename=Backgammon.png",
"attributes": [
    {
        "trait_type": "kind",
        "value": 100
    }
]

}

second one

{
"name": "Spades",
"description": "An Amazing cards game!",
"image": "https://ipfs.io/ipfs/QmWfUiKjJYPs67jAycxYq8c8cJSPq31v1wLRhMcNbvaqDe?filename=spade.png",
"attributes": [
    {
        "trait_type": "card rarity",
        "value": 1
    }
]

}

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文