How Daml smart contracts are digital twins of human relationships
Pacta sunt servanda - also in the distributed digital world
Part of the challenge I face daily is that I want to explain to partners and clients the essence and benefits of shared transaction systems in general and Daml-driven applications in particular.
Different conversations require different approaches:
- Some people don't know much about business process digitalization and take for granted that some background processes must be in place, supporting the applications they use daily. They experience firsthand that such processes sometimes fail, but if it doesn't happen too often, they are willing to accept such failures as part of the human condition.
- Some people know a lot about the usual workflow implementations and think this is all there is to it. "We've been doing it for 15 years, what's the news?" - I got asked recently.
- Some people have heard about "blockchain" and "smart contracts," and they take it for granted that the essence of blockchain is the immutable data secured by a "chain of blocks," and that "smart contracts" are neither smart nor contracts (which is valid for many implementations, by the way).
- Some people have heard about the "trustless" nature of blockchain, and think every ledger eliminates all trusted intermediaries.
- Some people find that the usual kind of application software implementing complex business scenarios is hopelessly complicated.
The common denominator: the “agreement mental model”
It might seem impossible to find a common denominator for such diverse audiences. But luckily, there is a shared mental model that is inclusive enough to resonate with a wide array of audiences, and specific enough to explain the essence and benefits of shared transaction systems.
I call this "the agreement mental model." It seems to be so common that none of the famous mental model collections (like eg Farnam Street) feature it, suggesting it doesn't have a place beside "standing on the shoulders of giants" and the like - but I hope I can convince you it does have a place in the hall of fame of mental models. (Italian people seem to have a special sense for the importance of agreements: they gave the world the proverb "Patti chiari, amicizia lunga”.)
In the following sections, I will show how agreements are indispensable for our everyday life, how useful and at the same time how intricate they can become in a digital world, and explain how applications running on the open-source Daml platform implement them–with the added benefit that Daml models can run on public ledgers (including the most popular among them, Ethereum), private consortium blockchain systems and centralized databases.
The basis of the "agreement mental model" is "the strength of weak ties." We interact daily with people with whom we don't have a lasting relationship. Still, we rely on them to sort out sometimes significant matters.
Sometimes the people we interact with represent an organization with which we have signed General Terms and Conditions. Still, in the actual interaction, it's not always easy to take effect on them.
More often, we follow implicit rules without a formal agreement, generally not being able to make a list of the exact conditions. The legal jargon knows such expressions as "oral contract" and "implied contract." Nick Szabo, the father of smart contracts, uses the term "contracts embedded in the world," referring to hardware and software, which makes it expensive to breach interaction rules.
Signing traditional contracts written on paper "with wet ink" and going to court to enforce them is costly. It's outright impossible to do so for every interaction we have with half-strangers. So if we can bake in the agreement mental model into our transactions at a fundamental level, it also means we can drive down transaction costs substantially.
Agreements can become quite intricate in the following cases:
- Sometimes we want to delegate our rights. In the legal jargon, the name for this is the "power of attorney," although we use it much more often than we see our attorneys.
- Sometimes we wish to form agreements with more than one party, where the rights and obligations between one set of parties depend on the interactions between another set of parties.
- Often, we want the performance of our duties to be mutual: we don't want to risk giving something without the assurance of reciprocation.
Nowadays, many of our interactions are digital, often between parties in different jurisdictions, which exacerbates the concerns around the possible consequences and enforceability of our agreements.
Implementing agreements in Daml
It's important to note that in everyday parlance, "contract" and "agreement" are synonyms, which isn't the case in the Daml vocabulary.
For a Daml modeler, everything is a contract. Contracts are the basic units for recording milestones of relationships, with authorization about who can make the next moves. A Daml contract can be the digital equivalent of a possibly unilateral legal statement, such as an offer, a disclaimer, or a will.
For a Daml contract to be an agreement, we need at least two parties who sign it. And this part seems for the uninitiated quite a mystery.
Forming agreements signed by two or more parties is made possible by a couple of features of Daml contracts and the Daml ledger model.
One trick is that Daml contracts can have a variable set of signatories and have a feature called "flexible controllers." The initiator of a multi-party agreement can make all the intended signatories observer on a contract, and allow them to archive and recreate the proposal contract in a way that they add themselves to the set of signatories. In this way, in every step, the intermediary contract is well authorized.
On the other hand, a contract with a variable set of signatories is not safe in a legal sense because the rights and obligations of the parties can change along the way. That's where another smart trick comes in: one contract can carry another contract as payload. This feature makes it possible that one contract with a variable set of signatories carrying another contract (with a fixed set of signatories and the data and rules of the intended multi-party agreement) doubles as an offer contract. The details of this design, which is called the "offer-acceptance pattern," is explained in detail in the Daml documentation.
This is how this mechanism is shown in the Daml documentation:
Multiple Party Agreement Diagram
Under the hood, the Daml ledger model is at work. It is a way of implementing the principle of "pacta sunt servanda," put differently, the basic principles of contract law:
- Obligations need consent
- Consent is needed to take away on-ledger rights
- On-ledger obligations cannot be unilaterally escaped.
As a visual metaphor, we can think of a space shuttle and its carrier. The function of the carrier is just getting the shuttle off the ground, which realizes the real mission. The following meme depicting this was created by Anthony Lusardi of Digital Asset, inspired by the author of this article.
Daml Multiple Party Agreement Meme
Daml agreements are no cul-de-sacs
When we enter an agreement, we want to know if and how we can get out of it, if circumstances change.
This happens the same way with Daml contracts as with traditional contracts: the options to terminate an agreement must be included in the contract template in advance. For Daml contracts this means that we have to include choices in the contract template for any party to archive it after the expiry date, or other ways to archive it, given the prescribed conditions.
Daml has also a new learn section where you can begin to code online: