-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTraits.sol
More file actions
42 lines (32 loc) · 1.22 KB
/
Traits.sol
File metadata and controls
42 lines (32 loc) · 1.22 KB
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
// SPDX-License-Identifier: MIT
pragma solidity =0.8.13;
import "@openzeppelin/contracts/utils/Strings.sol";
import "./ERC1155.sol";
contract Traits is ERC1155 {
constructor() ERC1155() {}
string private _uriBase;
string private _extension;
function name() public pure returns (string memory) {
return "TestTraits";
}
function symbol() public pure returns (string memory) {
return "TRAIT";
}
function setURI(string memory uriBase) public onlyOwner {
_uriBase = uriBase;
}
function setURIExtension(string memory extension) public onlyOwner {
_extension = extension;
}
function uri(uint256 tokenId) override public view returns (string memory) {
return string(abi.encodePacked(_uriBase, Strings.toString(tokenId), _extension));
}
function mint(address to, uint256 id, uint256 amount) external {
require(_hasAccess(Access.Mint, _msgSender()), "Not allowed to mint");
_safeMint(to, id, amount, "");
}
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts) external {
require(_hasAccess(Access.Mint, _msgSender()), "Not allowed to mint");
_safeMintBatch(to, ids, amounts, "");
}
}