Setup Candy Machine

Solana Godot SDK features implementation of Metaplex Candymachine V3, which allows minting generated NFTs from a premade collection

Supported featues:

  • pNFTs (Programmable NFTs)

  • Candy Guards

  • Candy Guard Groups

This is one of the most powerful features in the SDK, allowing developers to setup a much more interactive and interesting NFT minting experience using Godot game engine.

Step 0: Setup NFT Collection

Before implementing your NFT collection's minting inside Godot, you need to set it up using Metaplex Sugar. Once you have created a new candymachine and the necessary candy guards, you can bring it to Godot for minting.

Step 1: Mint Settings

We have prepared a very convenient class for setting candy guards in Godot, which you can create by right-clicking in the project's FileSystem, and choosing Create New -> Resource. Then, search for CandyGuardAccessList.

If you have set your Candy Guards when initializing the collection, this class will be very familiar: you have all the different guards on a Default guard group, and for any additional groups, you can just create new CandyGuardAccessList in the Groups section!

What you need to do is copy the guards here exactly how you did when creating the candy machine and save this file. You will need it to pass in later.

Step 2. Mint The NFT

This is a basic example of minting an NFT from a desired Guard group depending on which button was used. Note that mint_groups array should be filled with String texts of the group names, and the mint_buttons will be mapped to them.

For a full example with fetching the candy machine data, getting the callback of whether mint was success or fail and more, check SolanaSDK -> Demos -> CandyMachineDemo in the imported SolanaSDK addon!

@export var candy_machine_id:String
@export var candy_guard_id:String
@export var guard_settings:CandyGuardAccessList
@export var mint_groups:Array[String]
@export var mint_buttons:Array[Button]

func try_mint(pressed_button:Button) -> void:
	var button_index = mint_buttons.find(pressed_button,0)
	
	if guard_settings==null:
		push_error("Missing Candy Guard File")
		return
		
	var tx_id:String = await SolanaService.candy_machine_manager.mint_nft_with_guards(
		Pubkey.new_from_string(candy_machine_id),
		Pubkey.new_from_string(candy_guard_id),
		cm_data,
		SolanaService.wallet,
		SolanaService.wallet.get_kp(),
		guard_settings,
		mint_groups[button_index]
	)

Last updated