-1

Given a candy machine address how do you find the name of the collection?

https://explorer.solana.com/address/6TNFBdZR3kBYDxpqFkTVxVykk4ugUxL5xm7YnzWQ32WZ?cluster=devnet

Here's an example of the metadata on one of the tokens.

{
    "name": "Tara Base Card",
    "description": "Tara universe is a demo project to showcase the power of Meta Blocks Protocol. This base card is where the story begins.",
    "image": "0.png",
    "attributes":
    [
        {
            "trait_type": "texture",
            "value": "futuristic"
        },
        {
            "trait_type": "slots",
            "value": 4
        }
    ],
    "symbol": "TaraBase",
    "seller_fee_basis_points": 1000,
    "collection":
    {
        "name": "Tara Universe",
        "family": "Meta Blocks Samples"
    },
    "properties":
    {
        "files":
        [
            {
                "uri": "0.png",
                "type": "image/png"
            }
        ],
        "category": "image",
        "creators":
        [
            {
                "address": "6JbtQgSifp1ibwXbMVJJWjry1YoSaoSLSMTkYQjsyzUA",
                "share": 100
            }
        ]
    }
}
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Berry Blue
  • 15,330
  • 18
  • 62
  • 113

1 Answers1

1

this is the only api. it does return symbol but name:

import {Metaplex,bundlrStorage,PublicKey} from "@metaplex-foundation/js";
import { Connection, clusterApiUrl, Keypair } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("devnet"));
// create file: solana-keygen grind --starts-with com:1
const wallet = loadKeypairFromFile(
  "comowiMU9UhzUoR5hMwxWxqafip9P6TBC9zoYo5oLfb.json"
);

const metaplex = Metaplex.make(connection)

metaplex
  .candyMachinesV2()
  .findByAddress({
    address: new PublicKey("6TNFBdZR3kBYDxpqFkTVxVykk4ugUxL5xm7YnzWQ32WZ"),
  })
  .then((a) => console.log("Res", a));

this is the returned object

{
  model: 'candyMachineV2',
  address: PublicKey [PublicKey(6TNFBdZR3kBYDxpqFkTVxVykk4ugUxL5xm7YnzWQ32WZ)] {
    _bn: <BN: 510b8e93f13d198a6d62acd0d3890cc56420b217815d36cab19dbc61922ea776>
  },
  programAddress: PublicKey [PublicKey(cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ)] {
    _bn: <BN: 92aee3dfc2d0e55782313837969eaf52151c096c06b5c2a82f086a503e82c34>
  },
  version: 2,
  authorityAddress: PublicKey [PublicKey(aSfeXQytfVRCEHzohn3ykow3b3bvSkaRNqmgF2w9JCe)] {
    _bn: <BN: 891300da283022cb7559be01375e58b1c286381dcde9a20732a3c2187e0eb47>
  },
  walletAddress: PublicKey [PublicKey(aSfeXQytfVRCEHzohn3ykow3b3bvSkaRNqmgF2w9JCe)] {
    _bn: <BN: 891300da283022cb7559be01375e58b1c286381dcde9a20732a3c2187e0eb47>
  },
  tokenMintAddress: null,
  collectionMintAddress: PublicKey [PublicKey(68XYH4hN4uhP4gXB6XrBPo5dt7VvwxzeueJQbJ6iZztg)] {
    _bn: <BN: 4c3807f91328121ef1b0646068d90ccae2310f532dfeb087a2f3ea09b01245a9>
  },
  uuid: '#00000',
  price: {
    basisPoints: <BN: f4240>,
    currency: { symbol: 'SOL', decimals: 9 }
  },
  symbol: 'TaraBase',
  sellerFeeBasisPoints: 1000,
  isMutable: true,
  retainAuthority: true,
  goLiveDate: <BN: 61c65f00>,
  maxEditionSupply: <BN: 0>,
  items: [],
  itemsAvailable: <BN: 5>,
  itemsMinted: <BN: 0>,
  itemsRemaining: <BN: 5>,
  itemsLoaded: <BN: 0>,
  isFullyLoaded: false,
  endSettings: null,
  hiddenSettings: null,
  whitelistMintSettings: null,
  gatekeeper: null,
  creators: [
    {
      address: [PublicKey [PublicKey(6JbtQgSifp1ibwXbMVJJWjry1YoSaoSLSMTkYQjsyzUA)]],
      verified: true,
      share: 100
    }
  ]
}
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
  • If you need the collection name itself, you can take the mint address (in the above example that would be 68XYH4hN4uhP4gXB6XrBPo5dt7VvwxzeueJQbJ6iZztg), calculate the metadata PDA from it and then fetch the metadata object from the chain. The name of the collection is stored on the metadata object of the collection mint. – neft.world Mar 02 '23 at 13:41