-
-
Save rascode/56536774a8d239c0d5898be396d0ca4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contracts/GameItems.sol | |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.7; | |
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@openzeppelin/contracts/utils/Strings.sol"; | |
contract GameItems is ERC1155, Ownable { | |
uint256 public constant CHARIZARD = 0; | |
uint256 public constant IVYSAUR = 1; | |
uint256 public constant VENUSAUR = 2; | |
uint256 public constant CHARMANDER = 3; | |
mapping (uint256 => string) private _uris; | |
constructor() public ERC1155("https://bafybeihul6zsmbzyrgmjth3ynkmchepyvyhcwecn2yxc57ppqgpvr35zsq.ipfs.dweb.link/{id}.json") { | |
_mint(msg.sender, CHARIZARD, 100, ""); | |
_mint(msg.sender, IVYSAUR, 100, ""); | |
_mint(msg.sender, VENUSAUR, 100, ""); | |
_mint(msg.sender, CHARMANDER, 100, ""); | |
} | |
function uri(uint256 tokenId) override public view returns (string memory) { | |
return(_uris[tokenId]); | |
} | |
function setTokenUri(uint256 tokenId, string memory uri) public onlyOwner { | |
require(bytes(_uris[tokenId]).length == 0, "Cannot set uri twice"); | |
_uris[tokenId] = uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment