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.5 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";
2 years ago
import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol";
2 years ago
import {UnaboomerCommon} from "./UnaboomerCommon.sol";
contract Unaboomer is ERC721, Owned {
using LibString for uint256;
mapping(uint256 => bool) public tokenDead;
uint256 public constant MAX_SUPPLY = 10000;
2 years ago
uint256 public constant SURVIVOR_COUNT = 1000;
uint256 public killCount;
uint256 public minted;
2 years ago
string public aliveURI;
string public deadURI;
2 years ago
UnaboomerCommon public main;
2 years ago
constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {}
// =========================================================================
// Admin
// =========================================================================
2 years ago
/// Withdraw funds to contract owner
function withdraw() external onlyOwner {
uint256 balance = address(this).balance;
2 years ago
payable(msg.sender).transfer(balance);
}
2 years ago
/// Set metadata URI for alive BOOMR
function setAliveURI(string calldata _baseURI) external onlyOwner {
aliveURI = _baseURI;
}
2 years ago
/// Set metadata URI for dead BOOMR
function setDeadURI(string calldata _baseURI) external onlyOwner {
deadURI = _baseURI;
}
2 years ago
/// Set main contract address for executing functions
function setMainContract(address _address) external onlyOwner {
main = UnaboomerCommon(_address);
2 years ago
}
2 years ago
// =========================================================================
// Modifiers
// =========================================================================
modifier onlyMain {
require(msg.sender == address(main), "invalid minter");
_;
}
// =========================================================================
// Tokens
// =========================================================================
2 years ago
/// Mint tokens from main contract
function radicalize(address _to, uint256 _amount) external payable onlyMain {
2 years ago
require(minted + _amount <= MAX_SUPPLY, "supply reached");
unchecked {
for (uint256 i; i < _amount; i++) {
minted++;
2 years ago
_mint(_to, minted);
}
}
}
2 years ago
/// Toggle token state from living to dead
2 years ago
function kill(uint256 tokenId) external onlyMain {
2 years ago
require(tokenId < minted, "invalid token id");
2 years ago
if (tokenDead[tokenId] == false) {
killCount++;
tokenDead[tokenId] = true;
}
2 years ago
}
function totalSupply() public view returns (uint256 supply) {
return minted;
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
2 years ago
if (tokenDead[_tokenId]) {
return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json"));
2 years ago
} else {
return string(abi.encodePacked(aliveURI, _tokenId.toString(), ".json"));
}
}
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
2 years ago
}