Share contract Id in Multi-Party Signature design pattern with java bidings

Hello.
If you have several parties who have to sign a contract, for example in the multi-party signature design pattern, what is the best way for all of them to have access to the current contract and not to one already archived when using java bindings?

In my case, the number of parties that have access to the contract to sign is very large and the number of parties that have to sign is low.

Thank you very much.

Hi @Nunobrazz welcome to the Daml forums. Your question suggests that you have already tried something which didn’t get you the desired results. Are you able to share what you tried and what went wrong?

Hi @bernhard my first approach was to make each party probe the contract (Invitation), and update the variables where I keep the current active contractId and the contract data, using the same logic that is in the quickstart example, which is essentially:

 client
            .getTransactionsClient()
            .getTransactions(
                Invite.contractFilter(), acsOffset.get(), Collections.singleton(myParty), true)
            .forEach(
              t -> {
                for (Event event : t.getEvents()) {
                  if (event instanceof CreatedEvent) {
                    CreatedEvent createdEvent = (CreatedEvent) event;
                    long id = idCounter.getAndIncrement();
                    Invite.Contract contract = Invite.Contract.fromCreatedEvent(createdEvent);
                    invitations.put(id, contract.data);
                    invitationsCids.put(id, contract.id);
                    System.out.printf("New invitation created!");
                  } else if (event instanceof ArchivedEvent) {
                    ArchivedEvent archivedEvent = (ArchivedEvent) event;
                    long id =
                        invitationsCids.inverse().get(new Invite.ContractId(archivedEvent.getContractId()));
                    invitations.remove(id);
                    invitationsCids.remove(id);
                    System.out.printf("One invitation was archived!");
                  }
                }
                });

However, this approach makes it harder to verify whether the new contractId created is from a new invitation or an older invitation that was signed. It will also create a big message exchange without necessity. In java is there a way where each party can just receive the contracts that are not signed by the other invites ? Or do I have to create a new template for that ?

Thank you and regards

What you are doing is the way to maintain the current state in-memory. If you are using Daml Enterprise, PQS maintains this for you in a database so you can just query current state using jdbc.