ERC721Revealable
Functionality available for contracts that implement the
IERC721
and
ILazyMint
interfaces and inherit the
DelayedReveal
contract.
Allows you to lazy-mint batches of NFTs that are encrypted until a later time, and reveal them at any time using a password.
createDelayedRevealBatch
Create a batch of encrypted NFTs that can be revealed at a later time.
Provide an array of metadata for the NFTs you want to create, which can either be a
string
URL that points to metadata, or an object.
The metadata must conform to the metadata standards.
If you provide an object, it is uploaded and pinned to IPFS before being lazy-minted into the contract.
// the real NFTs, these will be encrypted until you reveal them
const realNFTs = [
{
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
},
{
name: "Cool NFT #2",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
},
];
// A placeholder NFT that people will get immediately in their wallet, and will be converted to the real NFT at reveal time
const placeholderNFT = {
name: "Hidden NFT",
description: "Will be revealed next week!",
};
// Create and encrypt the NFTs
await contract.erc721.revealer.createDelayedRevealBatch(
placeholderNFT,
realNFTs,
"my secret password",
);
Configuration
placeholder
A single metadata object
or URL string that points to
valid metadata.
This is the metadata users will see until you reveal
the batch.
// the real NFTs, these will be encrypted until you reveal them
const realNFTs = [
// ...
];
// A placeholder NFT that people will get immediately in their wallet, and will be converted to the real NFT at reveal time
const placeholderNFT = {
name: "Hidden NFT",
description: "Will be revealed next week!",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
};
// Create and encrypt the NFTs
const txResult = await contract.erc721.revealer.createDelayedRevealBatch(
placeholderNFT,
realNFTs,
"my secret password",
);
metadatas
An array of metadata objects or URL strings that point to valid metadata.
These are the NFTs that will be revealed when you reveal
the batch.
// the real NFTs, these will be encrypted until you reveal them
const realNFTs = [
{
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
},
{
name: "Cool NFT #2",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
},
];
// A placeholder NFT that people will get immediately in their wallet, and will be converted to the real NFT at reveal time
const placeholderNFT = {
// ...
};
// Create and encrypt the NFTs
const txResult = await contract.erc721.revealer.createDelayedRevealBatch(
placeholderNFT,
realNFTs,
"my secret password",
);
password
The password that will be used to reveal
the batch.
Passwords cannot be recovered or reset. If you forget your password, you will not be able to reveal your NFTs.
const realNFTs = [
// ...
];
const placeholderNFT = {
// ...
};
const txResult = await contract.erc721.revealer.createDelayedRevealBatch(
placeholderNFT,
realNFTs,
"my secret password",
);
getBatchesToReveal
Get a list of unrevealed batches.
const batches = await contract.erc721.revealer.getBatchesToReveal();
Configuration
Returns an array of BatchToReveal
objects, containing the following properties:
{
batchId: BigNumber;
batchUri: string;
placeholderMetadata: {
id: string;
uri: string; // The raw URI of the metadata
owner: string;
name?: string | number | undefined;
description?: string | null | undefined;
image?: string | null | undefined; // If the image is hosted on IPFS, the URL is https://gateway.ipfscdn.io/ipfs/<hash>
external_url?: string | null | undefined;
animation_url?: string | null | undefined;
background_color?: string | undefined;
properties?: {
[x: string]: unknown;
} | {
[x: string]: unknown;
}[] | undefined;
};
type: "erc721";
};
}[];
reveal
Reveal a batch of NFTs that were previously created with
createDelayedRevealBatch
.
const batchId = 0; // the batch to reveal
await contract.erc721.revealer.reveal(batchId, "my secret password");
Configuration
batchId
The ID of the batch to reveal, which you can get from
getBatchesToReveal
.
Must be a string
, number
, or BigNumber
.
await contract.erc721.revealer.reveal(
"{{batch_id}}",
"{{password}}",
);
password
When you create a batch using createDelayedRevealBatch
,
you specify a password. To you reveal the batch, you must provide the same
password.
Must be a string
.
await contract.erc721.revealer.reveal(
"{{batch_id}}",
"{{password}}",
);