How to assign Collection Name to NFTs minted via Candy Machine v2 on Solana?

I just made some NFTs using Candy Machine v2 with the sugar tool. But I’m having a weird issue. The NFTs and the Collection NFT got created, but they’re showing up as separate collections. Weird, right?

Here’s a snippet from my cache.json:

{
  "program": {
    "candyMachine": "ABCDE123456789XYZ",
    "candyMachineCreator": "987654321ZYXWVU",
    "collectionMint": "QWERTY098765UIOP"
  },
  "items": {
    "-1": {
      "name": "Cool Gadget",
      "image_hash": "1a2b3c4d5e6f7g8h9i",
      "image_link": "https://example.com/cool-gadget.png",
      "metadata_hash": "9i8h7g6f5e4d3c2b1a",
      "metadata_link": "https://example.com/cool-gadget.json",
      "onChain": true
    }
  }
}

I used sugar mint after this, but when I check on explorers, the collection is different. I tried using metaboss to fix it, but no luck. Even adding Collection items to the NFT’s metadata didn’t work.

Any ideas on how to set the Collection name correctly? I’m stumped!

I encountered a similar issue recently. The problem often stems from the Collection NFT not being properly verified during the minting process. To resolve this, you might need to use the Metaplex CLI to verify the collection after minting. Run ‘metaplex verify-collection’ with the appropriate arguments, including your Candy Machine ID and Collection Mint address. This should link your NFTs to the correct collection. If that doesn’t work, you may need to update the on-chain metadata of each NFT individually. It’s a bit time-consuming, but it ensures everything is properly connected. Remember to double-check your Candy Machine configuration before minting in the future to avoid this hassle.

hey ben, i had a similar issue. try using the metaplex CLI instead of sugar. it’s got a command specifically for setting collection names. run metaplex set-collection with the right parameters. that should do the trick. good luck!