Skip to content

digital-asset/dablchess

Repository files navigation

Sample code

This repo contains sample code to help you get started with DAML. Please bear in mind that it is provided for illustrative purposes only, and as such may not be production quality and/or may not fit your use-cases. You may use the contents of this repo in parts or in whole according to the BSD0 license:

Copyright © 2020 Digital Asset (Switzerland) GmbH and/or its affiliates

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Daml Chess

License CircleCI

Welcome to Daml Chess! A DAML app that can be deployed to Daml Hub. Daml Chess is a fog-of-war variant of Chess where you see only your pieces and where they can move. We demonstrate the power of DAML as the state of the two sides are encoded in separate smart contracts; what you know depends on DAML's ledger model, but you can still play via an intermediary.

Copyright (c) 2020, Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. SPDX-License-Identifier: 0BSD

Getting Started

Deploying to Daml Hub.

1. Create a ledger to run Daml Chess on

Log in to Daml Hub and scroll to the bottom of the workspace. Click the Deploy button on the Daml Chess tile.

2. Set up your automation

Click on your new Daml Chess ledger and finish deploying the Daml Chess package by clicking Deploy Instance. Then, once your ledger has the status Running, add the User Admin party in the Identities tab. Finally, go back to the Deployments tab and click on the Automation file. Configure a new instance of this automation as the User Admin party.

4. Log in and start playing!

You can find the subdomain url of your Daml Chess app in the Ledger Settings or Deployments tab of your ledger. When you login, give yourself an alias so that you are discoverable to other players.

Developing

1. Prerequisites

2. Clone this repo

git clone https://github.com/digital-asset/dablchess.git

3. Start the game locally:

# A DAML in memory ledger, a sandbox
$ make start_daml_server
# An bot that listens to ledger requests and advances play.
$ make start_operator
# A React app that displays game logic.
$ make start_ui_server

or

$ make start_all

4. Stop the game locally:

$ make stop_all

5. Release

$ make package

This will create a versioned dablchess-x.x.x.dar file containing the compiled DAML model, a dablchess-bot-x.x.x.tar.gz tarball containing the python automation, and a dablchess-ui-x.x.x.zip archive containing the UI static assets. These files will be zipped into a dabl-chess.zip under the target/ directory.