Git Product home page Git Product logo

daml-scala-task-manager-example's Introduction

DAML-task-manager-scala example

This example demonstrates how to:

  • set up and configure Scala codegen (see codegen configuration in the ./daml.yaml)
  • instantiate a contract and send a corresponding create command to the ledger
  • how to exercise a choice and send a corresponding exercise command
  • subscribe to receive ledger events and decode them into generated Scala ADTs

All instructions below assume that you have DAML SDK installed. If you have not installed it yet, please follow these instructions: https://docs.daml.com/getting-started/installation.html

Create a DAML-task-manager-scala project

daml new ./DAML-task-manager-scala DAML-task-manager-scala

This should output:

Created a new project in "./DAML-task-manager-scala" based on the template "DAML-task-manager-scala".

Where:

  • ./DAML-task-manager-scala is a project directory name

Compile the DAML project

The DAML code for the IOU example is located in the ./daml folder. Run the following command to build it:

$ cd ./DAML-task-manager-scala
$ daml build

this should output:

Compiling DAML-task-manager-scala to a DAR.
Created .daml/dist/DAML-task-manager-scala-0.0.1.dar.

Generate Scala classes representing DAML contract templates

$ daml codegen scala

This should generate scala classes in the ./scala-codegen/src/main/scala directory. See codegen configuration in the daml.yaml file:

...
codegen:
  scala:
    package-prefix: com.knoldus.example.iou.model
    output-directory: scala-codegen/src/main/scala
    verbosity: 2

Start Sandbox

This examples requires a running sandbox. To start it, run the following command:

$ daml sandbox ./.daml/dist/DAML-task-manager-scala-0.0.1.dar

where ./.daml/dist/DAML-task-manager-scala-0.0.1.dar is the DAR file created in the previous step.

Compile and run Scala example

Run the following command from the DAML-task-manager-scala folder:

$ sbt "application/runMain com.knoldus.example.iou.TaskManagerMain localhost 6865"

If example completes successfully, the above process should terminate and the output should look like this:

<Sent and received messages>
...
11:54:03.865 [run-main-0] INFO - Shutting down...
...
[success] Total time: 7 s, completed Sep 12, 2019, 11:54:04 AM

daml-scala-task-manager-example's People

Watchers

James Cloos avatar Himani Arora avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.