2

I am trying to attach metadata uploaded to arweave to a token. I am using createCreateMetadataAccountV3Instruction from @metaplex-foundation/mpl-token-metadata, but I am getting an error.

This is the fc

createCreateMetadataAccountV3Instruction(
      {
        metadata: pda,
        mint: mintKeypair.publicKey,
        mintAuthority: mintAuthority,
        payer: payer.publicKey,
        updateAuthority: mintAuthority,
      },
      {
        createMetadataAccountArgsV3: {
          data: ON_CHAIN_METADATA,
          isMutable: true,
          collectionDetails: null,
        },
      }
    )

what I am unsure of

  1. where to get pda? All I'm doing rn is const pda = await metaplex.nfts().pdas().metadata({ mint: wallet.publicKey }); but I am not sure this is the correct way

  2. what is collectionDetails: null? I put null because I do not know

ERROR I am getting:

'Program log: IX: Create Metadata Accounts v3',
    "Program log: panicked at 'range end index 36 out of range for slice of length 0', library/core/src/slice/index.rs:73:5",
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 7998 of 972240 compute units',

1 Answer 1

1

Instead of wallet.publicKey, you should be using the mint address of the token you're trying to create a metadata account for. The address of the metadata account is derived using the token mint address.

const pda = await metaplex.nfts().pdas().metadata({ mint: TOKEN_MINT_ADDRESS })

https://docs.metaplex.com/programs/token-metadata/overview#nfts

enter image description here

collectionDetails is only used for NFTs to specify a "collection nft". Its correct to leave as null if you are creating the metadata account for a fungible token. You can read more about metaplex collections from their docs.

https://docs.metaplex.com/programs/token-metadata/certified-collections#collection-nfts

enter image description here

Also, the data for createMetadataAccountArgsV3 should be in the format of the DataV2 type from @metaplex-foundation/mpl-token-metadata

For example:

const ON_CHAIN_METADATA= {
  name: "Token Name",
  symbol: "SYMBOL",
  uri: uri, // this is the uri to the offchain metadata
  sellerFeeBasisPoints: 0,
  creators: null,
  collection: null,
  uses: null,
} as DataV2
createMetadataAccountArgsV3: {
  data: ON_CHAIN_METADATA,
  isMutable: true,
  collectionDetails: null,
}

https://docs.metaplex.com/programs/token-metadata/overview#a-json-standard

enter image description here

Your Answer

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

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