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

Signatory

Observers

Integrity

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

Benefits of Agile Software Development for Enterprise

Advanced Sitecore Healthcheck is available now

Switching between EUS & non-EUS Azure RHEL VM Repositories

5 Programming Projects to Get you Through the Darker Months

Import data from MS SQL Server to Google Sheets using Google Apps Script

Vpn Client Configuration For Mac

Vpn Client Configuration For Mac

Is Python manage.py runserver used in Production??

The things I wish I had done before my first job

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

Unity guide

VRYNT and Oracle join up to drive the next generation of AI based NFT media creation experiences

Safe Liquidations for Decentralized Derivatives

The bond market in crypto