I would like to know how I can set a threshold of 10 entries so that it's the maximum number of values that can be stored in a StorageMap structure.

My struct is the following:

pub type CoinStorage<T> = StorageMap<_, Blake2_128Concat, AccountIdOf<T>, Coin, OptionQuery>;

2 Answers 2


In general it is the easiest to use a CountedStorageMap and check the number of entries before insertion, as the type itself does not enforce the limit.

Using a StorageValue<_, BoundedBTreeMap can be not ideal for parachains, since it will always load the whole value into the Proof, even when only a single element is accessed.
This implies that the number of elements must be configured to be conservatively low.


you could store BoundedBTreeMap in StorageValue:

pub type CoinStorage<T> = StorageValue<_, BoundedBTreeMap<AccountIdOf<T>, Coin, ConstU32<32>>, OptionQuery>;

I think it would have the same complexity for insertion/deletion as StorageMap - O(logn)

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.