Last active
October 5, 2021 12:19
-
-
Save grampabacon/1e60249a1b4d7a0b2254ee935946c701 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; | |
import '@openzeppelin/contracts/access/Ownable.sol'; | |
contract PaperCats is ERC721Enumerable, Ownable { | |
string _baseTokenURI; | |
bool public _paused = true; | |
uint256 private _price = 0.0005 ether; | |
// community address | |
address _communityWallet = 0xB93A6D9D539e7EDB0858Eb53a3e1501d51935752; | |
constructor(string memory baseURI) ERC721("Paper Cats", "PCATS") { | |
setBaseURI(baseURI); | |
} | |
// infinite mints, max 3 tokens per transaction | |
// tiny minting price, all goes back to the community :) | |
function adopt(uint256 amount) public payable { | |
require(amount < 4, "You can adopt a maximum of 3 Paper Cats"); | |
require(!_paused, "Sale paused"); | |
require(msg.value == _price * amount, "Ether sent is not correct"); | |
for (uint256 i; i < amount; i++) { | |
_safeMint(msg.sender, totalSupply()); | |
} | |
} | |
function walletOfOwner(address _owner) public view returns (uint256[] memory) { | |
uint256 tokenCount = balanceOf(_owner); | |
uint256[] memory tokensId = new uint256[](tokenCount); | |
for (uint256 i; i < tokenCount; i++) { | |
tokensId[i] = tokenOfOwnerByIndex(_owner, i); | |
} | |
return tokensId; | |
} | |
function _baseURI() internal view virtual override returns (string memory) { | |
return _baseTokenURI; | |
} | |
function setBaseURI(string memory baseURI) public onlyOwner { | |
_baseTokenURI = baseURI; | |
} | |
function pause(bool val) public onlyOwner { | |
_paused = val; | |
} | |
function withdrawAll() public onlyOwner { | |
require(payable(_communityWallet).send(address(this).balance)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment