Candy Guard

What is a guard?

A guard is a modular piece of code that can restrict access to the mint of a Core Candy Machine and even add new features to it!

There is a large set of guards to choose from and each of them can be activated and configured at will.

We’ll touch on all available guards later in this documentation but let’s go through a few examples here to illustrate that.

  • When the Start Date guard is enabled, minting will be forbidden before the preconfigured date. There is also an End Date guard to forbid minting after a given date.

  • When the Sol Payment guard is enabled, the minting wallet will have to pay a configured amount to a configured destination wallet. Similar guards exist for paying with tokens or NFTs of a specific collection.

  • The Token Gate and NFT Gate guards restrict minting to certain token holders and NFT holders respectively.

  • The Allow List guard only allows minting if the wallet is part of a predefined list of wallets. Kind of like a guest list for minting.

As you can see, each guard takes care of one responsibility and one responsibility only which makes them composable. In other words, you can pick and choose the guards your need to create your perfect Candy Machine.

The Core Candy Guard account

Each Core Candy Machine account should typically be associated with its own Core Candy Guard account which will add a layer of protection to it.

This works by creating a Core Candy Guard account and making it the Mint Authority of the Core Candy Machine account. By doing so, it is no longer possible to mint directly from the main Core Candy Machine program. Instead, we must mint via the Core Candy Guard program which, if all guards are resolved successfully, will defer to the Core Candy Machine Core program to finish the minting process.

Core Candy MachineOwner: Core Candy Machine ProgramFeaturesAuthority

Mint Authority = Candy Guard

...Core Candy GuardOwner: Core Candy Guard ProgramGuardsSol PaymentToken PaymentStart DateEnd Date...MintCore Candy Guard ProgramAccess Control

Anyone can mint as long as they comply with the activated guards.

MintCore Candy Machine Core ProgramMint Logic

Only Alice can mint.

NFTCandy MachineOwner: Candy Machine Core ProgramFeaturesAuthority

Mint Authority = Alice

...React Flow

Note that, since Core Candy Machine and Core Candy Guard accounts work hand and hand together, our SDKs treat them as one entity. When you create a Core Candy Machine with our SDKs, an associated Core Candy Guard account will also be created by default. The same goes when updating Core Candy Machines as they allow you to update guards at the same time. We will see some concrete examples on this page.

Why another program?

The reason guards don’t live in the main Core Candy Machine program is to separate the access control logic from the main Core Candy Machine responsibility which is to mint an NFT.

This enables guards to not only be modular but extendable. Anyone can create and deploy their own Core Candy Guard program to create custom guards whilst relying on the Core Candy Machine Core program for all the rest.

Core Candy MachineOwner: Core Candy Machine Core ProgramCore Candy GuardOwner: Core Candy Guard ProgramGuardsSol PaymentToken PaymentStart DateEnd Date...MintCore Candy Guard ProgramMintCustom Core Candy Guard ProgramDifferent Access ControlMintCore Candy Machine Core ProgramSame Mint LogicNFTCandy MachineOwner: Core Candy Machine Core ProgramCandy GuardOwner: Custom Core Candy Guard ProgramGuardsSol PaymentToken PaymentStart Date

My Custom Guard

...React Flow

Note that our SDKs also offer ways to register your own Core Candy Guard programs and their custom guards so you can leverage their friendly API and easily share your guards with others.

All available guards

Alright, now that we understand what guards are, let’s see what default guards are available to us.

In the following list, we’ll provide a short description of each guard with a link pointing to their dedicated page for more advanced reading.

  • Address Gate: Restricts the mint to a single address.

  • Allocation: Allows specifying a limit on the number of NFTs each guard group can mint.

  • Allow List: Uses a wallet address list to determine who is allowed to mint.

  • Bot Tax: Configurable tax to charge invalid transactions.

  • End Date: Determines a date to end the mint.

  • Freeze Sol Payment: Set the price of the mint in SOL with a freeze period.

  • Freeze Token Payment: Set the price of the mint in token amount with a freeze period.

  • Gatekeeper: Restricts minting via a Gatekeeper Network e.g. Captcha integration.

  • Mint Limit: Specifies a limit on the number of mints per wallet.

  • Nft Burn: Restricts the mint to holders of a specified collection, requiring a burn of the NFT.

  • Nft Gate: Restricts the mint to holders of a specified collection.

  • Nft Payment: Set the price of the mint as an NFT of a specified collection.

  • Program Gate: Restricts the programs that can be in a mint transaction

  • Redeemed Amount: Determines the end of the mint based on the total amount minted.

  • Sol Payment: Set the price of the mint in SOL.

  • Start Date: Determines the start date of the mint.

  • Third Party Signer: Requires an additional signer on the transaction.

  • Token Burn: Restricts the mint to holders of a specified token, requiring a burn of the tokens.

  • Token Gate: Restricts the mint to holders of a specified token.

  • Token Payment: Set the price of the mint in token amount.

  • Token22 Payment: Set the price of the mint in token22 (token extension) amount.

Conclusion

Guards are important components of Core Candy Machines. They make it easy to configure the minting process whilst allowing anyone to create their own guards for application-specific needs.

Last updated