Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set base URI on reveal #19

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions contracts/NFT/NFT_REVEAL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ contract NFT is ERC721Enumerable, Ownable {
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
mint(msg.sender, 20);
}
Expand Down Expand Up @@ -86,24 +84,25 @@ contract NFT is ERC721Enumerable, Ownable {
override
returns (string memory)
{
if(revealed == false) {
return notRevealedUri;
}

require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);

if(revealed == false) {
return notRevealedUri;
}

string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}

//only owner
function reveal() public onlyOwner {
revealed = true;
function reveal(string memory _baseURIInit) public onlyOwner {
baseURI = _baseURIInit;
revealed = true;
}

function setCost(uint256 _newCost) public onlyOwner {
Expand All @@ -119,6 +118,7 @@ contract NFT is ERC721Enumerable, Ownable {
}

function setBaseURI(string memory _newBaseURI) public onlyOwner {
require(revealed == true);
baseURI = _newBaseURI;
}

Expand Down