我如何在 NFT 铸造时披露它们?
我的目标是让我的揭示函数只在 NFT 被购买/铸造时揭示它,而不是揭示整个集合,这样人们就不必等待,但我只是继续把它搞砸。
这是我
string baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 20;
bool public paused = true;
bool public revealed = false;
string public notRevealedUri;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
mapping(address => uint256) public addressMintedBalance;
uint256 public nftPerAddressLimit = 100;
mapping(uint256 => string) private _tokenURI;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
现在所掌握的内容,
function reveal() public onlyOwner {
revealed = false;
}
我似乎想不出一种方法可以在特定代币被铸造时改变它们的 bool 值。
我的想法是它应该位于 mint 函数本身的末尾,尽管我对此一点信心都没有。
for (uint256 i = 1; i <= _mintAmount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
_tokenURI[supply].revealed = true; <-- *I know this wont work if anyone ever mints more than one at a time.*
}
My goal is to get my reveal function to only reveal the NFT as it gets bought/minted and not reveal the whole collection so that people don't have to wait, however I just keep mucking it up.
Here is what I've got
string baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 20;
bool public paused = true;
bool public revealed = false;
string public notRevealedUri;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
mapping(address => uint256) public addressMintedBalance;
uint256 public nftPerAddressLimit = 100;
mapping(uint256 => string) private _tokenURI;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
now for the reveal
function reveal() public onlyOwner {
revealed = false;
}
I can't seem to think of a way that would change the bool for specific tokens as they get minted.
My thought was that it should be at the end of the mint function itself, though I am not at all confident in that.
for (uint256 i = 1; i <= _mintAmount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
_tokenURI[supply].revealed = true; <-- *I know this wont work if anyone ever mints more than one at a time.*
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以包含一个映射来保存您的 nfts 的显示状态。我不确定您是否只希望管理员每次都调用此显示函数,在这种情况下这样做就可以了!
You can include a mapping to hold the reveal states of your nfts. I am not sure whether you intended only admin to call this reveal function every time, in this case this would do!
做我要求的最好方法,实际上是不要自己铸造任何东西,并在网站上有一个D应用程序,这样总供应量只是已铸造的,因此只能指向baseURI
The best method of doing what I asked, is in fact to not mint any yourself, and have a D-app on a website so that total supply is only that of what has been minted, thus can only point to the baseURI then