And now all together: an introduction to conjunction choices

Digital Asset
May 1, 2019 · 5 min read

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:

Image for post
Image for post

If 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:

Image for post
Image for post

The 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

Image for post
Image for post

Note 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:

Image for post
Image for post

There’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:

Image for post
Image for post

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

Image for post
Image for post

Donna 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:

Image for post
Image for post

In 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:

Image for post
Image for post

The 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.

Follow us on Twitter; join the community and download the DAML SDK at www.daml.com.

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.

DAML Driven

The developer’s choice for building safe, concise smart…

Digital Asset

Written by

The leading provider of Distributed Ledger Technology for multiple industries. digitalasset.com

DAML Driven

The developer’s choice for building safe, concise smart contracts

Digital Asset

Written by

The leading provider of Distributed Ledger Technology for multiple industries. digitalasset.com

DAML Driven

The developer’s choice for building safe, concise smart contracts

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store