How to draw inspiration from advanced DAML reference applications

György Balázsi
DAML Masterclass
Published in
3 min readAug 18, 2020
Photo by TK Hammonds on Unsplash

DAML is a domain specific smart contract language for creating transaction-driven, distributed business applications which can be run on blockchains as well as on centralised databases.

One of the revolutionary features of DAML is that you can build use cases using digital contracts signed by multiple parties, so that the contracts can express pre-authorisation and delegation of authority— just as in the traditional business world and government, jus much faster and with zero error rate.

Imagine for example that you can acquire a virtual driving license through a series of digital interactions with the involved organisations and authorities, at the end of which you get a “contract” about your driving eligibility, signed by all the parties necessary, which you can show to the police by making the officer an observer on the contract:

The more complex a business use case is, the better fit it is for a DAML-driven application. Although it’s necessary to first understand the basics rather than jumping right into the thick of it, the real business value lies in the rich, complex DAML models.

You get a lot of help for getting the baby steps right:

  • You have a terrific community forum for developers and users, where you get help with all kinds of questions very fast from the very people who are developing DAML.
  • It’s best to start with the Getting Started with DAML guide in the documentation.
  • There are available excellent interactive tutorials on the DAML website.
  • You can learn about Good design patterns that help you to draft e.g. multi-party agreements in DAML.
  • You can post questions on the DAML Discuss Forum, where super helpful experts will give you quick and always clear answers.

When you are already familiar with the basics and have some experience with writing simpler applications which consist of 3–4 smart contract templates and maybe some custom data types, you might want to raise the bar, and get your sight on more interesting use cases.

That’s where you can draw a lot of inspiration from advanced reference applications created by DAML experts from Digital Asset. (You can find all of them on the DAML Marketplace.)

In this blog post series, I will review some of these “refapps”, as DAML team members call it, which I studied first, and found extremely useful.

This post is the documentation of my journey into reverse-engineering these refapps, so that I can take them apart, and reassemble their building blocks for my purposes.

I emphasize that the selection doesn’t reflect any value judgment on my side, it’s just that I have picked some, which I thought could help me to steal ideas for the projects I have ahead of me. I hope the authors of the refapps left out won’t take it personally.

One caveat before starting off:

The downside is, that reading the source code of advanced refapps is not always easy. Some of them took me several runs to get a grasp of. The reason for this is that advanced DAML apps contain advanced functions and data types.

On the other hand, the upside is that the program code of these refapps is always well documented. If this isn’t enough, the IntelliSense functionality of VSCode helps a lot: you can trace back the function and datatype definitions, or just use the pop-up signature info to better understand what’s going on. Always read scenarios side-by-side with contract template definitions. Scenarios will help you to understand how the contract templates are used in actual transactions. At the end of the day, if you get past the initial difficulties, it’s a lot of fun, and you can learn a lot. As if you read chess grandmasters’ parties with good commentary.

Up next in this blog post series:

--

--