I’m stuck trying to get NFT metadata from the Hedera chain. When we made the NFTs, we changed the CID to unit8array. Now when I try to fetch the data, it’s all messed up. I can’t get the original CID from the metadata.
I checked the Hackpack wallet and the NFT images are there. So the data isn’t gone, I just can’t figure out how to get it in the right format.
I’ve tried changing the input to [unit8array] and unit8array, but I keep getting some weird encoded stuff. The metadata output isn’t hex or bin either.
I really need to turn this into a CID so I can show the NFT image on my website. Any ideas how to decode this metadata? I’m totally lost here.
hey there, had a similar issue. try using Buffer.from(metadata).toString(‘hex’) to convert the uint8array back to hex. then you can use that to recreate the cid. might need to tweak it depending on how you originally encoded it. good luck!
hey BrilliantCoder39, sounds like ur in a bit of a pickle!
have u tried using the @hashgraph/sdk library? it’s got some nifty tools for working with nft metadata on hedera. maybe somethin like:
const { TokenNftInfo } = require("@hashgraph/sdk");
const nftInfo = await new TokenNftInfo(tokenId, serialNumber).execute(client);
const metadata = nftInfo.metadata.toString();
that might get u the metadata in a more usable format. just a thought! what kinda website r u building btw? sounds pretty cool if ur workin with nfts! let us know if u figure it out, im curious to see how u solve this 
I’ve dealt with this exact problem before. The key is understanding how the CID was converted to uint8array initially. Have you tried using the js-multihash library? It’s quite useful for handling CID conversions. You’ll want to use the decode function to convert the uint8array back to a multihash object, then extract the digest. From there, you can reconstruct the CID using the appropriate base encoding. Just be cautious about the specific encoding used in your original conversion process. It might take some trial and error, but this approach should get you on the right track.