Daml Triggers – Off-Ledger Automation in Daml

In a full-stack Daml application, there usually are two types of components that interact with the ledger in addition to the Daml templates that you upload to the ledger. The first type is a component that provides the link between the ledger and the outside world. This is often just a web UI but it can also be something that integrates with external services, e.g., a bridge to Slack. Second, there is often a component that interacts only with the ledger. This is usually some form of automation that waits for certain contracts to appear on the ledger and then creates new contracts or exercises choices based on that. Automation and UIs are an often important parts of the developer experience of full-stack DLT applications which are often overlooked when the focus is only on the smart contract language.

So far, the Daml templates, the UI and the automation are commonly written in three separate languages, Daml for the templates, JavaScript for the UI and Java or Scala for the automation. However, this introduces a fair amount of friction since you have to translate between your Daml types and types in other languages. It may also force replicating logic that you have already defined in your Daml models in another language, e.g., you might want to check if a contract satisfies an ensure clause before creating it.

With Daml triggers, we aim to reduce some of the friction and repetition by allowing you to express automation that only interacts with the ledger directly in Daml. Thereby, you can reuse all of your types and functions that you have implemented as part of your Daml models.

To demonstrate how this looks in practice, we use a simple vacation tracker. Alice is a manager at Acme Corporation, which uses this Daml-based vacation tracker. Alice wants to leave it up to her employees to choose when they take their vacation. So instead of manually approving vacation requests, her goal is to implement a Daml trigger that will automatically approve all of them on her behalf. This is a simple example for the purpose of illustration, but you can imagine a different set of criteria for vacation requests that should be approved automatically.

You can find the full Daml model at https://github.com/cocreature/vacation-trigger/blob/master/src/Model.daml. In this blog, we focus on the two templates the trigger needs to interact with, namely Vacation and VacationRequest.

The implementation of AcceptRequest is not relevant for our trigger, so we have omitted it here.

To implement a Daml trigger, you need to provide 5 things:

  1. The type of your user-defined state. Most of the times this is simply the unit type ().
  2. A function to initialize the user-defined state on startup.
  3. A function to update the state when new messages arrive.
  4. A list of templates that the trigger is interested in.
  5. A rule method which sends commands to the ledger based on the current state of the Active Contract Set (ACS), the party the trigger is running as, the commands in flight (i.e., commands sent to the ledger which could still fail) and the user-defined state.

For this example, we do not need any user-defined state so we use () as our state type. Therefore the functions to initialise and update the user state become quite simple. We use AllInDar to indicate that we want to receive events for all templates in the DAR which is a safe but potentially less performant default. For this specific trigger, we could also use RegisteredTemplates [registeredTemplate @VacationRequest] at the cost of having to update this when our trigger starts using more templates.

In the rule of our auto-approve trigger, we first need to get all VacationRequest contracts. For that, there is a getContracts function that given the ACS returns a list of pairs of contract ids and the contract payload for a given template type. The auto-approve trigger will be running on behalf of a single party, so we have to filter the requests where this party is the boss (Alice in our example). Finally, we can call dedupExercise to exercise the AcceptRequest choice on each of those contracts. dedupExercise automatically makes sure that the choice is only executed if the same command is not already in flight, i.e., has already been sent by a previous run of this trigger. Putting this together the rule of our trigger is quite compact:

To run a trigger, you first compile it using daml build and then start it using daml trigger. The latter expects the path to the DAR, the name of the trigger in the form Module:identifier, the Ledger API host and port, and finally the party our trigger should run as.

daml trigger --dar=.daml/dist/vacation-trigger-0.0.1.dar --trigger-name=Trigger:autoApproveTrigger --ledger-host=localhost --ledger-port=6865 --ledger-party=Alice

This will start a long-running process for the trigger on your machine that connects to the ledger API. The trigger will run as Alice, so the boss argument in autoApproveRule will refer to Alice. Please take a look at the README (of this example project) for instructions on how to run the full example against an in-memory ledger and see the effects of the trigger in navigator.

To find more information on Daml triggers, go to our documentation.


Smart Contracts for Social Good: Unlocking Blockchain’s Potential Beyond Finance

VMware and Digital Asset have teamed up for the Odyssey hackathon to tackle two major Sustainable Development Goals: Plastic Pollution to Upcycling Economy and Consumer and Organization Driven Decarbonization. Contact us at community@daml.com to be notified of how to participate.

15. VMware, Daml - Upcycling economy


Having been exposed to the complex matrix of functions and systems as a product development manager at a bank, I was inspired by the thought leadership and ambition of Digital Asset (DA). From the onset, I knew that the team at DA was onto something revolutionary and I wanted to be a part of it. 

When DA was founded in 2014, the team was focused on how to apply blockchain technology to make the world’s markets operate more efficiently and productively. While our initial focus was on certain financial use cases, as an organization we always knew that our technology would be applied to support individuals and companies in building better and more inclusive global businesses.    

Nearly five years later, we can count many projects among our successes in bringing the original goal to life such as reimagining the way securities are cleared and settled with the Australian Securities Exchange (ASX), partnering with Broadridge to change the way repo trading and its associated collateral is executed and processed, and redefining market standards across the derivatives industry with the International Swaps and Derivatives Association (ISDA)

Throughout my career, I’ve led teams in delivering software that empowers operations and business users to focus on value added functions. At DA, I’ve had the unique privilege of applying my knowledge of the operationally and technically complex world of finance to other industries that  face similar operational hurdles, such as healthcare and energy. Using the capabilities of blockchain, we can unlock opportunities that we couldn’t have imagined only a few years ago. 

Smart Contracts

As we enter 2020, I’m excited to see Digital Asset continue to focus on helping companies and development teams spend less time on non-value added services by using Daml, the smart contract language created by Digital Asset. For an industry like healthcare, this means continuing to focus on projects related to how insurance companies process claims more efficiently. By implementing a smart contract solution for claims processing, not only will healthcare providers get paid faster but patients will have more transparency upfront into the cost of their treatment. 

The positive effects of using smart contracts and blockchain technology only continue to apply and evolve to industries such as finance and healthcare as the barriers to adoption decrease. We’ve seen partners in the logistics and transport industry rapidly develop applications to more easily track and trace products throughout the supply chain lifecycle with Daml-driven applications. And, perhaps even more importantly, we are seeing businesses not only build better and more technologically sound applications, but we are seeing partners and customers leverage their expertise in using Daml to develop net new products and services.    

16.  VMware, Daml - Decarbonization

Outcompeting Destructive Systems

But we think there’s even more we can do with Daml to support the global call for action to protect our planet and its most marginalized communities. From my experience, Daml works best when it is being used in support of building solutions which bring together multiple participants who are focused on solving complex problems. This is why we were thrilled when one of our ledger partners — global leader in infrastructure and digital workspace technology — VMware asked us to partner with them in supporting the Odyssey Hackathon. Odyssey brings together individuals and teams focused on providing a new space where everyone (and everything) can become part of a solution to a 21st-century challenge. It will be hosted April 3-6 in the Netherlands.

At DA, I’m tasked with helping clients utilize Daml and our other tools to solve all types of problems facing global commerce, whether that be how to process a loan application or track the food and beverage supply chain. As I continue to reflect on how we can use Daml to expedite innovation, it feels like exactly the right time to collaborate with leading institutions in using smart contract and blockchain technology to create solutions tied to the UN’s Sustainable Development Goals. I believe Daml is uniquely positioned to “achieve a better and more sustainable future for all” by ultimately facilitating global problem solving for an increasingly digital world.

Together with VMware and my teammates at Digital Asset, we are supporting two key challenges at the hackathon focused on outcompeting destructive systems: Plastic Pollution to Upcycling Economy and Consumer and Organization Driven Decarbonization. For individuals and teams interested in winning the Odyssey Hackathon with us by applying blockchain technology towards a more peaceful and prosperous planet, reach out to us at community@daml.com to be notified when you can submit your team and for support along the way. We look forward to using innovative technology to tackle these important challenges together!

Release of Daml SDK 0.13.40

Daml Compiler

  • The modules DA.Types and GHC.Tuple from daml-prim have been moved to separate DALF packages.
  • Fixed an issue where packages produced by damlc resulted in type errors during validation by Daml engine.


  • The sandbox JWT authentication now respects the ledgerId and participantId fields of the token payload.
  • Improve loading of active contracts for the Sandbox SQL backend.
  • AuthService implementations can now restrict the validity of access tokens to a single ledger or participant.

Java Client

  • Ensure the access token is initialized when using a deprecated constructor.

RxJava Bindings

  • Added a method to the Bot class allowing users to specify a Scheduler to use for running the bot. See issue #2356.

Java Bindings

  • Removed warnings in code emitted by the Java Codegen.


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

Low-code Smart Contracts for the Enterprise with Unibright and Daml

For anyone looking to deploy production grade applications using smart contracts and blockchain, enterprise technology integration remains one of the biggest areas for improvement by far.

Unibright and Daml

Stefan Schmidt
 the CTO of Unibright unpacks what his company has done to make Daml easier to deploy in the enterprise. Unibright specializes in the integration of blockchain technology with business applications. In this blog post, Stefan talks about the business challenges Daml solves and how it integrated Daml with the Unibright Framework, a suite of tools that helps you model business processes as smart contracts and then integrate smart contracts with enterprise systems such as ERP (e.g. SAP).  Daml is the latest addition to the Unibright Framework in addition to Solidity (on Ethereum. Because Daml was created for use with distributed systems it provides a variety of unique benefits. 

>> Read Stefan’s blog post on DamlDriven 
>> Read our press release with Unibright

Release of Daml SDK 0.13.39

0.13.39 – 2019-12-05

Java Bindings

  • Added authentication support. See issue #3626

Daml Compiler

  • The modules GHC.Prim and GHC.Types from daml-prim have been moved to separate packages.
  • Don’t make UndecidableSuperClasses a default language extension for Daml anymore. If you really need this feature for a module, you can reenable it using a LANGUAGE pragma at the top.

Daml SDK

  • Reduced the size of the Daml SDK by about 60% uncompressed, 70% compressed, by deduplicating Scala dependencies.
  • daml damlc docs now takes into account the project’s build-options from daml.yaml.
  • daml ledger navigator now loads frontend-config.js properly.


  • Explicit config files passed via -c are preferred over daml.yaml.

Ledger API Server

Participant State API

  • Add a mandatory currentHealth() method to IndexServiceReadService and WriteService.

Daml Triggers – Experimental

  • Daml triggers can now be run against an authenticated ledger.

Daml Script – Experimental

  • Add createAndExerciseCmd matching the Ledger API command of the same name.


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

Low-code Smart Contracts for the Enterprise with Unibright and Daml

by Stefan Schmidt, CTO, Unibright

Blockchain is uniquely positioned to bridge silos. Especially in an enterprise landscape where not only external but internal organizational boundaries must be bridged. The biggest effect is the creation of a logical golden source while also allowing all participants to mutualize their business processes. This implies that reconciliations between applications can be eliminated, and compliance to regulations and audit can be improved tremendously. 

The Unibright Framework allows for business processes to be modeled as smart contracts and integrations with enterprise systems such as ERP (e.g. SAP). In this post we will outline how Daml, an open source smart contract language originally created by Digital Asset, can be used to achieve this objective. Daml is the latest addition to the Unibright Framework in addition to Solidity (on Ethereum), and being purpose built for distributed systems offers unique benefits by several built in properties we will outline later in this blog. 

To illustrate the integration, the process we chose to model with the Unibright Framework is around inventory management and fulfilment. As we will show that this process requires both internal, as well as multi-enterprise decision making. 



When we evaluated the integration of the Unibright framework with Daml, we observed that Daml solves three big challenges with traditional blockchain application development:

  1. Enable multi-party workflows not only across, but within enterprises, with built in privacy and rights & obligations management.

  2. Enable golden source of data across participating entities (applications or organizations) while maintaining strict privacy between participants as needed.

  3. Improves productivity, avoids vendor lock-in, and reduces time to market by abstracting ledger complexities and enabling ledger selection only when the use case has been been proven.

These are also Unibright’s raison-d’etre. So in this blog post, we’ll outline what we mean by the above challenges and how the Unibright – Daml integration is solving them.


Mapping the Unibright Framework to Daml

As we planned out the integration, we looked at the Unibright Framework components and analyzed the best-fit areas while mapping them to the needs being expressed by clients. We found that any business process progresses through a series of business rules that are then orchestrated to create competitive differentiation, viz. just like in a game of chess. And just like an application of any technology is made better by providing user friendly tooling, we decided to focus on the three key benefits Unibright positions to clients – ease of use, ease of deployment and ease of management. 

The Unibright modeler allows for WYSIWYG creation of business processes that can be operationalized. The modeler then automatically generates the right Daml smart contracts for the workflows as defined.  Daml, by providing native constructs for data types such as parties, the fact that no party can be put into an obligable position without their consent, and by ensuring contract visibility and privacy at a sub-transaction level, provides powerful capabilities to define multi-party workflows that work out of the box. This makes the Unibright modeler integration very powerful because users and developers do not have to look under the hood to understand and define these intricacies. It also makes the integration very scalable and amenable to change. Smart contract templates are used by Unibright modeler to create out-of-the-box instances of processes that enterprises needed.

Second, a key goal of Unibright is to help clients harmonize their business processes. With its integration with Daml, Unibright modeler can now be used to define a business process that runs across multiple business applications of an enterprise (e.g. SAP, procurement, inventory, ecommerce etc). This implies that the same Daml workflow now underpins the entire business process without requiring multiple data silos. This has not been easily possible before. We’ll cover this in detail in the next section too.

Unibright templates were created to provide ledger independence to clients – select a template and the rest of the work is done for you. And now by integrating Daml with the Unibright framework, we take that experience to the next level. Each template has the capability to run on multiple ledgers (to use across enterprises) and even databases (to use across applications within an enterprise). More importantly, we can select the underlying blockchain ledger or databases after we have evangelized the prototype to all parties, and verified all of our hypotheses on privacy, regulatory and compliance reporting, and most importantly the business case. Once a Daml model is selected with Unibright, you can proceed all the way to prototyping out of the box! And then when you’re ready to move to production, the right ledger or database can be selected to deploy both across and within your enterprise.

Finally, our vision is to improve business productivity. The Unibright modeler and templates are a means to that end. Daml further abstracts away all of the ledger level complexity such as contract privacy, cryptography etc. to its runtime, so the generated code is several times shorter, and much cleaner. This allows for rapid maintenance and enhancement of functionality and feature set. The goals of agile development are also realized because both business and technology can work together more effectively.      


Illustrative Use Case on Inventory Management 

Consider a purchase process in SAP for new inventory. The details of that order must flow after approvals into the inventory management system – frequently a third party product – where this potential inventory is mapped to demand information. The purchase order is sent through various mechanisms – sometimes 3rd party procurement systems – to the suppliers, who might have their own complex value chains to be able to service the order, or provide a quote. When an order has been fulfilled, the inventory management system must again be updated so that demand orders can now be mapped to the available inventory thus triggering shipment and other processes. Upon consumption of this inventory, the information must again flow back to the ERP, so that financial records can be updated, and the payment processes can occur.

Traditionally, this complex business process has been met by data feeds to various systems and offline order updates from suppliers and other third parties. Even if managed through APIs, each participating entity must maintain its own data store and constantly match it to that maintained by the other party. As a result, businesses must deal with latencies at every stage, while also having to perform constant checks and balances to ensure that the view of information is consistent across the many islands of data. 

Using Daml smart contracts and Unibright, this business process can be set up to execute external tasks such as receiving invoices and status of shipments, while also extending the same Daml workflow for internal steps such as invoice verification and payment generation. As a result, each entity – internal or external – can operate off a golden version of information. This is a powerful capability that has the promise to bridge data silos and usher in an era of massive operational efficiency and agility.


Target Use Cases

Given Unibright’s market focus and where we see Daml going for non-finance specific use cases, and at the risk of narrowing our focus too much, we think the following use cases will see traction in the short term:

  1. Supply chain: Track and trace remains a popular topic for new entrants because of the traditional thought process of treating the blockchain as a database. However with the kind of workflow focus that Daml offers, we believe that the days of creating a responsive supply chain are upon us now. This includes complex problems like demand-supply matching, procurement linked to business operations, as well as proactive inventory management and flexible shipping to maximize revenue realization. The Unibright templates and our ERP expertise (especially SAP) can be joined together to achieve these transformation goals.

  2. Tokenization: Almost everything needs a way to be moved digitally. We are used to traditional tokenization of assets, but think of a home mortgage that moves between bank providers. Today, the process is costly, complex and error prone with data migrations, customer service issues and so on. With Unirbright and Daml, this can be accomplished effectively and rapidly because all we need to do is to provide the right consents to a Daml workflow, enabled by Unibright of course!


Current Development Status (November 2019)

For anyone looking to deploy production grade applications using smart contracts and blockchain, enterprise technology integration remains by far as one of the biggest improvement areas. 

We demonstrated the integration of Daml with the Unibright framework through a live demo at Synchronize Europe in June, an event hosted by Digital Asset. Since then we have been working to refine the integration and workflows. Daml has taken over some of the heavy lifting that the framework traditionally performed because it runs itself on multiple ledgers. We are now looking to get started with an end to end use case with a customers interested in tokenization (real estate) as well as supply chain (CPG).

Wondering how you can help out? We are always looking to make new connections. If you know anyone working with a CPG or Retailer who would like to explore the use of blockchain for their supply chain, we’d love for you to make an introduction for us!

Learn more about Unibright and Daml at unibright.io