I have a project where I need to integrate image files, such as JPG or PNG, into the metadata of a NonFungibleData structure in Scrypto. I’m unsure of the best method to achieve this. Should I use Decimal for conversion, or would a HashMap be more effective to store the image data? I’ve experimented with various approaches but haven’t found the most efficient way yet. Any advice on how to effectively include image data in NFT metadata would be greatly appreciated. What types work best for representing binary images in Scrypto?
Wait, I’m curious about your specific use case - why embed images directly instead of using external storage? Are you working on something where you need guaranteed permanence without relying on IPFS nodes staying up?
If you’re set on embedding them, what size images are we talking about? Tiny 32x32 pixel art or full resolution photos? That’ll make a huge difference in how viable this is.
Also wondering - are these images changeable after minting or permanent? That might influence how you structure your metadata. Have you thought about using base64 encoding within a String field instead of raw Vec? Sometimes that plays nicer with off-chain tools reading the metadata.
What transaction fees are you seeing when you test your current approaches? Would love to hear what you’ve tried and what problems you ran into!
yo, dont embed images directly in the NFT metadata. its super expensive! better to upload them to IPFS and just use the link or hash in there. if u gotta include it though, Vec works for binary data, but just think about it again, alright?
The IPFS suggestion above is solid for most situations. But if you really need to embed images directly in your NFT metadata, Vec is the right type for binary data in Scrypto. Decimal won’t work - it’s for numbers only. HashMap is overkill for simple binary storage. Just heads up: storing large binary files on-ledger will jack up your transaction costs and bloat the ledger. Compress your images first or use smaller thumbnails if you can’t avoid direct embedding. For production apps, external storage with content hashes is still the industry standard.