Protected
Readonly
guardsReadonly
metaplexYou may use the guards()
client to access the default guards
available as well as register your own guards.
const guardsClient = metaplex.candyMachines().guards();
You may use the builders()
client to access the
underlying Transaction Builders of this module.
const buildersClient = metaplex.candyMachines().builders();
You may use the pdas()
client to build PDAs related to this module.
const pdasClient = metaplex.candyMachines().pdas();
Calls the special "route" instruction on a specific guard.
This allows guards to provide additional features such as creating PDAs that verify a payer before the mint instruction is executed or freezing and thawing minted NFTs.
The "route" instruction must select a specific guard on a specific group (if groups are enabled) since it is possible for the same type of guard to have different settings based on its group.
Additionally, it is possible for a guard to support multiple "paths" within
their "route" instruction. The route settings of the guard will usually use
the path
property to distinguish them.
const { nft } = await metaplex
.candyMachines()
.callGuardRoute({
candyMachine,
guard: 'allowList',
settings: {
path: 'proof',
merkleProof: getMerkleProof(data, leaf)
},
};
Optional
options: OperationOptionsCreates a brand new Candy Machine with the provided settings.
Unless the withoutCandyGuard
option is set to true
, a
Candy Guard will be created with the given guards and
immediately linked to the Candy Machine.
const { candyMachine } = await metaplex
.candyMachines()
.create({
itemsAvailable: toBigNumber(5000),
sellerFeeBasisPoints: 333, // 3.33%
collection: {
address: collectionNft.address,
updateAuthority: collectionUpdateAuthority,
},
});
Optional
options: OperationOptionsCreates a new Candy Guard account with the provided settings.
const { candyGuard } = await metaplex
.candyMachines()
.createCandyGuard({
guards: {
startDate: { date: toDateTime('2022-09-05T20:00:00.000Z') },
solPayment: { amount: sol(1.5), },
botTax: { lamports: sol(0.01), lastInstruction: true },
},
};
Optional
options: OperationOptionsDeletes a Candy Machine account by withdrawing its rent-exempt balance.
await metaplex
.candyMachines()
.delete({
candyMachine: candyMachine.address,
candyGuard: candyMachine.candyGuard.address,
authority,
};
Optional
options: OperationOptionsDeletes a Candy Guard account by withdrawing its rent-exempt balance.
await metaplex
.candyMachines()
.deleteCandyGuard({
candyGuard,
authority,
};
Optional
options: OperationOptionsFind all Candy Guards matching by a given authority.
const candyGuards = await metaplex
.candyMachines()
.findAllCandyGuardsByAuthority({ authority: new PublicKey('...') });
Optional
options: OperationOptionsFind an existing Candy Machine by its address.
const candyMachine = await metaplex
.candyMachines()
.findbyAddress({ address };
Optional
options: OperationOptionsFind an existing Candy Guard by its address.
const candyGuard = await metaplex
.candyMachines()
.findCandyGuardbyAddress({ address };
Optional
options: OperationOptionsHelper method that fetches a Candy Guard via the base address used to derived its PDA.
const candyGuard = await metaplex
.candyMachines()
.findCandyGuardByBaseAddress({ address: base });
Optional
options: OperationOptionsInsert items into an existing Candy Machine.
Note that the name and URI of each item should not include the prefixes configured in the config line settings.
await metaplex
.candyMachines()
.insertItems({
candyMachine,
items: [
{ name: 'My NFT #1', uri: 'https://example.com/nft1' },
{ name: 'My NFT #2', uri: 'https://example.com/nft2' },
{ name: 'My NFT #3', uri: 'https://example.com/nft3' },
],
};
Optional
options: OperationOptionsMints the next NFT from a given candy machine.
const { nft } = await metaplex
.candyMachines()
.mint({
candyMachine,
collectionUpdateAuthority,
};
Optional
options: OperationOptionsHelper method that refetches a given Candy Machine or Candy Guard.
const candyMachine = await metaplex.candyMachines().refresh(candyMachine);
const candyGuard = await metaplex.candyMachines().refresh(candyGuard);
Optional
options: OperationOptionsUnwraps the given Candy Machine from its Candy Guard.
This makes the Candy Machine authority its own mint authority again
await metaplex
.candyMachines()
.unwrapCandyGuard({
candyMachine,
candyGuard,
};
Optional
options: OperationOptionsUpdates the every aspect of an existing Candy Machine, including its authorities, collection and guards (when associated with a Candy Guard).
await metaplex
.candyMachines()
.update({
candyMachine,
sellerFeeBasisPoints: 500,
};
Optional
options: OperationOptionsUpdates an existing Candy Guard account.
Note that the provided guards
and groups
will replace the existing ones.
await metaplex
.candyMachines()
.updateCandyGuard({
candyGuard: candyGuard.address,
guards: {
startDate: { date: toDateTime('2022-09-05T20:00:00.000Z') },
solPayment: { amount: sol(1.5), },
botTax: { lamports: sol(0.01), lastInstruction: true },
},
groups: [],
};
Optional
options: OperationOptions{@inheritDoc updateCandyGuardAuthorityOperation}
Optional
options: OperationOptionsWraps the given Candy Machine in a Candy Guard.
This makes the Candy Guard the mint authority for the Candy Machine which means all minting will have to go through the Candy Guard.
await metaplex
.candyMachines()
.wrapCandyGuard({
candyMachine,
candyGuard,
};
Optional
options: OperationOptionsGenerated using TypeDoc
This is a client for the Candy Machine V3 module.
It enables us to interact with the Candy Machine V3 and Candy Guard programs in order to create, update, delete and mint from Candy Machines as well as registering your own custom Candy Guards.
You may access this client via the
candyMachines()
method of yourMetaplex
instance.Example
You can create a new Candy Machine with minimum input like so. By default, the current identity of the Metaplex instance will be the authority of the Candy Machine and it will immediately create a Candy Guard linked to the new Candy Machine.
See
CandyGuard The
CandyGuard
model