|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +// Amended by HashLips |
| 4 | +/** |
| 5 | + !Disclaimer! |
| 6 | + |
| 7 | + These contracts have been used to create tutorials, |
| 8 | + and was created for the purpose to teach people |
| 9 | + how to create smart contracts on the blockchain. |
| 10 | + please review this code on your own before using any of |
| 11 | + the following code for production. |
| 12 | + The developer will not be responsible or liable for all loss or |
| 13 | + damage whatsoever caused by you participating in any way in the |
| 14 | + experimental code, whether putting money into the contract or |
| 15 | + using the code for your own project. |
| 16 | +*/ |
| 17 | + |
| 18 | +pragma solidity ^0.8.0; |
| 19 | + |
| 20 | +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol"; |
| 21 | +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol"; |
| 22 | + |
| 23 | +contract NFT1155 is ERC1155, Ownable { |
| 24 | + |
| 25 | + string public name; |
| 26 | + string public symbol; |
| 27 | + |
| 28 | + mapping(uint => string) public tokenURI; |
| 29 | + |
| 30 | + constructor() ERC1155("") { |
| 31 | + name = "HashItems"; |
| 32 | + symbol = "HASHITEMS"; |
| 33 | + } |
| 34 | + |
| 35 | + function mint(address _to, uint _id, uint _amount) external onlyOwner { |
| 36 | + _mint(_to, _id, _amount, ""); |
| 37 | + } |
| 38 | + |
| 39 | + function mintBatch(address _to, uint[] memory _ids, uint[] memory _amounts) external onlyOwner { |
| 40 | + _mintBatch(_to, _ids, _amounts, ""); |
| 41 | + } |
| 42 | + |
| 43 | + function burn(uint _id, uint _amount) external { |
| 44 | + _burn(msg.sender, _id, _amount); |
| 45 | + } |
| 46 | + |
| 47 | + function burnBatch(uint[] memory _ids, uint[] memory _amounts) external { |
| 48 | + _burnBatch(msg.sender, _ids, _amounts); |
| 49 | + } |
| 50 | + |
| 51 | + function burnForMint(address _from, uint[] memory _burnIds, uint[] memory _burnAmounts, uint[] memory _mintIds, uint[] memory _mintAmounts) external onlyOwner { |
| 52 | + _burnBatch(_from, _burnIds, _burnAmounts); |
| 53 | + _mintBatch(_from, _mintIds, _mintAmounts, ""); |
| 54 | + } |
| 55 | + |
| 56 | + function setURI(uint _id, string memory _uri) external onlyOwner { |
| 57 | + tokenURI[_id] = _uri; |
| 58 | + emit URI(_uri, _id); |
| 59 | + } |
| 60 | + |
| 61 | + function uri(uint _id) public override view returns (string memory) { |
| 62 | + return tokenURI[_id]; |
| 63 | + } |
| 64 | + |
| 65 | +} |
| 66 | + |
0 commit comments