You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.0 KiB
Solidity
89 lines
3.0 KiB
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.13;
|
|
|
|
import {ERC721A} from "erc721a/ERC721A.sol";
|
|
import {Owned} from "solmate/auth/Owned.sol";
|
|
import {LibString} from "solmate/utils/LibString.sol";
|
|
import {Main} from "./Main.sol";
|
|
|
|
contract Unaboomer is ERC721A, Owned {
|
|
using LibString for uint256;
|
|
|
|
mapping(uint256 => bool) public tokenDead;
|
|
|
|
uint256 public constant MAX_SUPPLY = 10000;
|
|
uint256 public constant SURVIVOR_COUNT = 1000;
|
|
uint256 public killCount;
|
|
uint256 public minted;
|
|
string public aliveURI;
|
|
string public deadURI;
|
|
Main public main;
|
|
|
|
constructor() ERC721A("Unaboomer", "BOOMR") Owned(msg.sender) {}
|
|
|
|
// =========================================================================
|
|
// Admin
|
|
// =========================================================================
|
|
|
|
/// Withdraw funds to contract owner
|
|
function withdraw() external onlyOwner {
|
|
uint256 balance = address(this).balance;
|
|
payable(msg.sender).transfer(balance);
|
|
}
|
|
|
|
/// Set metadata URI for alive BOOMR
|
|
function setAliveURI(string calldata _baseURI) external onlyOwner {
|
|
aliveURI = _baseURI;
|
|
}
|
|
|
|
/// Set metadata URI for dead BOOMR
|
|
function setDeadURI(string calldata _baseURI) external onlyOwner {
|
|
deadURI = _baseURI;
|
|
}
|
|
|
|
/// Set main contract address for executing functions
|
|
function setMainContract(address _address) external onlyOwner {
|
|
main = Main(_address);
|
|
}
|
|
|
|
// =========================================================================
|
|
// Modifiers
|
|
// =========================================================================
|
|
|
|
/// Only main address can mint
|
|
modifier onlyMain {
|
|
require(msg.sender == address(main), "invalid minter");
|
|
_;
|
|
}
|
|
|
|
// =========================================================================
|
|
// Tokens
|
|
// =========================================================================
|
|
|
|
/// Mint tokens from main contract
|
|
function radicalize(address _to, uint256 _amount) external payable onlyMain {
|
|
require(totalSupply() + _amount <= MAX_SUPPLY, "supply reached");
|
|
_safeMint(_to, _amount);
|
|
}
|
|
|
|
/// Toggle token state from living to dead
|
|
function die(uint256 tokenId) external onlyMain {
|
|
require(tokenId < totalSupply(), "invalid token id");
|
|
if (tokenDead[tokenId] == false) {
|
|
killCount++;
|
|
tokenDead[tokenId] = true;
|
|
}
|
|
}
|
|
|
|
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
|
|
if (tokenDead[_tokenId] == true) {
|
|
return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json"));
|
|
} else {
|
|
return string(abi.encodePacked(aliveURI, _tokenId.toString(), ".json"));
|
|
}
|
|
}
|
|
|
|
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721A) returns (bool) {
|
|
return super.supportsInterface(interfaceId);
|
|
}
|
|
} |