digital-asset / daml-ui-template

Apache License 2.0
10 stars 14 forks source link

DAML App Template

Overview

This repository contains a simple UI template for a DAML application. It provides ledger connectivity and shows how to create simple reports from contracts. The template is based on create-react-app and the Material UI framework.

Prerequisites

Running the app

  1. Start the sandbox ledger
    daml start

Wait until the ledger has started up.

  1. In a new shell, start the UI
    cd ui
    yarn install --force --frozen-lockfile
    yarn start

This opens a browser page pointing to http://localhost:3000/#/login. Note that the development server serves content via http and should not be exposed as is to a public-facing network.

If you change the Daml code you need to rerun all of the steps above in order for the changes to propagate properly into the UI code.

Note that in order to support login with party aliases (like "Alice") we output a [(Text, Party)] mapping from the init script. This output file (ui/parties.json) is used to map party aliases to party ids. For this to work the ledger has to have completed the init script before starting up the UI server. This is of course only a convenience practice and should not be used in production.

Exploring the application

The Report page is meant as an example, which you can copy and modify to your needs.