May 1, 2019

And now all together: an introduction to conjunction choices

By Martin Huschenbett
. May 1, 2019

And now all together: an introduction to conjunction choices


Continuing our insider look at DAML’s authorization system

In a previous blog post, we introduced a few changes that were made to DAML’s authorization system. In this post we’ll discuss the first, conjunction choices, discussing what motivated this new feature and explaining its usage by walking through a slightly extended version of the PaintHouse example from the DA Ledger Model documentation. The full code of the example can be found in this GitHub Gist.

Painting the house the clean way

We all know that painting a house can get quite messy and hence we not only want to hire a painter but also a cleaner:

1If you wanted to get an instance of a contract with three signatories on the ledger in older versions of DAML, you needed to use a proposal chain with at least two more contracts. Not so with conjunction choices—the owner can now make a proposal which contains a choice that can only be accepted by painter and cleaner when they authorize it simultaneously:

2The interesting bit is the controller [painter, cleaner] can clause. This new syntactic form defines a choice that can only be exercised when both the painter and the cleaner authorize it (hence the name conjunction choice). Since the Ledger API only allows single submitters, we can’t exercise this choice through the Ledger API directly. What we need instead is some delegation contract.

Setting up a small cooperative

In fact, the painter and the cleaner might work together on a regular basis and the cleaner is happy to accept any PaintHouse job that is offered to the painter as long as the price is above some threshold. We can codify this as

3Note that conjunction choices are exercised exactly the same way as ordinary choices in the last line. To get an instance of this contract on the ledger, we use the proposal pattern once more:

4There’s nothing new here.

Make Alice’s house a wonderland

Let’s have a look at this in action. First of all, we set up a relationship between the painter Bob and the cleaner Carl for jobs that are worth at least $500:

5Next thing that happens is that Alice wants to get her big house beautifully painted for $1000 and Bob happily accepts this job:

6Donna wants in on the action too

After hearing that Alice got her house painted by Bob, Donna wants her place to be freshly painted by Bob as well—but Bob’s regular cleaner Carl is overbooked, so she asks Bob to work with her friend Eric to do the cleaning. Unfortunately, Eric is also unavailable, and—as we would hope—any of Bob’s attempts to force Eric into this job fail:

7In the end, Donna still wants her place painted by Bob and in the absence of anyone available to clean up she is able to convince Bob to do the cleaning himself for a larger fee:

8The interesting bit about this is that Bob can exercise the choice on his own even though it is a conjunction choice because he’s the only controller of it.

Read the first story in this series

Read the next story in this series

Join the community and download the DAML SDK at daml.com

This story was originally published 1 May 2019 on Medium

About the authors

Martin Huschenbett, Ph.D. – Senior Software Engineer – Language Engineering, Digital Asset

Martin joined Digital Asset’s language engineering team in 2017, where he works on the DAML compiler and authorization checker. Previously, as a member of the trading systems team for the proprietary trading firm Jane Street Capital in London, he contributed to the research infrastructure used by the quantitative analysts, and the monitoring systems for the compliance team.

Martin holds a Ph.D. from Technische Universität Ilmenau in Germany, where he worked as a research associate at the Department of Theoretical Computer Science. His academic work included research and teaching primarily in the fields of computational logic, automata theory and formal verification. He held a postdoctoral position at the Ludwig-Maximilians-Universität München prior to joining Jane Street Capital.

Robin Krom, Ph.D. – Senior Software Engineer – Language Engineering, Digital Asset

Robin is a member of the language engineering team at Digital Asset concerned with developing and evolving the DAML language.

Prior to joining Digital Asset, Robin finished his Ph.D. in Mathematics at ETH Zurich, where he explored new ways towards proving the uniqueness of symplectic structures on closed 4-dimensional manifolds in a fixed cohomology class. He is very much interested in pure and applied mathematics, especially in computer science and loves coding in Haskell.


Join the DAML mailinglist to get occasional updates on announcements and new releases