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.
79 lines
2.2 KiB
Solidity
79 lines
2.2 KiB
Solidity
2 years ago
|
// 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();
|
||
|
|
||
|
contract Unaboomer is Owned, ERC721 {
|
||
|
using LibString for uint256;
|
||
|
|
||
|
enum TokenState {
|
||
|
LIVING,
|
||
|
DEAD
|
||
|
}
|
||
|
|
||
|
mapping(uint256 => TokenState) public tokenState;
|
||
|
|
||
|
uint256 public constant MAX_SUPPLY = 10000;
|
||
|
uint256 public minted;
|
||
|
string public livingURI;
|
||
|
string public deadURI;
|
||
|
|
||
|
constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {}
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
}
|