-
Notifications
You must be signed in to change notification settings - Fork 2
/
MCUOSC.sol
65 lines (53 loc) · 1.93 KB
/
MCUOSC.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.6.0/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.6.0/access/Ownable.sol";
import "@openzeppelin/contracts@4.6.0/utils/Counters.sol";
contract MCUOSC is ERC721, Ownable {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenIdCounter;
uint256 public constant MAX_SUPPLY = 7;
uint256 public mintPrice = 0.0000000000005 ether;
uint256 totalSupply = 0;
mapping(uint256 => bool) public tokenRevealed;
constructor() ERC721("MCUOSC", "MO") {}
function _baseURI() internal pure override returns (string memory) {
return "https://gateway.pinata.cloud/ipfs/QmcJPSNLR7drk9WXsK8PZfBCT7YyqruiZo4MK96Rz1TsW2/";
}
function mint() public payable {
require(
totalSupply + 1 < MAX_SUPPLY,
"Sale done"
);
require(
mintPrice <= msg.value,
"Not enough ether"
);
_mint();
}
function _mint() internal {
totalSupply += 1;
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(msg.sender, tokenId);
tokenRevealed[tokenId] = false;
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(
_exists(tokenId),
"URI query for nonexistent token"
);
if(tokenRevealed[tokenId] == false){
return "https://gateway.pinata.cloud/ipfs/QmR5YGsQfFcuaxX7QHbYvtDTV7R8e4wPzYNPYjUFb5cpFy";
}
return string(abi.encodePacked(_baseURI(), tokenId.toString(), ".json"));
}
function flipReveal(uint256 tokenId) public {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"Caller is not owner nor approved"
);
tokenRevealed[tokenId] = !tokenRevealed[tokenId];
}
}