-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoredTownMinterV2.sol
54 lines (43 loc) · 1.53 KB
/
BoredTownMinterV2.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
interface V2Interface {
function numberMinted(address owner) external view returns (uint256);
function remainingSupply() external view returns (uint256);
function mint(address to, uint256 amount) external;
}
contract BoredTownMinterV2 is Ownable {
// config
bool public mintEnabled = false;
string private secret = "ILOVEMINTDOTFUN";
// target contract
address public targetAddress;
V2Interface private targetContract;
function setTarget(address _addr) external onlyOwner {
targetAddress = _addr;
targetContract = V2Interface(_addr);
}
// toggle sale
function toggleSale() external onlyOwner {
mintEnabled = !mintEnabled;
}
// mint
function mint(uint quantity, string calldata _secret) external {
require(mintEnabled, "Sale is not enabled");
require(Strings.equal(secret, _secret), "Invalid secret");
targetContract.mint(msg.sender, quantity);
}
// aliases
function numberMinted(address owner) external view returns (uint256) {
return targetContract.numberMinted(owner);
}
function remainingSupply() external view returns (uint256) {
return targetContract.remainingSupply();
}
// eth
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
}