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.

106 lines
3.4 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
/******* Mint Mechanics
.00 per unaboomer (BOOMR) - 10k supply
.02 per bomb (BOMB) - infinite supply
BOMB holders can randomly mail bombs to other owners
1 BOMB kills 1 BOOMR - BOOMR image switches to explosion after being bombed
chaos ensues until 1000 survivors - the game stops
********/
import {ERC721} from "solmate/tokens/ERC721.sol";
import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol";
error NotOwnerOfToken();
error MaxSupplyReached();
error TooMany();
error NoContract();
error WrongEtherAmount();
error MaxAmountReached();
error NoAdmins();
contract Unaboomer is Owned, ERC721 {
using LibString for uint256;
enum TokenState {
LIVING,
DEAD
}
mapping(uint256 => TokenState) public tokenState;
mapping(address => bool) public adminWallets;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public minted;
string public livingURI;
string public deadURI;
address[] public payoutWallets;
constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {}
// =========================================================================
// Admin
// =========================================================================
///@dev Specify team wallets for payouts and contract administration
function updateAdmins(address[] calldata _admins) external onlyOwner {
payoutWallets = _admins;
for (uint256 i; i < _admins.length; i++) {
adminWallets[_admins[i]] = true;
}
}
///@dev Remove admins if needed
function removeAdmin(address _admin) external onlyOwner {
adminWallets[_admin] = false;
}
///@dev Split payments to team
function withdraw() external onlyOwner {
if (payoutWallets.length == 0) revert NoAdmins();
uint256 balance = address(this).balance;
for (uint256 i; i < payoutWallets.length; i++) {
payable(payoutWallets[i]).transfer(balance / payoutWallets.length);
}
}
// =========================================================================
// Tokens
// =========================================================================
function mint(uint256 _amount) external payable {
if (msg.sender == tx.origin) revert NoContract();
if (_amount > 20) revert TooMany();
if (minted + _amount > MAX_SUPPLY) revert MaxSupplyReached();
unchecked {
for (uint256 i; i < _amount; i++) {
_mint(msg.sender, minted + 1);
minted++;
}
}
}
function totalSupply() view public returns (uint256 supply) {
return minted;
}
function setBaseURI(string calldata _baseURI) external onlyOwner {
livingURI = _baseURI;
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
if (tokenState[_tokenId] == TokenState.LIVING) {
return string(abi.encodePacked(livingURI, _tokenId.toString(), ".json"));
} else {
return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json"));
}
}
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
}