Search code examples
blockchainmetadataipfsnfthedera-hashgraph

Process NFT metadata on hedera chain


I'm trying to get the metadata from the NFT on hedera chain. When creating NFT the CID was converted to unit8array format but when I fetch the data the output is different.

I'm unable to retrieve the original CID value which was in metadata.

link to the output of NFT data: https://testnet.mirrornode.hedera.com/api/v1/accounts/0.0.48797750/nfts

When I check in Hackpack wallet the NFT images are there which are part of metadata, so the data is not lost. I'm just not able to process/get the metadata in proper format.

I tried to convert the input in formats [unit8array] and unit8array but both of them are giving some encoded value.

The output in metadata is neither hex of bin.

I need to convert it to CID so I can display NFT image to the frontend.


Solution

  • I ran into a similar issue recently for one of my projects, after some trial and error I discovered that the value in the meta data field being returned by the API request was actually in base 64, so all I had to do was decode it using Node Js Buffer.from method. I explained the process with an example in a thread. Follow the link below to check it out. devmaesters