storage { k: User v: Vec<Item> }

If I want to give a unique identifier to the item.

Can I use UnixTime::now()?

If the user sends a batch tx and it creates two items. Will their identifier be different?

  • Are you talking about a StorageMap? Why can you not use an ever-increasing counter? Nov 30, 2022 at 17:53

1 Answer 1


Timestamp sounds strictly worse than the block number, but this is even not good enough.

We use something called a "timepoint" in the multisig pallet, which is:


/// A global extrinsic index, formed as the extrinsic index within a block, together with that
/// block's height. This allows a transaction in which a multisig operation of a particular
/// composite was created to be uniquely identified.
    Copy, Clone, Eq, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen,
pub struct Timepoint<BlockNumber> {
    /// The height of the chain at the point in time.
    height: BlockNumber,
    /// The index of the extrinsic at the point in time.
    index: u32,

This will not work with a batch call, since all the extrinsics in the batch will have the same height and index. In that case, you should track your own unique id, like a u32 counter, in the pallet you are concerned about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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