-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherc1155Example.sol
More file actions
59 lines (53 loc) · 1.79 KB
/
Copy patherc1155Example.sol
File metadata and controls
59 lines (53 loc) · 1.79 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
// Import OpenZeppelin's ERC-1155 implementation
import "@openzeppelin/contracts@4.9.3/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts@4.9.3/access/Ownable.sol";
/**
* @title BasicERC1155
* @dev A simple implementation of an ERC-1155 token contract with minting functionality.
*/
contract BasicERC1155 is ERC1155, Ownable {
// Constructor sets the initial metadata URI
constructor(string memory _uri) ERC1155(_uri) {}
/**
* @notice Mint new tokens
* @dev Only the contract owner can mint new tokens.
* @param account The address to mint tokens to.
* @param id The token ID to mint.
* @param amount The number of tokens to mint.
* @param data Optional data to pass to the receiver (if applicable).
*/
function mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) public onlyOwner {
_mint(account, id, amount, data);
}
/**
* @notice Mint multiple tokens at once
* @dev Only the contract owner can mint multiple tokens.
* @param to The address to mint tokens to.
* @param ids An array of token IDs to mint.
* @param amounts An array of amounts for each token ID.
* @param data Optional data to pass to the receiver (if applicable).
*/
function mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public onlyOwner {
_mintBatch(to, ids, amounts, data);
}
/**
* @notice Update the base metadata URI
* @dev Only the contract owner can update the URI.
* @param newuri The new metadata URI.
*/
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
}