What is the equivalent in Daml to DB sequences?

G-d willing

I need each instance of a specific contract to have a unique id. Is there anything in Daml that implement it?
In databases we have auto-incremented sequences… I was thinking, is there something similar in Daml?

Hi @cohen.avraham,

A Daml application is, by nature, a distributed application. That means you cannot assume a “global” point of view, which in this case in turns means you cannot, in general, guarantee that all contracts of a given template have a different (much less “auto-increment”) value for a given field.

If you trust all of the parties involved to “play by the rules”, a possible solution would be to have a Text field in your contract that gets populated by a UUID generated client-side. The probability of collision on UUIDs is low enough that this should work out to unique IDs for all practical intents and purposes, as long as there is no deliberate fudging.

The contract ID is unique; perhaps you can exploit this.

Hi @Stephen, for my use case it’s not, but thanks anyway