Triggers - Query Contracts without generating events

In my Trigger, I want to query contracts, but i dont want to list those templates under the registeredTemplates section. I tried this, but the query unregistered templates doesnt return any contracts. But if i register this template, then it will also generate an event each time this template creates a contract, and i want to avoid that.

The use case is more like syncing two set of contracts(Think like i am syncing two separately developed daml models) . Say the first set has a template called deposit, against which i need to sync the second set of contracts. The flow I want to achieve is this

Deposit Contract creation -> Trigger the Rule
            ----> In the Rule
                            ------> Query the tokenoffer template, 
                                          Exercise choice Buy on Tokenoffer

The problem occurs, when the trigger exercise choice Buy, which results in multiple contracts, including a new token offer with the balance quantity. So if the token offer template is registered, this will trigger a new event.

You’re thinking in terms of triggers, which Triggers are not meant for. A better way to approach Triggers is to think of them as rules, or invariants you want to enforce.

From that perspective:

  • Trigger mechanisms are just an optimization: conceptually, your rule would be enforced at all times, but in practice that’s a bit inefficient, so your triggers should be tailored to the type of events that may invalidate your invariants.
  • Registered templates should cover all of the templates over which you want the invariants to hold, because only those templates will be available. Think of registered templates as a subset of the full ACS, rather than “triggers on create”.
  • Since your rule’s purpose is to enforce invariants, it should be perfectly fine for it to run when the invariants are already holding, in which case the rule can simply do nothing.