我从本教程中创建了一个非常基本的ERC1155令牌:
// contracts/GameItems.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
contract GameItems is ERC1155 {
uint256 public constant GOLD = 0;
uint256 public constant SILVER = 1;
uint256 public constant THORS_HAMMER = 2;
uint256 public constant SWORD = 3;
uint256 public constant SHIELD = 4;
constructor() public ERC1155("https://game.example/api/item/{id}.json") {
_mint(msg.sender, GOLD, 10**18, "");
_mint(msg.sender, SILVER, 10**27, "");
_mint(msg.sender, THORS_HAMMER, 1, "");
_mint(msg.sender, SWORD, 10**9, "");
_mint(msg.sender, SHIELD, 10**9, "");
}
}如您所见,在部署契约时创建了5个令牌。这5个令牌中的每个都与一个元数据文件相关联:
https://game.example/api/item/0000.....0001.json
https://game.example/api/item/0000.....0002.json
https://game.example/api/item/0000.....0003.json
https://game.example/api/item/0000.....0004.json
https://game.example/api/item/0000.....0005.json我想定制这5个urls。他们需要有很大的不同。有可能吗?我可以重写ERC1155函数,但我想要兼容ERC1155,以便保持令牌与市场位置的兼容。
谢谢
https://ethereum.stackexchange.com/questions/96931
复制相似问题