Storing metadata hash of length more than 32

Hi Everyone,

I was trying to build an application using assets feature. But one of the function I would like to use is to store a long array in the metadata hash field but it has to be base64 encoded but with a restriction of length 32. But I find it difficult cause the length is always more. Any ideas how to go about with the type conversion so I could place the data there and get it back.

Thanks.

Hi @anupcoded,

One solution is to store your full metadata somewhere else, and just provide a URL to the full metadata and a hash of the metadata in the actual asset metadata.

You may consider using IPFS to store the full metadata.
If the full metadata is shorter than 512 bytes, you may also use the note field of another transaction (and point to this transaction in the asset metadata).

Another way without using note field which belongs to transaction context, would be converting IPFS CID to 32 bytes strings that fits both metadatahash and url fields (although on 2.7.1 URL is extended to 96 bytes).
ipfs2bytes32 GitHub repository
ONLINE DEMO

In more complex scenarios URL (96 bytes since 2.7.1) can hold ASA service endpoints which are actually URls and metadatahash field can hold onto IPFS CID (which can be converted to 32 bytes and fits now).