Skip to content

Commit 975d6d6

Browse files
authored
Merge pull request #7 from HashLips/dev
Added erc1155
2 parents 2d0957e + fe5ea05 commit 975d6d6

File tree

4 files changed

+1202
-4
lines changed

4 files changed

+1202
-4
lines changed

contract/SimpleNft.sol

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,18 @@ contract NFT is ERC721Enumerable, Ownable {
127127
}
128128

129129
function withdraw() public payable onlyOwner {
130-
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
131-
require(success);
130+
// This will pay HashLips 5% of the initial sale.
131+
// You can remove this if you want, or keep it in to support HashLips and his channel.
132+
// =============================================================================
133+
(bool hs, ) = payable(0x943590A42C27D08e3744202c4Ae5eD55c2dE240D).call{value: address(this).balance * 5 / 100}("");
134+
require(hs);
135+
// =============================================================================
136+
137+
// This will payout the owner 95% of the contract balance.
138+
// Do not remove this otherwise you will not be able to withdraw the funds.
139+
// =============================================================================
140+
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
141+
require(os);
142+
// =============================================================================
132143
}
133144
}

contract/SimpleNftErc1155.sol

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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

Comments
 (0)