When multiple versions of a package are uploaded to a validator, the validator needs rules for deciding which version to execute. Package selection determines this — it governs how the Daml runtime resolves templates and choices when both v1 and v2 packages are available.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.
How Version Resolution Works
Every contract on the ledger is associated with the package version that created it. When you fetch or exercise a contract, the runtime uses the package version referenced in your code, not necessarily the version that created the contract. The resolution follows these rules:- Creating contracts — The runtime uses the package version your code references. If your backend imports v2, new contracts are created with v2.
- Fetching contracts — The runtime evaluates the contract’s data against the version your code references. SCU and vetting rules determine whether the fetch succeeds (see Upgrade Compatibility).
- Exercising choices — The choice body from the version your code references is executed, not the version that created the contract. This means bug fixes in v2 choices apply to v1 contracts.
Symbolic Package References
Do not hardcode a specific package version in your backend. Use symbolic package references in your Ledger API queries. Instead of specifying a particular package ID, you reference a package by name:com-example-licensing package that contains a Main.License template. Your backend receives contracts from both v1 and v2 without needing separate query logic for each version.
Without symbolic references, you’d need to update your backend’s query filters every time you upload a new package version — defeating the purpose of seamless upgrades.
Multi-Version Coexistence
Both v1 and v2 packages remain active on the ledger after uploading v2. This means:- Contracts created with v1 continue to exist and can be fetched, exercised, and archived
- New contracts can be created with either v1 or v2 (depending on which version your code references)
- Different organizations can use different versions simultaneously during the rollout period
Optional field with a non-None value), you must archive the v1 contract and create a new v2 contract — either through normal business operations or through an explicit upgrade choice.
Package Vetting
Vetting a package allows other participant nodes to determine which workflows the parties on the participant can engage in. A package cannot be used until it is vetted, providing an additional verification step in the deployment process. By default, when a Daml package is uploaded, the participant node automatically marks it as vetted and publishes its vetting status on the synchronizer. Packages can also be unvetted. For example, after uploading and vetting v2, unvetting v1 signals that the participant node can no longer participate in v1 workflows, finalizing the upgrade process. A participant node must fully upgrade all its v1 contracts before unvetting v1 to avoid potential issues. A contract created with V1 of a template can be used/upgraded with/to V2, even though V1 was unvetted provided that V2 is vetted.Cross-Version Fetch Behavior
The runtime uses whatever package version your code references. There is no automatic “preference” for newer versions — the version used depends on which package your code was compiled against. The cross-version behavior follows these rules:- If you fetch a
Licenseusing v2 code, and the contract was created with v1, the runtime applies v2 logic (filling newOptionalfields withNone) - If you fetch a
Licenseusing v1 code, and the contract was created with v2 where new fields areNone, the runtime applies v1 logic (ignoring unknown fields) - If you fetch a
Licenseusing v1 code, and the contract was created with v2 where new fields have non-Nonevalues, the fetch fails to prevent data loss
Next Steps
- Testing Upgrades — Verify that version resolution works correctly for your upgrade
- Deploying Upgrades — Coordinate package uploads across validators