A Doodle In DAML — Part 1

What’s a Doodle?

  • A user — hereafter referred to as the organizer— must be able to create a Doodle with a description, voting options and an initial set of voters. After creation, the Doodle will be in a “set-up” mode, that is, not open for voting.
  • The organizer must be able to add / remove voters
  • The organizer must be able to open the Doodle for voting and issue invites to voters.
  • Each voter must be able to vote exactly once for one or more options
  • Each voter must be able to observe the doodle
  • A voter should not be able to vote on behalf of another voter

The DAML Doodle

VotingSlot — DAML Data Structures

Doodle Template Declaration

Template Parameters

  • name —of type Text, which in Java and Scala would map to a java.lang.String and in C++ it would be an std::string.
  • organizer — of type Party. A Party is a native DAML type representing an entity that interacts with the ledger. It can be a natural person or an organization.
  • voters — the list (not array) of type Party representing parties the organizer has invited to vote.
  • options —a list of type String representing options voters can vote for
  • votes —of type TextMap. This is a key-value map where the key is a Text and the value is of the specified type — in our case the VotingSlot data structure. In Java this would be a java.util.Map and in C++ a std:map.
  • open — a boolean that controls the state of the doodle. When set to false, the organizer can still add or remove voters and options, voting is not possible yet. When set to true, voting is possible, but the organizer will not be able to change voter and options any more.

Signatories, Observers and Constraints




The Key

Choices, Contract Archival and Creation

Declaring a Choice

Contract Archival

Creating a New Contract Version

Working With Lists

Adding an Element to a List

Removing an Element from a List

Transforming a List

  • first — lines 6–7 in the code fragment above — a lambda that consumes a list element and creates a DoodleInvite contract out of it.
    Creating a contract is quite self explanatory: use the “create” keyword followed by the template name and the list of named parameters.
  • second, the list the function will iterate over.

To Be Continued




Lead Architect at LiquidShare, building a cloud native, blockchain enabled, financial services SaaS platform.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

I browsed through 100+ brutalist websites; here’s what I learned

Python _curses.error: setupterm: could not find terminal on Docker-compose (10/31/2020)

Version Control with Git

Leetcode — Single Number — Easy

Microsoft Teams “secret” Dev Tool

New Way to Host a Static Website on GitHub Free

How to host a static website on Github

How AWS Lambda Solved a Major Photo Bug

4 Tips How You Can Outsource Your Mobile App Project Effectively

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Emil Kirschner

Emil Kirschner

Lead Architect at LiquidShare, building a cloud native, blockchain enabled, financial services SaaS platform.

More from Medium

Shadow Academy release animated video for debut single White Whale

Spotlight of Web 3.0 — Dive into the Paradigm of Storage on Arweave

Saving the word

Chainwhiz set to speed up Storage and Efficiency with a Grant from Filecoin