-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMemeTokenERC1155Factory.sol
82 lines (71 loc) · 2.02 KB
/
MemeTokenERC1155Factory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract ERC1155Token is ERC1155, Ownable {
constructor(
string memory _name,
address initialOwner,
string memory _uri
) ERC1155(_name) Ownable(initialOwner) {
_setURI(_uri);
}
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
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);
}
}
contract MemeTokenERC1155Factory {
event TokenCreated(address tokenAddress);
enum Strategy {
ERC1155
}
struct ContractInfo {
string name;
string symbol;
uint256 initialSupply;
uint256 maxSupply;
string uri;
Strategy strategy;
}
mapping(address => address[]) public ownerToTokens;
mapping(address => ContractInfo) public tokenToContractInfo;
function createERC1155Token(
string memory name,
address initialOwner,
string memory uri
) public {
ERC1155Token newToken = new ERC1155Token(name, initialOwner,uri);
ownerToTokens[initialOwner].push(address(newToken));
tokenToContractInfo[address(newToken)] = ContractInfo({
name: name,
symbol: "",
initialSupply: 0,
maxSupply: 0,
uri: uri,
strategy: Strategy.ERC1155
});
emit TokenCreated(address(newToken));
}
function getTokensForOwner(
address owner
) public view returns (address[] memory) {
return ownerToTokens[owner];
}
}