Skip to content
/ shifumi-cameligo Public template

An exemple of a shifumi game contract in CameLIGO

License

Notifications You must be signed in to change notification settings

ligolang/shifumi-cameligo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract Shifumi

This contract implements a "Shifumi" (Rock Paper Scissors game for 2 players.

This smart contract implements a "commit & reveal" mechanism with chest allowing players to keep choice secret until all players have played. In order to motivate players to reveal their secret action, players must lock 10 mutez during "Commit" and they get back their 10 mutez once the secret action is "revealed".

Users can create a new session and specify players and the number of round.

Players can choose an action (Stone, Paper, Cisor) secretly and commit their secret choice. Once all players have chosen their secret action, they can reveal it.

Players can reveal their secret action and commit their secret choice. Once all players have revealed their secret action (for the current round), the result for this round is computed and the session goes to the next round.

The result of the session is automatically computed once all rounds have been played.

The smart contract provides an on-chian view for retrieving the session information:

  • the status of a session (Inplay, Winner, Draw)
  • winners for each round

In the case of a player refusing to play (and keep the session stuck), an entrypoint has been provided to claim victory for 10 minutes of inactivity.

Makefile usage

The repository provides a Makefile for compiling/testing/deploying the smart contract Shifumi. All makefile targets are described with the make command.

Compile Shifumi contract

The repository provides a Makefile for compiling the smart contract Shifumi.

make compile

You can also override make parameters by running :

make compile ligo_compiler=<LIGO_EXECUTABLE> protocol_opt="--protocol <PROTOCOL>"

It compiles the smart contract in TZ file and also in the JSON format

Test Shifumi contract

The repository provides a Makefile for testing the smart contract Shifumi.

make test

Deploy Shifumi contract

The repository provides a deployment script for deploying the smart contract Shifumi.

make deploy

You have to rename deploy/.env.dist to deploy/.env and fill the required variables to be able to deploy.

About

An exemple of a shifumi game contract in CameLIGO

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published