Skip to main content

DelayedReveal

Delayed Reveal

Thirdweb's DelayedReveal is a contract extension for base NFT contracts. It lets you create batches of 'delayed-reveal' NFTs. You can learn more about the usage of delayed reveal NFTs here - https://blog.thirdweb.com/delayed-reveal-nfts

Methods

encryptDecrypt

function encryptDecrypt(bytes data, bytes key) external pure returns (bytes result)

Encrypt/decrypt data on chain.

Encrypt/decrypt given data with key. Uses inline assembly. See: https://ethereum.stackexchange.com/questions/69825/decrypt-message-on-chain

Parameters

NameTypeDescription
databytesBytes of data to encrypt/decrypt.
keybytesSecure key used by caller for encryption/decryption.

Returns

NameTypeDescription
resultbytesOutput after encryption/decryption of given data.

encryptedData

function encryptedData(uint256) external view returns (bytes)

Mapping from tokenId of a batch of tokens => to delayed reveal data.

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0bytesundefined

getRevealURI

function getRevealURI(uint256 _batchId, bytes _key) external view returns (string revealedURI)

Returns revealed URI for a batch of NFTs.

Reveal encrypted base URI for _batchId with caller/admin's _key used for encryption. Reverts if there's no encrypted URI for _batchId. See {encryptDecrypt}.

Parameters

NameTypeDescription
_batchIduint256ID of the batch for which URI is being revealed.
_keybytesSecure key used by caller/admin for encryption of baseURI.

Returns

NameTypeDescription
revealedURIstringDecrypted base URI.

isEncryptedBatch

function isEncryptedBatch(uint256 _batchId) external view returns (bool)

Returns whether the relvant batch of NFTs is subject to a delayed reveal.

Returns true if _batchId's base URI is encrypted.

Parameters

NameTypeDescription
_batchIduint256ID of a batch of NFTs.

Returns

NameTypeDescription
_0boolundefined

reveal

function reveal(uint256 identifier, bytes key) external nonpayable returns (string revealedURI)

Reveals a batch of delayed reveal NFTs.

Parameters

NameTypeDescription
identifieruint256The ID for the batch of delayed-reveal NFTs to reveal.
keybytesThe key with which the base URI for the relevant batch of NFTs was encrypted.

Returns

NameTypeDescription
revealedURIstringundefined

Events

TokenURIRevealed

event TokenURIRevealed(uint256 indexed index, string revealedURI)

Parameters

NameTypeDescription
index indexeduint256undefined
revealedURIstringundefined