> ## 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.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# Interfaces

> Define and implement Daml interfaces for polymorphic contract behavior and cross-template interoperability

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](https://docs.canton.network/appdev/reference/daml-language-reference.md#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:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
error type checking template Asset.SimpleAsset interface instance Asset:Asset for Asset:SimpleAsset:
  The interface Asset was defined in this package and implemented in Asset by SimpleAsset

  This may make this package and its dependents not upgradeable.

  It is recommended that interfaces are defined in their own package separate from their implementations.
  Downgrade this error to a warning with -Wupgrade-interfaces
  Disable this error entirely with -Wno-upgrade-interfaces
```

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`.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
my-project/
├── multi-package.yaml
├── asset-interface/
│   ├── daml.yaml
│   └── daml/Asset.daml              # interface Asset, its view type
└── simple-asset/
    ├── daml.yaml
    └── daml/SimpleAsset.daml        # template SimpleAsset, interface instance Asset
```

`multi-package.yaml` lists both packages, so `dpm build --all` builds them in dependency order:

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
packages:
  - ./asset-interface
  - ./simple-asset
```

The template package depends on the interface package's DAR:

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
sdk-version: <sdk-version>
name: simple-asset
version: 0.0.1
source: daml
dependencies:
  - daml-prim
  - daml-stdlib
data-dependencies:
  - ../asset-interface/.daml/dist/asset-interface-0.0.1.dar
```

For package naming conventions, see [Separating Interfaces from Templates](https://docs.canton.network/appdev/modules/m6-package-naming.md#separating-interfaces-from-templates). For the upgrade rules behind this check, see [Separate Interfaces/Exceptions from Templates](https://docs.canton.network/appdev/deep-dives/smart-contract-upgrade.md#separate-interfaces/exceptions-from-templates).

## Interfaces on Canton Network

Interfaces are central to interoperability across the Canton Network. [CIP-0056 — Token Standard](https://github.com/canton-foundation/cips/blob/main/cip-0056/cip-0056.md) 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](https://docs.canton.network/overview/reference/external-party.md#trust-relationships).
