Getting Started tutorials

This section explains how some key concepts of Daml Finance work in practice. It combines a step by step description of different workflows with supporting Daml code.

The following tutorials are available:

  • Holdings: describes the core asset model used in Daml Finance.
  • Transfer: shows how to transfer ownership of a holding to another party.
  • Settlement: explains how to execute multiple asset movements atomically.
  • Lifecycling: describes how lifecycle rules and events can be used to evolve instruments over time.

Each tutorial builds on top of the previous ones, so they should ideally be followed in order.

Prerequisites

We expect the reader to be familiar with the basic building blocks of Daml. If that is not the case, a suitable introduction can be found here.

An understanding of Daml Interfaces is very helpful, as these are used extensively throughout the library. However, you should be able to follow along and grasp the fundamental concepts also without detailed knowledge on interfaces.

Finally, make sure that the Daml SDK is installed on your machine.

Download the code for the tutorials

Open a new terminal window and run:

daml new quickstart-finance --template quickstart-finance

This creates a new folder with contents from our template. Navigate to the folder and then run the following to download the required Daml Finance packages:

./get-dependencies.sh

or, if you are using Windows

./get-dependencies.bat

Finally, you can start Daml Studio to inspect the code and run the project’s scripts:

daml studio

Structure of the Code and Dependencies

The project includes

  • four workflows defined in the Workflows folder
  • four Daml scripts defined in the Scripts folder

The Workflows encapsulate the core business logic of the application, whereas the Scripts are meant to be executed on a one-off basis.

As you can see from the import list, modules in the Workflows folder depend only on interface packages of Daml Finance (the packages that start with Daml.Finance.Interface.*).

This is important, as it decouples the user-defined business logic from the template implementations used in Daml Finance, which makes it easier to upgrade the application. The user-defined business logic in the Workflows will not need to be modified nor re-compiled to work with upgraded (ie., newer versions of) implementation packages.

On the other hand, modules in the Scripts folder depend on both the interface packages and the implementation packages (in this case, Daml.Finance.Account, Daml.Finance.Holding, and Daml.Finance.Instrument.Token). This is not problematic as scripts are meant to be run only once when the application is initialized.