Skip to main content
In Daml, an interface defines an abstract type together with a behavior specified by its view type, method signatures, and choices. For a template to conform to an interface, there must be a corresponding interface instance definition where all the methods of the interface (including the special view method) are implemented. This lets other developers write applications in terms of the interface instead of the concrete template, so contracts built on different templates can interoperate as long as they implement the same interface. For the full syntax — interface declarations, view types, interface choices, interface instance clauses, required interfaces, and the toInterface/fromInterface family of functions — see Reference: Interfaces in the Daml Language Reference.

Define interfaces in their own package

Interface definitions can’t be upgraded. If one package defines an interface and also a template that implements it, the compiler stops with an error like this:
Don’t switch the check off with -Wupgrade-interfaces or -Wno-upgrade-interfaces. A template that shares a package with an interface can never be upgraded, so the problem only moves to your first upgrade. Split the code into two packages instead: one that holds the interfaces, and one that holds the implementing templates and imports the interface package through data-dependencies.
multi-package.yaml lists both packages, so dpm build --all builds them in dependency order:
The template package depends on the interface package’s DAR:
For package naming conventions, see Separating Interfaces from Templates. For the upgrade rules behind this check, see Separate Interfaces/Exceptions from Templates.

Interfaces on Canton Network

Interfaces are central to interoperability across the Canton Network. CIP-0056 — Token Standard defines the standard Daml interfaces for tokens on Canton Network. If your application issues or transfers tokens, implementing these interfaces makes your assets usable by wallets and other applications in the ecosystem without custom integration with each counterparty. App developers implementing an interface: by default, use the authority your interface choices receive only on your app’s own contracts. These choices run with the authority of the parties that exercise them, and the interface view does not prove which implementation runs. In your implementation:
  • Fetch every contract ID your choices receive at the interface type, and convert it with fromInterface to one of your own templates. Abort if none matches.
  • Check that the contract’s signatories and fields match what your choice expects, for example that your registry’s admin signed it and that its owner is the sender.
  • Exercise choices only on contracts you have checked this way, never on an interface contract ID taken directly from the caller.
Validator operators rely on this property when they vet your package. See the trust model for parties.