Glossary of concepts¶
Daml is a programming language for writing smart contracts, that you can use to build an application based on a ledger. You can run Daml contracts on many different ledgers.
A contract is an item on a ledger. They are created from blueprints called templates, and include:
- data (parameters)
- roles (signatory, observer)
- choices (and controllers)
Contracts are immutable: once they are created on the ledger, the information in the contract cannot be changed. The only thing that can happen to it is that the contract can be archived.
Active contract, archived contract¶
When a contract is created on a ledger, it becomes active. But that doesn’t mean it will stay active forever: it can be archived. This can happen:
- if the signatories of the contract decide to archive it
- if a consuming choice is exercised on the contract
Once the contract is archived, it is no longer valid, and choices on the contract can no longer be exercised.
A template is a blueprint for creating a contract. This is the Daml code you write.
For full documentation on what can be in a template, see Reference: templates.
A choice is something that a party can exercise on a contract. You write code in the choice body that specifies what happens when the choice is exercised: for example, it could create a new contract.
Choices give you a way to transform the data in a contract: while the contract itself is immutable, you can write a choice that archives the contract and creates a new version of it with updated data.
A choice can only be exercised by its controller. Within the choice body, you have the authorization of all of the contract’s signatories.
For full documentation on choices, see Reference: choices.
A consuming choice means that, when the choices is exercised, the contract it is on will be archived. The alternative is a nonconsuming choice.
Consuming choices can be preconsuming or postconsuming.
A nonconsuming choice does NOT archive the contract it is on when exercised. This means the choice can be exercised more than once on the same contract.
A party represents a person or legal entity. Parties can create contracts and exercise choices.
Signatories, observers, controllers, and maintainers all must be parties, represented by the
Party data type in Daml.
A signatory is a party on a contract. The signatories MUST consent to the creation of the contract by authorizing it: if they don’t, contract creation will fail.
For documentation on signatories, see Reference: templates.
An observer is a party on a contract. Being an observer allows them to see that instance and all the information about it. They do NOT have to consent to the creation.
For documentation on observers, see Reference: templates.
A controller is a party that is able to exercise a particular choice on a particular contract.
Controllers must be at least an observer, otherwise they can’t see the contract to exercise it on. But they don’t have to be a signatory. this enables the propose-accept pattern.
A choice observer is a party on a choice. Choice observers are guaranteed to see the choice being exercised and all its consequences with it.
Stakeholder is not a term used within the Daml language, but the concept refers to the signatories and observers collectively. That is, it means all of the parties that are interested in a contract.
The maintainer is a party that is part of a contract key. They must always be a signatory on the contract that they maintain the key for.
It’s not possible for keys to be globally unique, because there is no party that will necessarily know about every contract. However, by including a party as part of the key, this ensures that the maintainer will know about all of the contracts, and so can guarantee the uniqueness of the keys that they know about.
For documentation on contract keys, see Contract keys.
The Daml standard library is a set of Daml functions, classes and more that make developing with Daml easier.
For documentation, see The standard library.
An agreement is part of a contract. It is text that explains what the contract represents.
It can be used to clarify the legal intent of a contract, but this text isn’t evaluated programmatically.
See Reference: templates.
A create is an update that creates a contract on the ledger.
Contract creation requires authorization from all its signatories, or the create will fail. For how to get authorization, see the propose-accept and multi-party agreement patterns.
A party submits a create command.
See Reference: updates.
An exercise is an action that exercises a choice on a contract on the ledger. If the choice is consuming, the exercise will archive the contract; if it is nonconsuming, the contract will stay active.
Exercising a choice requires authorization from all of the controllers of the choice.
A party submits an exercise command.
See Reference: updates.
Daml Script provides a way of testing Daml code during development. You can run Daml Script inside Daml Studio, or write them to be executed on Sandbox when it starts up.
They’re useful for:
- expressing clearly the intended workflow of your contracts
- ensuring that parties can exclusively create contracts, observe contracts, and exercise choices that they are meant to
- acting as regression tests to confirm that everything keeps working correctly
In Daml Studio, Daml Script runs in an emulated ledger. You specify a linear sequence of actions that various parties take, and these are evaluated in order, according to the same consistency, authorization, and privacy rules as they would be on a Daml ledger. Daml Studio shows you the resulting transaction graph, and (if a Daml Script fails) what caused it to fail.
A contract key allows you to uniquely identify a contract of a particular template, similarly to a primary key in a database table.
A contract key requires a maintainer: a simple key would be something like a tuple of text and maintainer, like
See Contract keys.
DAR file, DALF file¶
.dar file is the result of compiling Daml using the Assistant.
.dar files to a ledger in order to be able to create contracts from the templates in that file.
.dar contains multiple
.dalf files. A
.dalf file is the output of a compiled Daml package or library. Its underlying format is Daml-LF.
Daml Assistant is a command-line tool for many tasks related to Daml. Using it, you can create Daml projects, compile Daml projects into .dar files, launch other developer tools, and download new SDK versions.
Daml Studio is a plugin for Visual Studio Code, and is the IDE for writing Daml code.
See Daml Studio.
Sandbox is a lightweight ledger implementation. In its normal mode, you can use it for testing.
You can also run the Sandbox connected to a PostgreSQL back end, which gives you persistence and a more production-like experience.
See Daml Sandbox.
Application, ledger client, integration¶
Application, ledger client and integration are all terms for an application that sits on top of the ledger. These usually read from the ledger, send commands to the ledger, or both.
There’s a lot of information available about application development, starting with the Application architecture page.
The Ledger API is an API that’s exposed by any Daml ledger. Alternative names: Daml Ledger API and gRPC Ledger API if disambiguation from other technologies is needed. See The Ledger API page. It includes the following services.
Command submission service¶
Use the command submission service to submit commands - either create commands or exercise commands - to the ledger. See Command submission service.
Command completion service¶
Use the command completion service to find out whether or not commands you have submitted have completed, and what their status was. See Command completion service.
Use the command service when you want to submit a command and wait for it to be executed. See Command service.
Use the transaction service to listen to changes in the ledger, reported as a stream of transactions. See Transaction service.
Active contract service¶
Use the active contract service to obtain a party-specific view of all contracts currently active on the ledger. See Active contracts service.
Use the package service to obtain information about Daml packages available on the ledger. See Package service.
Ledger identity service¶
Use the ledger identity service to get the identity string of the ledger that your application is connected to. See Ledger identity service.
Ledger configuration service¶
Use the ledger configuration service to subscribe to changes in ledger configuration. See Ledger configuration service.
Ledger API libraries¶
The following libraries wrap the ledger API for more native experience applications development.
An idiomatic Java library for writing ledger applications. See Java bindings.
An idiomatic Scala library for writing ledger applications. See Scala bindings.
Reading from the ledger¶
Applications get information about the ledger by reading from it. You can’t query the ledger, but you can subscribe to the transaction stream to get the events, or the more sophisticated active contract service.
Submitting commands, writing to the ledger¶
Applications make changes to the ledger by submitting commands. You can’t change it directly: an application submits a command of transactions. The command gets evaluated by the runtime, and will only be accepted if it’s valid.
For example, a command might get rejected because the transactions aren’t well-authorized; because the contract isn’t active (perhaps someone else archived it); or for other reasons.
This is echoed in scenarios, where you can mock an application by having parties submit transactions/updates to the ledger. You can use
submitMustFail to express what should succeed and what shouldn’t.
When you compile Daml source code into a .dar file, the underlying format is Daml-LF. Daml-LF is similar to Daml, but is stripped down to a core set of features. The relationship between the surface Daml syntax and Daml-LF is loosely similar to that between Java and JVM bytecode.
As a user, you don’t need to interact with Daml-LF directly. But internally, it’s used for:
- executing Daml code on the Sandbox or on another platform
- sending and receiving values via the Ledger API (using a protocol such as gRPC)
- generating code in other languages for interacting with Daml models (often called “codegen”)
Ledger, Daml ledger¶
Ledger can refer to a lot of things, but a ledger is essentially the underlying storage mechanism for a running Daml applications: it’s where the contracts live. A Daml ledger is a ledger that you can store Daml contracts on, because it implements the ledger API.
Daml ledgers provide various guarantees about what you can expect from it, all laid out in the Daml Ledger Model page.
When you’re developing, you’ll use Sandbox as your ledger.
A trust domain encompasses a part of the system (in particular, a Daml ledger) operated by a single real-world entity. This subsystem may consist of one or more physical nodes. A single physical machine is always assumed to be controlled by exactly one real-world entity.