4

I'm trying to understand how CM works in theory. As much as I understand, smart contracts can't make internet calls so we have to store data in blockchain in order to access it. Therefore I am assuming all CM data (all those jsons, png links) must be stored in Solana blockchain first.

So, BEFORE MINT, all mintable NFTs metadata must be somewhere on chain. I want to find out how. Is it like 1 NFT Metadata = 1 Account or is like all collection metadata stored in 1 account? How does that work?

CMv3

I'm trying to find out how are these items are stored.

1 Item = 1 Account

OR

all items = 1 Account (everything stored in a huge vector in one account)

1 Answer 1

2
+100

It differs a bit depending on which candy machine version you are talking about. This answer is for the latest version candy machine v3 (which is split into candy core and candy guards. The NFT data is stored in Candy Core, Candy Guards are used to control the minting conditions):

The Data for all NFTs that can be minted from one machine is stored in one Candy Core Account. You can find more Info on the account structure in the code. The Account generally looks like this

pub struct CandyMachine {
    /// Features versioning flags.
    pub features: u64,
    /// Authority address.
    pub authority: Pubkey,
    /// Authority address allowed to mint from the candy machine.
    pub mint_authority: Pubkey,
    /// The collection mint for the candy machine.
    pub collection_mint: Pubkey,
    /// Number of assets redeemed.
    pub items_redeemed: u64,
    /// Candy machine configuration data.
    pub data: CandyMachineData,
    // hidden data section to avoid deserialisation:
    //
    // - (u32) how many actual lines of data there are currently (eventually
    //   equals items available)
    // - (ConfigLine * items_available) lines and lines of name + uri data
    // - (item_available / 8) + 1 bit mask to keep track of which ConfigLines
    //   have been added
    // - (u32 * items_available) mint indices
}

Part of the candyMachineData is the following configLine struct where each configLine is the Data for one NFT.

pub struct ConfigLine {
    /// Name of the asset.
    pub name: String,
    /// URI to JSON metadata.
    pub uri: String,
}

When an NFT is minted the Config Line and general data (like creators) is read from this Account to create the NFT.

Also be aware that with v3 not the whole Name or URI has to be stored. You can also work with prefixes for both to save space.

tl;dr: all items = 1 Account

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.