setting price

master
lza_menace 2 years ago
parent 4622f2788f
commit 1ae9c63b2f

@ -14,6 +14,7 @@ import {ERC721} from "solmate/tokens/ERC721.sol";
import {Owned} from "solmate/auth/Owned.sol"; import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol"; import {LibString} from "solmate/utils/LibString.sol";
error NotEnoughEther();
error NotOwnerOfToken(); error NotOwnerOfToken();
error MaxSupplyReached(); error MaxSupplyReached();
error TooMany(); error TooMany();
@ -31,6 +32,7 @@ contract Unaboomer is ERC721, Owned {
mapping(uint256 => bool) public tokenDead; mapping(uint256 => bool) public tokenDead;
uint256 public constant MAX_SUPPLY = 10000; uint256 public constant MAX_SUPPLY = 10000;
uint256 public price = 0.01 ether;
uint256 public minted; uint256 public minted;
string public aliveURI; string public aliveURI;
string public deadURI; string public deadURI;
@ -48,6 +50,11 @@ contract Unaboomer is ERC721, Owned {
payable(msg.sender).transfer(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 /// Set metadata URI for alive BOOMR
function setAliveURI(string calldata _baseURI) external onlyOwner { function setAliveURI(string calldata _baseURI) external onlyOwner {
aliveURI = _baseURI; aliveURI = _baseURI;
@ -70,6 +77,7 @@ contract Unaboomer is ERC721, Owned {
function mint(uint256 _amount) external payable { function mint(uint256 _amount) external payable {
if (msg.sender == tx.origin) revert NoContract(); if (msg.sender == tx.origin) revert NoContract();
if (_amount > 20) revert TooMany(); if (_amount > 20) revert TooMany();
if (msg.value < _amount * price) revert NotEnoughEther();
if (minted + _amount > MAX_SUPPLY) revert MaxSupplyReached(); if (minted + _amount > MAX_SUPPLY) revert MaxSupplyReached();
unchecked { unchecked {
for (uint256 i; i < _amount; i++) { for (uint256 i; i < _amount; i++) {

@ -15,12 +15,11 @@ contract UnaboomerTest is Test {
vm.deal(address(boomr), 11 ether); vm.deal(address(boomr), 11 ether);
vm.prank(address(boomr.owner())); vm.prank(address(boomr.owner()));
boomr.withdraw(); boomr.withdraw();
assertEq(boomr.owner().balance > 10 ether, true);
} }
function testMint() public { function testMint() public {
vm.startPrank(address(1)); hoax(address(1));
boomr.mint(5); boomr.mint{value: 0.05 ether}(5);
assertEq(boomr.totalSupply(), 5); assertEq(boomr.totalSupply(), 5);
assertEq(boomr.tokenDead(1), false); assertEq(boomr.tokenDead(1), false);
} }

Loading…
Cancel
Save