I was inspired to learn more about smart contract development on Tezos and to explore some of the unique features that have been recently added to that ecosystem - namely tickets

What it does

I made a 'hot potato' game for any number of players. Anyone can initiate and manage games and anyone can participate in other people's games.

Players buy-in to a game by spending 10XTZ to recieve their hot potato. The potatoes are represented in the code as tickets.

When the tickets for that game have run out (or enough people have bought in) the game is started.

Players then pass their potato back whenever they feel like but each player wants to be the last to pass their potato before the game is ended. The players do not know how long each game will last.

When the game is ended the last person to pass their potato before the game end receives the whole pot as the prize.

How we built it

It is built in Ligo, a smart contract language on Tezos with OCaml-like syntax.

This is compiled and generates Michelson code which can be used to originate contracts on the Tezos blockchain.

It was tested manually using the tezos-client on a local sandbox environment and on the Tezos Florence testnet.

Challenges we ran into

Working with the Tickets type was hard. Once created they cannot be copied so doing normal things like writing functions that take a ticket as an argument will not type check as passing one as an argument would involve a copy.

Also defi on Tezos is fairly new and so the tooling, whilst of a very high quality, can be hard to figure out sometimes. Getting a local sandbox up and running and understanding how all the pieces fit together took me a while. Then originating the contracts on a remote testnet was non-trivial for me.

I didn't have time to write a front end.

I also didn't properly test the FA2 aspects of the game contract - I'm not sure I understand that part properly so I'll be looking at that more.

Accomplishments that we're proud of

Getting the game working and then testing locally and then originating it on the testnet was a great feeling. The fact that it worked the same on the remote testnet as on my local sandbox gave me great confidence in the Tezos tooling and ecosystem.

What we learned

  • How to write smart contracts on Tezos - I'd never done it before - it's only been a month.

  • How to setup local sandboxes.

  • How to build/compile and run Tezos itself.

  • What tools I need to effectively write and test smart contracts on Tezos.

What's next for Baking-potato

Front end

Make a front end - pretty important - all interactions are currently done through the command line. Probably look at taquito for this.


Make sure FA2 parts are working correctly and make sense. I'm not confident I fully understand this part so would need to go through in more detail, probably using tqtezos codebase.

Private transactions

Use sapling to make the game initiators commit to a stopping time for their game.

Sapling lets you do private transactions - the idea would be that you charge some amount of XTZ per minute as a deposit that gets returned if the game lasts that amount of time e.g.

new_game(game_id, admin_address, max_players, number_minutes) -> shielded transaction of number_minutes * 10 XTZ

The initial deposit would be private to the game initiator and then revealed to the players when the game ends. They can verify that the game did last that long and the deposit could be returned.

Built With

  • edo
  • fa2
  • florence
  • ligo
  • tezos
  • tickets
Share this project: