DISCLAIMER: This work in progress!
This repository contains a template to get started with developing full-stack DAML applications. The demo application covers the following aspects:
- A DAML model (of a simplistic social network)
- Automation using DAML triggers
- A UI written in TypeScript
The application showcases a variety of experimental DAML SDK features such as DAML triggers and the HTTP JSON API service.
The UI is developed using React, Semantic UI and its official React integration. The whole project was bootstrapped with Create React App. Regardless of these choices, all DAML specific aspects of the UI client are written in plain TypeScript and the UI framework should hence be easily replacable.
Before you can run the application, you need to install the DAML SDK and a package manager for JavaScript. For the development of this project we have used yarn, but others might work equally well.
First, you need to obtain a copy of this project, either by clicking the "Use this template" button above or by cloning this repository directly via
git clone https://github.com/hurryabit/create-daml-app.git
Once you have copy of this project, you need to install its dependencies by calling
yarn install
at the root of the repository.
To start the application, first start a DAML ledger using
./daml-start.sh
After this, start the UI server via
yarn start
This should open a browser window with a login screen. If it doesn't, you can manually point your browser to http://localhost:3000.
You can log into the app by providing a user name, say Alice
, clicking
on the calculator icon to generate an access token for the DAML ledger,
and finally clicking on "Sign up". You will be greeted by a screen
indicating that you don't have any friends yet. You can change this by
adding a friend in the upper box, say Bob
. Both boxes on the screen
then reflect the fact that you consider Bob
a friend. After that, let's
log out in the top right corner and sign up as Bob
.
As Bob
, we can see that we don't have any friends yet and that Alice
considers us a friend nevertheless. We can make Alice
a friend by
clicking the plus symbol to the right of here name.
If you are a very popular and friendly person who is considered a friend by many other people and wants to reciprocate that friendship in the application, adding all these other people as friends can become quite tedious. That is where the automation with DAML triggers mentions above becomes handy. To fire up the trigger, we need to execute
./daml-trigger.sh Alice
at the root of the repository.
To see the automation in action, we need to sign up as a new person, say
Charlie
and add Alice
as our friend. If we log out and then log in as
Alice
again, we will see that we reciprocate Charlie
's friendship and
consider him our friend too. We didn't have to do anything to get there,
our DAML trigger has done that for us.
There are many directions in which this application can be extended. Regardless of which direction you pick, the following files will be the most interesting ones to familiarize yourself with:
daml/User.daml
: the DAML model of the simplistic social networksrc/daml/User.ts
: a reflection of the types contained in the DAML model in TypeScriptsrc/ledger/Ledger.ts
: a TypeScript class to communicate with the Ledger APIsrc/components/MainController.tsx
: the React component talking to the Leger APIdaml/Reciprocate.daml
: the automation using DAML triggers
TBD
TBD