looks like a classic pubkey initialization issue tbh. try wrapping your nftAddress in a try-catch when creating the PublicKey - sometimes the string format gets messed up. also make sure you’re using the actual mint address from the nft object, not some other property that might look like an address but isnt
I ran into this exact same error a few months back and it drove me crazy for hours. The issue is almost certainly that you’re passing the wrong address type to the update function. When you mint an NFT, the response contains multiple addresses and you need to be careful about which one you use. In your minting code, try logging the full nft object structure - you’ll probably see properties like address, mint.address, and metadataAddress. For the update function, you specifically need the mint address, not the metadata address or token address. Try this modification to your update code: javascript const modifyNftData = async() => { const nft = await metaplex.nfts().findByMint({ mintAddress: new PublicKey(nftAddress) }); const { updatedNft } = await metaplex.nfts().update({ nftOrSft: nft, uri: "https://arweave.net/def456updated" }); } Passing the full nft object instead of just an address usually resolves the toBuffer error because the SDK has all the context it needs. The findMetadataPda function is failing because it’s receiving an undefined or malformed PublicKey object.
hmm this is interesting - i’ve seen this toBuffer error pop up before and it’s usually related to how the PublicKey is being handled or passed around.
quick question though - are you sure the nftAddress you’re using is actually valid? i mean, when you log nft from your minting function, what does the address look like? sometimes the issue is that we’re trying to use the wrong address format or the address isn’t what we think it is.
also, just curious - have you tried logging the tokenAddress right before calling the update function? like:
the reason im asking is because sometimes the nft address from the minting response might not be the token address you need for updates. in metaplex, there’s usually a difference between the mint address and the metadata account address, and the update function might be expecting somethign specific.
another thing - which version of @solana/web3.js are you using alongside metaplex? version mismatches can sometimes cause weird buffer-related errors like this.
what happens if you try to fetch the nft first before updating it? does something like await metaplex.nfts().findByMint({ mintAddress: tokenAddress }) work?