splitting contracts
parent
1ae9c63b2f
commit
210d22aacd
@ -0,0 +1,106 @@
|
|||||||
|
// 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 NotEnoughEther();
|
||||||
|
error NotOwnerOfToken();
|
||||||
|
error MaxSupplyReached();
|
||||||
|
error TooMany();
|
||||||
|
error NoContract();
|
||||||
|
error WrongEtherAmount();
|
||||||
|
error MaxAmountReached();
|
||||||
|
error NoAdmins();
|
||||||
|
error NotAdmin();
|
||||||
|
error NoRemoveSelf();
|
||||||
|
error NoRemoveDeployer();
|
||||||
|
|
||||||
|
contract Mailbomb is ERC721, Owned {
|
||||||
|
using LibString for uint256;
|
||||||
|
|
||||||
|
mapping(uint256 => bool) public tokenDead;
|
||||||
|
|
||||||
|
uint256 public constant MAX_SUPPLY = 10000;
|
||||||
|
uint256 public price = 0.01 ether;
|
||||||
|
uint256 public minted;
|
||||||
|
string public aliveURI;
|
||||||
|
string public deadURI;
|
||||||
|
address public MailBombContract;
|
||||||
|
|
||||||
|
constructor() ERC721("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 price for PFP + 2 BOMB
|
||||||
|
function setPrice(uint256 _price) external onlyOwner {
|
||||||
|
price = _price;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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 contract address for Mailbomb tokens
|
||||||
|
function setMailBombContract(address _address) external onlyOwner {
|
||||||
|
MailBombContract = _address;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// Tokens
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
function mint(uint256 _amount) external payable {
|
||||||
|
if (msg.sender == tx.origin) revert NoContract();
|
||||||
|
if (_amount > 20) revert TooMany();
|
||||||
|
if (msg.value < _amount * price) revert NotEnoughEther();
|
||||||
|
if (minted + _amount > MAX_SUPPLY) revert MaxSupplyReached();
|
||||||
|
unchecked {
|
||||||
|
for (uint256 i; i < _amount; i++) {
|
||||||
|
_mint(msg.sender, minted + 1);
|
||||||
|
minted++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// also mint 2 BOMB to user
|
||||||
|
}
|
||||||
|
|
||||||
|
function totalSupply() view public returns (uint256 supply) {
|
||||||
|
return minted;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
|
||||||
|
if (tokenDead[_tokenId]) {
|
||||||
|
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 (ERC721) returns (bool) {
|
||||||
|
return super.supportsInterface(interfaceId);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue