Smart contract upgrades (SCU) in Daml are powerful but have firm boundaries. Understanding these limitations upfront prevents surprises during development and production rollouts.Documentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
Packages Cannot Be Removed
Once you upload a DAR (Daml Archive) package to a validator, it stays there permanently. There is no mechanism to delete or unregister a package. This means:- Every version of your package that was ever uploaded remains available
- The validator’s package store grows over time
- You cannot revert a package upload
Template Removal Is Not Possible
You cannot remove a template from a package in a later version. If version 1 defines templatesAsset and LegacyAsset, version 2 must still include both.
Deprecating a Template
Adding and Deprecating Templates
New templates can be added. Existing templates cannot be removed but can be deprecated by:- Removing references to them from other Daml code.
- Adding
ensure Falseto make them non-operational. This prevents new contract creation using the template and choice exercises, including the implicit Archive choice, on existing contracts created using the template.
ensure clause to True. To deprecate a template without leaving contracts on the ledger that cannot be archived,
add ensure False to the template only after all active contracts created from it have been archived through automation or other means.
Removing Fields, Choices, or Variant Constructors Is Not Allowed
SCU compatibility rules prohibit removing:- Fields from a template — You can add optional fields (with defaults) but cannot remove existing ones
- Choices from a template — Once a choice exists, it must remain in all future versions
- Constructors from a variant type — Variant types can gain new constructors but not lose existing ones
Changing Field Types Is Restricted
You cannot change the type of an existing field. Ifamount is a Decimal in version 1, it must remain a Decimal in version 2. Type changes are breaking modifications that would make existing contracts unreadable.
What You Can Do
For contrast, these modifications are allowed across package versions:- Add new templates
- Add new optional fields to existing templates (with default values)
- Add new choices to existing templates
- Add new variant constructors
- Add new interface implementations (on new templates only)
- Change choice bodies (the implementation logic)
Planning Around Limitations
Manage Backward-Incompatible Changes
Not all changes can maintain backward compatibility. The strategy for updating Daml models follows principles similar to how APIs evolve in a service-based architecture. Only backward-compatible changes are allowed for existing APIs, that is for the current Daml code. Introduce backward-incompatible changes by creating changing APIs, such as removing a parameter in a choice. To implement backwards-incompatible upgrades:- Introduce the new templates with the backwards incompatible change with a consuming
Upgradechoice to existing templates. This choice archives the old contract and creates an instance of the new template, ensuring a backwards-compatible upgrade. - Where necessary, provide reference data, such as default values, for
Upgradechoices via additional choice arguments. - Use backend automation to migrate old contracts to new ones. The process may incur downtime on workflows until the contracts are converted by the automation.
Further Reading
- Upgrade Compatibility — Full compatibility rules for SCU
- Package Naming — Naming conventions that account for breaking changes
- Smart Contract Upgrades in Production — Operational considerations for rollouts