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.0+commit.c7dfd78e.js&optimize=false&runs=200&gist=
This file contains 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.0; | |
// import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/extensions/ERC1155Pausable.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol"; | |
contract DinisiumToken is ERC1155Pausable, Ownable { | |
uint256 public constant GOLD = 11; | |
uint256 public constant SILVER = 111; | |
uint256 public constant DOLLAR = 222; | |
event MintedTokens(address mintedOn, uint256 id, uint256 mintedTokens); | |
event BurnedTokens(address burnedBy,uint256 id, uint256 burnedTokens); | |
event PausedContract(address pauseddBy); | |
event UnpausedContract(address unpausedBy); | |
event SingleTokenTransfer(address from, address to, uint256 id, uint256 amount); | |
event BatchTokensTransfer(address from, address to, uint256[] ids, uint256[] amounts); | |
constructor() ERC1155("https://game.example/api/item/{id}.json") { | |
_mint(msg.sender, GOLD, 10**5, ""); | |
_mint(msg.sender, SILVER, 10**6, ""); | |
_mint(msg.sender, DOLLAR, 10**9, ""); | |
} | |
function increaseSupply (uint256 id, uint256 amount) onlyOwner external { | |
require (msg.sender != address(0), "Address is zero"); | |
_mint (msg.sender, id, amount, ""); | |
emit MintedTokens(msg.sender, id, amount); | |
} | |
function decreaseSupply (uint256 id, uint256 amount) whenNotPaused external { | |
require (msg.sender != address(0), "Address is zero"); | |
_burn(msg.sender, id, amount); | |
emit BurnedTokens(msg.sender, id, amount); | |
} | |
function transferSingle (address from, address to, uint256 id, uint256 amount) whenNotPaused external { | |
bytes memory data = '0x00'; | |
safeTransferFrom(from, to, id, amount, data); | |
emit SingleTokenTransfer(from, to, id, amount); | |
} | |
function transferBatch ( address from, address to, uint256[] memory ids, uint256[] memory amounts) whenNotPaused external { | |
bytes memory data = '0x00'; | |
safeBatchTransferFrom(from, to, ids, amounts, data); | |
emit BatchTokensTransfer(from, to, ids, amounts); | |
} | |
function singleBalance (address account, uint256 id) public view returns (uint256){ | |
return balanceOf(account, id); | |
} | |
function batchBalance (address[] memory accounts, uint256[] memory ids) public view returns (uint256[] memory){ | |
return balanceOfBatch(accounts, ids); | |
} | |
function pauseContract () public onlyOwner returns (bool status) { | |
_pause(); | |
emit PausedContract(msg.sender); | |
return true; | |
} | |
function unpauseContract () public onlyOwner returns (bool status) { | |
_unpause(); | |
emit UnpausedContract(msg.sender); | |
return true; | |
} | |
} | |
// address to send ; 0xed9d02e382b34818e88b88a309c7fe71e65f419d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment