1

I am creating a token mint and was wondering, if i can use the meta plex sdk to upload meta data for it.

I am trying like this.

const mint = await createMint(
  pg.connection,
  pg.wallet.keypair,
  mintAuthority.publicKey,
  freezeAuthority.publicKey,
  9 // We are using 9 decimals to match the CLI decimal default exactly
);

const metaplex = new Metaplex(pg.connection);

const nft = await metaplex.nfts().findByMint({
  mintAddress: mint,
});

const updateResult = await metaplex.nfts().update({
  nftOrSft: nft,
  uri: "https://shdw-drive.genesysgo.net/AzjHvXgqUJortnr5fXDG2aPkp2PfFMvu4Egr57fdiite/PirateCoinMeta",
});

But getting this error:

Uncaught error: The account of type [e] was not found at the provided address [Cp1pypMrwZ5Ba6K6NuQKmPvWQjH46erCSe4gKkUn3ect].

The error doesnt tell me much. Maybe I can only use that function with an NFT that was created with the metaplex sdk which creates some extra accounts?

I can use the createCreateMetadataAccountV3Instruction instruction from '@metaplex-foundation/mpl-token-metadata' but I wanted to see if I can also do that without it.

4
  • Try using sft instead of nft for the nftOrSft arg.
    – kwelliott
    May 19, 2023 at 11:56
  • How do I do that? :D
    – Jonas H.
    May 19, 2023 at 12:08
  • Oh sorry, I thought that was a bool not the actual NFT.
    – kwelliott
    May 19, 2023 at 12:22
  • 1
    The error is likely due to trying to update a metadata account that hasn't been created yet. If you want to create the token manually, not sure if there's a way to avoid having to use mpl-token-metadata like you've mentioned trying to avoid.
    – john
    May 19, 2023 at 17:23

2 Answers 2

3

Ok, I gave up. Now im just using the createSFT function from metaplex instead:

Here is the solution:

import { keypairIdentity, token, Metaplex } from "@metaplex-foundation/js";

const metaplex = new Metaplex(pg.connection).use(
  keypairIdentity(pg.wallet.keypair)
);

const createdSFT = await metaplex.nfts().createSft({
  uri: "https://shdw-drive.genesysgo.net/AzjHvXgqUJortnr5fXDG2aPkp2PfFMvu4Egr57fdiite/PirateCoinMeta",
  name: "Gold",
  sellerFeeBasisPoints: 100,
  updateAuthority: mintAuthority,
  mintAuthority: mintAuthority,
  decimals: 9,
  tokenStandard: "Fungible",
  symbol: "GOLD",
  isMutable: true,
});

let mintResult = await metaplex.nfts().mint({
  nftOrSft: createdSFT.sft,
  authority: pg.wallet.keypair,
  toOwner: pg.wallet.keypair.publicKey,
  amount: token(100 * mintDecimals),
});
1

When updating, you don't need to create a new mint. Rather you just need to update the current mint. You should be able to do this by...

const sft = metaplex.nfts().findByMint({mint: mintPubkeyOfToken})

const update = metaplex.nfts().update({
nftOrSft: sft,
uri: "your uri"
})

Creating a mint isn't actually creating a sft/nft or the metadata accounts... Looks like you've moved on, but if they token is already created, above should help to update the current metadata.

1
  • Yeah that code is what gave me that cryptic error with the normal mint. Do you know whats causing it or how to fix it? What is it expecting to be an sft?
    – Jonas H.
    May 28, 2023 at 19:17

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.