- Overview
- Tutorials
- Getting started
- Get started with Canton and the JSON Ledger API
- Get Started with Canton, the JSON Ledger API, TypeScript and WebSockets
- Get Started with Canton, the JSON Ledger API, and TypeScript
- Get started with Canton Network App Dev Quickstart
- Using the JSON Ledger API
- Get started with smart contract development
- Basic contracts
- Test templates using Daml scripts
- Build the Daml Archive (.dar) file
- Data types
- Transform contracts using choices
- Add constraints to a contract
- Parties and authority
- Compose choices
- Handle exceptions
- Work with dependencies
- Functional programming 101
- The Daml standard library
- Test Daml contracts
- Next steps
- Application development
- Getting started
- Development how-tos
- Component how-tos
- Explanations
- References
- Application development
- Smart contract development
- Daml language cheat sheet
- Daml language reference
- Overview: Template Structure
- Reference: Templates
- Reference: Choices
- Reference: Updates
- Reference: Data Types
- Reference: Built-in Functions
- Reference: Expressions
- Reference: Functions
- Reference: Daml File Structure
- Reference: Daml Packages
- Reference: Contract Keys
- Reference: Interfaces
- Reference: Exceptions (Deprecated)
- Fixity, Associativity and Precedence
- Daml standard library
- DA.Action.State.Class
- DA.Action.State
- DA.Action
- DA.Assert
- DA.Bifunctor
- DA.Crypto.Text
- DA.Date
- DA.Either
- DA.Exception
- DA.Fail
- DA.Foldable
- DA.Functor
- DA.Internal.Interface.AnyView.Types
- DA.Internal.Interface.AnyView
- DA.List.BuiltinOrder
- DA.List.Total
- DA.List
- DA.Logic
- DA.Map
- DA.Math
- DA.Monoid
- DA.NonEmpty.Types
- DA.NonEmpty
- DA.Numeric
- DA.Optional
- DA.Record
- DA.Semigroup
- DA.Set
- DA.Stack
- DA.Text
- DA.TextMap
- DA.Time
- DA.Traversable
- DA.Tuple
- DA.Validation
- GHC.Show.Text
- GHC.Tuple.Check
- Prelude
- Daml Script
- Smart contract upgrading reference
- Glossary of concepts
The Daml Compiler¶
At the core of the Daml toolchain lies the Daml Compiler, also known as damlc. Its primary usage is to compile Daml source code, which defines smart contracts and their behaviours, into a lower-level language called Daml-LF, which Canton participants can evaluate in order to run those smart contracts.
We recommend running the compiler via DPM (i.e. through
dpm build), or alternatively, by calling damlc directly. When compiling
code, the Daml Compiler goes through the following stages:
The input
.damlfiles are type-checked (i.e. it is verified if they are well-formed or not)The type-checked
`.damlcode is transformed to Daml-LF.The produced Daml-LF is packaged together with its dependencies and their metadata into a
.darfile, which essentially is an archive of Daml-LF files with metadata.
Build files produced by a call to dpm build are stored in a .daml
directory, local to the project in which dpm build was run. They can be
cleaned using dpm clean.
The Daml Compiler also offers testing functionality. It can be invoked either by
first calling dpm build to obtain a .dar which is then used in a call to
Daml Script (i.e. dpm script), or by calling Daml Test
(i.e. dpm test) directly.
Build & test flags¶
These flags are available for both --build as well as --test.
-h,--helpPrints option information when called on the commandline.--package-root ARGDPM-specific option.Path to the root of a Package containingdaml.yaml. Using this option, you set the package to build/test. You should prefer theDAML_PACKAGEenvironment variable over this option. See Configuration for more details.--project-root ARGDPM-specific option.project-rootis deprecated, please use--package-root.Path to the root of a Package containingdaml.yaml. You should prefer theDAML_PACKAGEenvironment variable over this option. See Configuration for more details.--include INCLUDE-PATHPath to an additional source directory to be included.--package-db LOC-OF-PACKAGE-DBUse Package Database in the given location.--access-token-file PATHDeprecated command**, use DPM-specific insteadPath to the token-file for ledger authorization.--shake-profiling PROFILING-REPORTDirectory for Shake Profiling Reports.--jobs THREADSThe number of threads to run in parallel. When -j is not passed, 1 thread is used. If -j is passed, the number of threads defaults to the number of processors. Use –jobs=N to explicitely set the number of threads to N. Note that the output is not deterministic for > 1 job.--debugSet log level to DEBUG.--log-level ARGSet log level. Possible values are DEBUG, INFO, WARNING, ERROR.--detail LEVELDetail level of the pretty printed output (default: 0). A higher level of detail will pretty print more information from for exampledamlc inspectas well as printing source file locations. See Detail Level (damlc).--ghc-option OPTIONOptions to pass to the underlying GHC.-p,--test-pattern PATTERNOnly scripts with names containing the given pattern will be executed.--typecheck-upgrades ARGTypecheck upgrades. Can be set to “yes”, “no” or “auto” to select the default (True).--upgrades UPGRADE_DARSet DAR to upgrade>.-W ARGTurn an error into a warning with-W<name>or-Wwarn=<name>or-Wno-error=<name>. Turn a warning into an error with-Werror=<name>. Disable warnings and errors with-Wno-<name>. Available names are:deprecated-exceptionscrypto-text-is-alphaupgrade-interfacesupgrade-exceptionsupgrade-dependency-metadataupgraded-template-expression-changedupgraded-choice-expression-changedcould-not-extract-upgraded-expressionunused-dependencyupgrades-own-dependencytemplate-interface-depends-on-daml-scripttemplate-has-new-interface-instance
--ignore-data-deps-visibility ARGIgnore explicit exports on Data Dependencies, and instead allow importing of all definitions from that Package (this was the default behaviour before Daml 2.10). Can be set to “yes”, “no” or “auto” to select the default (False).
Build flags¶
- All build & test flags described above.
-o,--output FILEOptional output file (defaults to<PACKAGE-NAME>.dar).--incremental ARGEnable Incremental Builds. Can be set to “yes”, “no” or “auto” to select the default (False).--init-package-db ARGInitialize Package Database. Can be set to “yes”, “no” or “auto” to select the default (True).--enable-multi-package ARGEnable/disable multi-package.yaml support (enabled by default). Can be set to “yes”, “no” or “auto” to select the default (True).--allBuild all packages in multi-package.yaml.--no-cacheDisables cache checking, rebuilding all dependencies.--multi-package-path FILEPath to the multi-package.yaml file.
Test flags¶
- All build & test flags described above.
--filesOnly run test declarations in the specified files.--allRun tests in current Package as well as dependencies--load-coverage-onlyDon’t run any tests. Only load Coverage results from files and write the aggregate to a single file.--show-coverageShow detailed test Coverage.--colorColored test results>--junit FILENAMEFilename of JUnit output file. This file contains the test output in the de-facto standard for test output, JUnit XML file format. See https://github.com/testmoapp/junitxml.--package-name PACKAGE-NAMECreate package artifacts for the given package name.--table-output ARGFilename to which table should be output. Used to render the table view of Daml Studio, but usable on the cli as well.--transactions-output ARGFilename to which the transaction list should be output. Used to render the transaction view of Daml Studio, but usable on the cli as well.--load-coverage ARGFile to read prior Coverage results from. Can be specified more than once.--save-coverage ARGFile to write final aggregated Coverage results to.--coverage-ignore-choice ARGRemove choices matching a regex from the Coverage report. The full name of a local choice takes the format<module>:<template name>:<choice name>, preceded by<package id>:for nonlocal packages.
Test flags¶
-h,--helpPrints option information when called on the commandline.--package-root ARGDPM-specific option.Path to the root of a Package containingdaml.yaml. Using this option, you set the package to clean. You should prefer theDAML_PACKAGEenvironment variable over this option. See Configuration for more details.--project-root ARGDPM-specific option.project-rootis deprecated, please use--package-root.Path to the root of a Package containingdaml.yaml. You should prefer theDAML_PACKAGEenvironment variable over this option. See Configuration for more details.--multi-package-path FILEPath to the multi-package.yaml file.--allClean all packages in multi-package.yaml.