Skip to content

Instantly share code, notes, and snippets.

@jakzaizzat
Created August 17, 2022 09:34
Show Gist options
  • Save jakzaizzat/d07de3d5c1e354b1cb9b03ed47245b66 to your computer and use it in GitHub Desktop.
Save jakzaizzat/d07de3d5c1e354b1cb9b03ed47245b66 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.7.3/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts@4.7.3/access/Ownable.sol";
import "@openzeppelin/contracts@4.7.3/security/Pausable.sol";
import "@openzeppelin/contracts@4.7.3/token/ERC1155/extensions/ERC1155Supply.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract TRT is ERC1155, Ownable, Pausable, ERC1155Supply {
mapping (uint256 => string) private _uris;
constructor() ERC1155("https://live---metadata-5covpqijaa-uc.a.run.app/metadata/{id}.json") {
_mint(msg.sender, 0, 1, "");
_mint(msg.sender, 1, 1, "");
_mint(msg.sender, 2, 1, "");
}
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
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);
}
function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
internal
whenNotPaused
override(ERC1155, ERC1155Supply)
{
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
function uri(uint256 tokenId) override public pure returns (string memory) {
return (
string(abi.encodePacked(
"https://live---metadata-5covpqijaa-uc.a.run.app/metadata/",
Strings.toString(tokenId)
))
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment