Skip to content

Instantly share code, notes, and snippets.

@Chmarusso
Created October 18, 2021 19:56
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save Chmarusso/3a86960f7d7db8cf99180b807788e79f to your computer and use it in GitHub Desktop.
Save Chmarusso/3a86960f7d7db8cf99180b807788e79f to your computer and use it in GitHub Desktop.
// 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;
}
}
@itsanishjain
Copy link

There might be issue metadata is not showing on opensea
https://testnets.opensea.io/collection/unidentified-contract-xfxdvbl2at

@wahajhaider21
Copy link

@itsanishjain you need to verify the contract aswell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment