0

I am about to make the decision on how to store some hash value inside the blockchain. A hash value is the best practice to minimise the size of the blockchain, but still allows people to verify information.

I used the following approach in the past:

[u8; 16]

I found, that in the pallet_democracy there is the following approach:

<T as frame_system::Config>::Hash

What way of storing information on-chain is the best, and why?

1 Answer 1

2

When you use <T as frame_system::Config>::Hash you will use the Hash as configured in your runtime. The advantage of this is that it will make your pallet generic over the hashing algorithm to use. If you only use [u8; 16] you need to have the hashing algorithm hard-coded to ensure that the hash is only 16 bytes.

Depending on what you are trying to do, there is no downside of any of the solutions. Storage size will only depend on the length of the hash you are using. If you directly specify [u8; 16] or use a hash that is 16 bytes the storage usage will be exactly the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.