Creating custom NFT properties with splToken.Token.createMint in Solana web3 SDK

Hey everyone, I’m working on a Solana project and I’m stuck. I’ve been using the splToken.Token.createMint function from the solana-web3 SDK to create tokens. I can get the transaction ID and signature, and I can see them in the explorer. But I’m not sure how to add custom properties to my NFT like name, symbol, and image URI during the minting process.

I’ve looked into metaplex and the token-metadata standard, but there’s not much info out there for Solana. Can anyone point me in the right direction? Here’s a simplified version of what I’m working with:

const mint = await splToken.Token.createMint(
  connection,
  wallet,
  wallet.publicKey,
  null,
  9,
  splToken.TOKEN_PROGRAM_ID
);

await mint.mintTo(
  tokenAccount.address,
  wallet.publicKey,
  [],
  1000000000
);

How can I add custom metadata to this process? Any help would be awesome!

To add custom properties to your NFT, you’ll need to utilize the Metaplex Foundation’s metadata program. After minting your token, create a separate transaction to attach metadata. Here’s a general approach:

Install the @metaplex-foundation/js package; use the createMetadataAccountV2 instruction from Metaplex; construct a transaction with the required metadata (name, symbol, URI); then sign and send it. The URI should point to a JSON file containing additional NFT details such as the image link. This process occurs post-minting, so plan accordingly if you’re minting multiple tokens.

hey WhisperingTree, for adding custom metadata to ur nft, you’ll need to use the Metaplex Foundation’s tools. Check out their @metaplex-foundation/js package. It provides methods to create and update metadata for ur token. You’ll need to create a separate transaction to add the metadata after minting. hope this helps!

hey whisperingtree! i’ve been messing around with nfts on solana too and ran into the same issue. have you checked out the metaplex js sdk? it’s pretty handy for adding metadata to your tokens after you mint them.

what kind of nft project are you working on? i’m curious about the custom properties you want to add. are you doing anything cool with the metadata?

btw, have you considered using candymachine for minting? it can make the whole process a bit easier, especially if you’re planning to mint a bunch of nfts. just a thought!

let me know if you figure it out. i’d love to hear how your project turns out!