Let me see if I understand your requirements here. You have a predefined token, and a bunch of parties who are expecting a contract with that token as the key. In your ideal world, the key for the contract would be just that token, and everyone interested (among the authorized parties) could retrieve the contract using that token, with no regard for who created said contract.
But DAML gets in your way because it requires the key to contain a Party, and using the creator of the contract as the party here makes the contract impossible to find.
We can’t get around the fact that a key needs a maintainer — @bernhard can explain the reasons better than I, but it essentially boils down to the fact that we’re in a distributed system so we need to have someone we can ask for the contract with that key.
One option here would be to have a “central” authority, i.e. a party whose job is to publish the tokens and sign the contracts; perhaps something like:
module Main where
nonconsuming choice CreateTopic : ()
assert $ proposer `elem` clients
create Topic with token, proposer, observers = clients, operator
observers : [Party]
key (operator, token) : (Party, Text)
nonconsuming choice Demo : ()
do return ()
test = script do
alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
charlie <- allocatePartyWithHint "Charlie" (PartyIdHint "Charlie")
reg <- submit alice do
createCmd Registry with clients = [alice, bob, charlie], operator = alice
submit bob do
exerciseCmd reg $ CreateTopic with proposer = bob, token = "blabla"
submit charlie do
exerciseByKeyCmd @Topic (alice, "blabla") Demo with p = charlie
So the maintainer is always the same and you don’t need to pass it around.