Visualizing Daml Contracts

Visualizing Daml Contracts is currently an Early Access Feature in Labs status.

You can generate visual graphs for the contracts in your Daml project. To do this:

  1. Install Graphviz.
  2. Open a terminal and navigate to your project root directory.
  3. Generate a DAR from your project by running daml build -o project.dar.
  4. Generate a dot file from that DAR by running daml damlc visual project.dar --dot project.dot
  5. Generate the visual graph with Graphviz by running dot -Tpng project.dot > project.png

You can of course choose different names for the files, as long as you’re consistent between file creation and point of use.

Example: Visualizing the Quickstart project

Here’s an example visualization based on the quickstart. You’ll need to install Graphviz to try this out.

  1. Generate the dar using daml build
  2. Generate a dot file daml damlc visual dist/quickstart-0.0.1.dar --dot quickstart.dot
  3. Generate the visual graph with Graphviz by running dot -Tpng quickstart.dot -o quickstart.png

Running the above should produce an image which looks something like this:

A visualization based on a a simple Iou transfer workflow, in the form of a flowchart.

Visualizing Daml Contracts - Within IDE

You can generate visual graphs from VS Code IDE. Open the daml project in VS Code and use command palette. Should reveal a new window pane with dot image. Also visual generates only the currently open daml file and its imports.

Note: You will need to install the Graphviz/dot packages as mentioned above.

Visualizing Daml Contracts - Interactive Graphs

This does not require any packages installed. You can generate D3 graphs for the contracts in your Daml project. To do this

  1. Generate a DAR from your project by running daml build
  2. Generate HTML file daml damlc visual-web .daml/dist/quickstart-0.0.1.dar -o quickstart.html

Running the above should produce an image which looks something like this:

A visualization of a contract as a circular graph.