-
Notifications
You must be signed in to change notification settings - Fork 0
/
mint.sol
66 lines (52 loc) · 2.14 KB
/
mint.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//Minting contract with mint_price and withdraw owner
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract CENTRA is ERC721, ERC721Enumerable, Pausable, Ownable, ERC721Burnable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
uint256 public MINT_PRICE = 0.05 ether;
uint256 public MAX_SUPPLY = 100;
constructor() ERC721("CENTRA", "CEN") {
_tokenIdCounter.increment();
}
function _baseURI() internal pure override returns (string memory) {
return "ipfs://QmehjD1qPwtS4LAHPw8LeKN6uLhzREvGFjXyKwycXrD41Q/";
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function safeMint(address to) public payable {
require(totalSupply() < MAX_SUPPLY, "Can't mint anymore");
require(msg.value >= MINT_PRICE, "Not enough ether sent");
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
uint256 batchSize
) internal override(ERC721, ERC721Enumerable) whenNotPaused {
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
function withdraw() public onlyOwner {
require(address(this).balance > 0, "Balance is zero");
payable(owner()).transfer(address(this).balance);
}
// The following functions are overrides required by Solidity.
function supportsInterface(
bytes4 interfaceId
) public view override(ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
}