setting up erc721a

master
lza_menace 2 years ago
parent a72a7dc9f0
commit 053470d648

@ -1,3 +1,4 @@
ds-test/=lib/solmate/lib/ds-test/src/
solmate/=lib/solmate/src/
forge-std/=lib/forge-std/src/
forge-std/=lib/forge-std/src/
erc721a/=lib/erc721a/contracts/

@ -10,12 +10,12 @@ BOMB holders can randomly mail bombs to other owners
chaos ensues until 1000 survivors - the game stops
********/
import {ERC721} from "solmate/tokens/ERC721.sol";
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 ERC721, Owned {
contract Unaboomer is ERC721A, Owned {
using LibString for uint256;
mapping(uint256 => bool) public tokenDead;
@ -28,7 +28,7 @@ contract Unaboomer is ERC721, Owned {
string public deadURI;
Main public main;
constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {}
constructor() ERC721A("Unaboomer", "BOOMR") Owned(msg.sender) {}
// =========================================================================
// Admin
@ -70,30 +70,19 @@ contract Unaboomer is ERC721, Owned {
/// Mint tokens from main contract
function radicalize(address _to, uint256 _amount) external payable onlyMain {
require(minted + _amount <= MAX_SUPPLY, "supply reached");
unchecked {
uint256 startToken = minted + 1;
for (uint256 i; i < _amount; i++) {
_mint(_to, startToken);
startToken += 1;
}
minted += _amount;
}
require(totalSupply() + _amount <= MAX_SUPPLY, "supply reached");
_safeMint(_to, _amount);
}
/// Toggle token state from living to dead
function kill(uint256 tokenId) external onlyMain {
require(tokenId < minted, "invalid token id");
require(tokenId <= totalSupply(), "invalid token id");
if (tokenDead[tokenId] == false) {
killCount++;
tokenDead[tokenId] = true;
}
}
function totalSupply() public view 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"));
@ -102,7 +91,7 @@ contract Unaboomer is ERC721, Owned {
}
}
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721) returns (bool) {
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
Loading…
Cancel
Save