NFT Gate
Overview
The NFT Gate guard restricts minting to holders of a specified NFT collection.
Guard Settings
The NFT Gate guard contains the following settings:
- Required Collection: The mint address of the required NFT Collection. The NFT we provide as proof when minting must be part of this collection.
JavaScript — Umi library (recommended)
JavaScript — SDK
Here’s an example of how to set up a Candy Machine using the NFT Gate guard.
const { candyMachine } = await metaplex.candyMachines().create({
// ...
guards: {
nftGate: {
requiredCollection: requiredCollectionNft.address,
},
},
});
API References: Operation, Input, Output, Transaction Builder, Guard Settings.
Mint Settings
The NFT Gate guard contains the following Mint Settings:
- Mint: The mint address of the NFT to provide as proof that the payer owns an NFT from the required collection.
- Token Account (optional): You may optionally provide the token account linking the NFT with its owner explicitly. By default, the associated token account of the payer will be used.
Note that, if you’re planning on constructing instructions without the help of our SDKs, you will need to provide these Mint Settings and more as a combination of instruction arguments and remaining accounts. See the Candy Guard’s program documentation for more details.
JavaScript — Umi library (recommended)
When minting via the Umi library, simply provide the mint address of the NFT to use as proof of ownership via the mint
attribute like so.
mintV2(umi, {
// ...
mintArgs: {
nftGate: some({ mint: nftToBurn.publicKey }),
},
});
API References: mintV2, NftGateMintArgs
JavaScript — SDK
When minting via the JS SDK, simply provide the mint address of the NFT to use as proof of ownership via the mint
attribute like so.
const { nft } = await metaplex.candyMachines().mint({
// ...
guards: {
nftGate: {
mint: nftFromRequiredCollection.address,
},
},
});
You may also provide the tokenAccount
attribute explicitly should the NFT not use an associated token account.
API References: Operation, Input, Output, Transaction Builder, Mint Settings.
Route Instruction
The NFT Gate guard does not support the route instruction.