Uniqueness of a contract Key
I read through this tutorial on property rentals written in DAML (love this end to end tutorial example btw) and noticed the use of party as well as text for a contract key. Here’s the specific code.
key (agency, registerId) : (Party, Text)
maintainer key._1
I presume this helps create more uniqueness for a key to avoid conflicts? I thought this was a good idea so I implemented this in my code as well but then I came to the realisation that in the rental application example, a rental licence is probably only offered to each party once(?)
Whereas in my app, I have agents that can issue multiple proposals and I wanted to setup a key that would be unique via agent and the proposaliD. I.e. it’s the difference between a one-to-one relationship and a one-to-many.
So my question is: is it necessary for me to take things a step further in some way or is the code example above a good enough solution?
I did notice the increment function but I wasn’t sure if this would be a little overkill?
Hope my question makes sense?
Note that the agency is a key maintainer. Maintainers are a fundamental part of the key. You can read more about them on the documentation, as they are central to ensuring key uniqueness in a decentralized network where you cannot have any form of global visibility.
From what I can read, it sounds like your agents can work as the key maintainer in your app.
This thread on the forum may also contain interesting information for you.
OK, I think I understand this better now