Reactive Java -> other TransactionFilter than FiltersByParty

Hello daml forum!

Using the java reactive library, I am trying to filter my calls to the daml ledger to be more efficient.
Filtering on Java side is easy, but it has come as a requirement to feed the function

                                                new FiltersByParty(Collections.singletonMap(this.partyName,

with something better than FiltersByParty to avoid retrieving too many contracts.

Is this a correct approach and actually reducing the load on the daml ledger? If yes:

Checking the documentation ( TransactionFilter (, it seems FiltersByParty ( is the only implemented solution.

How would one implement a new TransactionFilter or where could I have a look at the FiltersByParty code to make my Implementation?

Thank you,

Kind regards,


The only dimension across which the Ledger API allows you to filter are template and party. The Ledger API has relatively light querying capabilities in order to have predictable and steady performance when serving a very disparate array of contracts.

FiltersByParty is basically an idiomatic version for the Java bindings of this kind of filtering which is offered natively from the Ledger API, it’s not possible to have some kind of different implementation that could offer richer querying capabilities since those are not provided by the Ledger API.

If you want to enable more fine grained and efficient querying for specific fields of a contract the solution is to usually store the contracts for a given template in a separate data store that acts as some sort of read replica of the ledger and has rich query capabilities that match your application’s requirements.

Thank you for your quick answer.

Would you know the “filter by template” equivalent using java bindings?

I currently do that filtering post-query, so combining it with the request would already be an improvement.

FiltersByParty wraps a map from party names (as Strings) to the filters to be applied for that party, with the only implementations of those being InclusiveFilter, which is itself a wrapper for a Set of template Identifiers that will be retrieved for that party. For example, you can specify a filter that allows you to retrieve all the Foos for Alice and all the Foos and Bars for Bob (provided you have the necessary authorization to readAs those parties).

1 Like