-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelayedRevealNFT
More file actions
28 lines (23 loc) · 843 Bytes
/
Copy pathDelayedRevealNFT
File metadata and controls
28 lines (23 loc) · 843 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract DelayedRevealNFT is ERC721, Ownable {
bool public revealed = false;
string public unrevealedURI;
string public baseURI;
constructor(address initialOwner) ERC721("MysteryBox", "BOX") Ownable(initialOwner) {
unrevealedURI = "ipfs://QmUnrevealedHash";
}
function reveal(string memory _newBaseURI) public onlyOwner {
revealed = true;
baseURI = _newBaseURI;
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
_requireOwned(tokenId);
if (!revealed) {
return unrevealedURI;
}
return string(abi.encodePacked(baseURI, tokenId));
}
}