{"id":18708411,"url":"https://github.com/marigold-dev/decookies","last_synced_at":"2025-04-12T10:34:23.938Z","repository":{"id":61696537,"uuid":"513592875","full_name":"marigold-dev/decookies","owner":"marigold-dev","description":"Deku with cookies","archived":false,"fork":false,"pushed_at":"2022-12-28T14:16:43.000Z","size":6935,"stargazers_count":8,"open_issues_count":7,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-04-14T12:27:14.775Z","etag":null,"topics":["dapp","dapp-example","deku","layer-2","marigold","sidechain","tezos"],"latest_commit_sha":null,"homepage":"https://www.marigold.dev/deku","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marigold-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-13T16:24:02.000Z","updated_at":"2023-07-27T12:08:18.000Z","dependencies_parsed_at":"2023-01-31T06:45:53.943Z","dependency_job_id":null,"html_url":"https://github.com/marigold-dev/decookies","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marigold-dev%2Fdecookies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marigold-dev%2Fdecookies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marigold-dev%2Fdecookies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marigold-dev%2Fdecookies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marigold-dev","download_url":"https://codeload.github.com/marigold-dev/decookies/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223511459,"owners_count":17157521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dapp","dapp-example","deku","layer-2","marigold","sidechain","tezos"],"created_at":"2024-11-07T12:23:17.538Z","updated_at":"2024-11-07T12:23:18.485Z","avatar_url":"https://github.com/marigold-dev.png","language":"TypeScript","readme":"# Decookies\n\nDecookies is a front-end application, allowing players to bakes cookies on [Marigold Sidechain Deku](https://www.marigold.dev/deku).\n\n## Run the game\n\n1. Git clone this repo\n\n2. Run `npm start` and go to `http://localhost:3000` to see the minimalist UI:\n\n![](resources/doc/homepage.png)\n\n3. Filfill the `Deku node URI` with the URI of your running Deku node\n\n4. Login using [`Beacon wallet`](https://docs.walletbeacon.io/supported-wallets/).\n\n\u003e ** ⚠️ The only thing Decookies will ask you to sign, is the \"delegation\". Under the hood, we generate a random private key to sign all the operations submitted to Deku. ⚠️**\n\nThe delegation operation submitted to Deku is:\n```ligo\nDelegate({onBehalfOf: \\\"tz1xxx\\\" as address})\n```\n\nWhere `tz1xxx` is your Beacon public address. This operation will be submitted to Deku via the randomly generated key, and will allow decookies to bake cookies from the generated address, and link them to your real Beacon address.\n\nHere is an example of the state on Deku side:\n\n```JSON\n\"state\":\n    [ \"Map\",\n        [ [ [ \"String\", \"tz1xxxxx\" ],\n            [ \"Pair\",\n            [ [ \"Pair\",\n                [ [ \"Pair\",\n                    [ [ \"Pair\",\n                        [ [ \"Pair\",\n                            [ [ \"Set\",\n                                [ [ \"String\",\n                                    \"tz1Generated1\" ],\n                                    [ \"String\",\n                                    \"tz1Generated2\" ],\n                                    [ \"String\",\n                                    \"tz1Generated3\" ],\n                                    [ \"String\",\n                                    \"tz1Generated4\" ],\n                                    [ \"String\",\n                                    \"tz1Generated5\" ] ] ],\n                                [ \"Int\", \"60\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"0\" ], [ \"Int\", \"2232516\" ] ] ] ] ],\n                        [ \"Pair\",\n                        [ [ \"Pair\", [ [ \"Int\", \"57\" ], [ \"Int\", \"1\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"1220491\" ], [ \"Int\", \"0\" ] ] ] ] ] ] ],\n                    [ \"Pair\",\n                    [ [ \"Pair\",\n                        [ [ \"Pair\",\n                            [ [ \"Int\", \"50\" ], [ \"Int\", \"172\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"1\" ], [ \"Int\", \"115\" ] ] ] ] ],\n                        [ \"Pair\",\n                        [ [ \"Pair\", [ [ \"Int\", \"1\" ], [ \"Int\", \"40\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"0\" ], [ \"Int\", \"15612\" ] ] ] ] ] ] ] ] ],\n                [ \"Pair\", [ [ \"Int\", \"2314\" ], [ \"Int\", \"2\" ] ] ] ] ] ] ] ]\n```\n\nIn this case, `tz1xxxxx` is my actual Beacon public address, and `tz1GeneratedX` are every generated keys allowed to bake cookies for me. A new random key is generated each time you disconnect your wallet.\n\n5. Bake cookies!\n\n### Game principles\n\nWe basically implemented the same scenario as [cookie-clicker](https://cookieclicker.fandom.com/wiki/Cookie_Clicker_Wiki).\n\nHence, the levels are almost the same (still in WIP) and the costs calculation is almost the same.\n\n#### Baking cookies\n\nThe goal of this game is to bake as many cookies as possible. To do so, there are several ways:\n\n- Click on the cookie button. Each click will submit one cookie to be baked to Deku (cookie in oven). Once the operation had been included in a block, you will have the cookie.\n- Buy buildings to passively bake cookies for you. For example, you can buy your first Cursor for 15 cookies. Once the cursor had been baked, it will bake one cookie per second for you.\n\n#### Transfer cookies\n\nWe added a feature to transfer cookies from your game to an other player. You simply need to fulfill the amount and the recipient address.\n\n#### Eating cookies\n\nWhat is a cookie baking game if we cannot eat them?\n\nHence, we added this feature. Let's see who is the biggest eater! A leaderboard will be available to see who has eaten the more cookies! Let's eat yours!\n\n## FAQ\n\n1. Who are Marigold? And what are they working on?\n\n\u003e [Marigold](https://www.marigold.dev/) is a dynamic and collaborative company, established by Gabriel Alfour in November 2020, focused on testing and developing upgrades to the Tezos Protocol.\n\nWe have several projects, and one of them is the **Deku sidechain.**\n\nDecookies, is a game running on this Deku sidechain.\n\n2. What is the cookie-clicker game?\n\nAt the genesis of this project, we had two different goals:\n\n- Create a blockchain app to betatest our onboarding on Deku-P\n- Test Deku transaction per second\n\nWe decided to develop a gam to do them both! We chose to do a cookie-clicker game like (we were mainly inspired by [this one](https://orteil.dashnet.org/cookieclicker/) from Orteil), because it will force us to:\n\n- reach high TPS on Deku side\n- develop blockchain app\n- develop front to interact with blockchain app\n\n[A first article had been posted on Marigold blog](https://www.marigold.dev/post/30-min-to-create-your-first-blockchain-app-with-typescript-deku) to create your first Blockchain App. Decookies, is a front allowing players to interact with the related Blockchain App, running on Deku Parametric AKA Deku-P.\n\n3. Decookies asks me to sign an operation, what is it?\n\nTo preserve the gameplay, we need to use the [`InMemorySigner` from Taquito](https://tezostaquito.io/docs/inmemory_signer/). This signer needs the Private key and Public address of the user. Of course, we are not going to ask for your private key (because you know you must never share it).\n\nHence, we use the Beacon SDK to sign a payload submitted to Deku. This payload is simply:\n```\nDelegate({onBehalfOf: \\\"tz1xxx\\\" as address})\n```\n\nWhich means, the randomly generated private key, will be able to bake cookies for you, on Deku side.\n\n**Please note, this is the only payload you will ever have to sign from Decookies. Of course, if you change browser or whatever, you will have to sign, again, this same payload, but for an other random private key.**\n\nOn Deku side, your state will look like:\n\n```JSON\n\"state\":\n    [ \"Map\",\n        [ [ [ \"String\", \"tz1xxxxx\" ],\n            [ \"Pair\",\n            [ [ \"Pair\",\n                [ [ \"Pair\",\n                    [ [ \"Pair\",\n                        [ [ \"Pair\",\n                            [ [ \"Set\",\n                                [ [ \"String\",\n                                    \"tz1Generated1\" ],\n                                    [ \"String\",\n                                    \"tz1Generated2\" ],\n                                    [ \"String\",\n                                    \"tz1Generated3\" ],\n                                    [ \"String\",\n                                    \"tz1Generated4\" ],\n                                    [ \"String\",\n                                    \"tz1Generated5\" ] ] ],\n                                [ \"Int\", \"60\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"0\" ], [ \"Int\", \"2232516\" ] ] ] ] ],\n                        [ \"Pair\",\n                        [ [ \"Pair\", [ [ \"Int\", \"57\" ], [ \"Int\", \"1\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"1220491\" ], [ \"Int\", \"0\" ] ] ] ] ] ] ],\n                    [ \"Pair\",\n                    [ [ \"Pair\",\n                        [ [ \"Pair\",\n                            [ [ \"Int\", \"50\" ], [ \"Int\", \"172\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"1\" ], [ \"Int\", \"115\" ] ] ] ] ],\n                        [ \"Pair\",\n                        [ [ \"Pair\", [ [ \"Int\", \"1\" ], [ \"Int\", \"40\" ] ] ],\n                            [ \"Pair\",\n                            [ [ \"Int\", \"0\" ], [ \"Int\", \"15612\" ] ] ] ] ] ] ] ] ],\n                [ \"Pair\", [ [ \"Int\", \"2314\" ], [ \"Int\", \"2\" ] ] ] ] ] ] ] ]\n```\n\nand you can verify this by running:\n\n```bash\n$ curl https://deku-canonical-vm0.deku-v1.marigold.dev/api/v1/state/unix/DK1DpUMB44Ex3WXEUXPjp9DDkjiQ5cyvVwoU/\n```\n\nThis will print the entire state of Decookies contract deployed on Deku.\n\n4. How can I know the public address of my game, to ask cookies from a friend?\n\nAs explained previously, the Public Address is generated. It is now displayed right below the form you have to complete.\n\n## State machine diagram\n\n```mermaid\nstateDiagram-v2\n    direction LR\n    Player --\u003e cookieBaker\n    cookieBaker --\u003e Cursors\n    cookieBaker --\u003e Grandmas\n    cookieBaker --\u003e MintCookie : Click to mint one cookie\n    MintCookie --\u003e cookieBaker : Receive one cookie\n    state BuyCursor \u003c\u003cBuyCursor\u003e\u003e\n        cookieBaker --\u003e BuyCursor\n        BuyCursor --\u003e NotEnoughCookie: if cookieBaker.cookies \u003c cursorCost\n        BuyCursor --\u003e +1Cursor : if cookieBaker.cookies \u003e= cursorCost\n        BuyCursor --\u003e cookieBaker: add one cursor\n    state BuyGrandma \u003c\u003cBuyGrandma\u003e\u003e\n        cookieBaker --\u003e BuyGrandma\n        BuyGrandma --\u003e NotEnoughCookie: if cookieBaker.cookies \u003c grandmaCost\n        BuyGrandma --\u003e +1Grandma : if cookieBaker.cookies \u003e= grandmaCost\n        BuyGrandma --\u003e cookieBaker: add one Grandma\n    Cursors --\u003e MintCookie : Each cursor mint 1cps\n    MintCookie --\u003e cookieBaker : Receive 1cps\n    Grandmas --\u003e MintCookie : Each grandma mint 3cps\n    MintCookie --\u003e cookieBaker : Receive 3cps\n```\n\n\u003e CPS=Cookies Per Second\n\n**TL;DR;**\n\nEach player as a `cookieBaker` type, which stores every counters:\n\n- number of cookies\n- number of cursors\n- number of grandmas\n  There are several possible actions:\n- mint a cookie =\u003e simply add one cookie in the current amount of cookies\n- buy a cursor =\u003e if enough cookie to buy one, add one cursor to the current amount of cursors. Every seconds, one cursor will mint one cookie for the user.\n- buy a grandma =\u003e if enough cookies to buy one, add one grandma to the current amount of grandams. Every secondes, one grandma will mint three cookies for the user.\n\n## Diagram sequence\n\n```mermaid\nsequenceDiagram\n    participant Player2\n    actor Player1\n    participant State\n    participant Cursor\n    Note right of Cursor: Cursor initial cost is 15 cookies\n    participant Grandma\n    Note right of Grandma: Grandma initial cost is 100 cookies\n    loop Each click\n        Player-\u003eState: Mint 1 cookie\n    end\n    loop Each second\n        loop Each cursor\n            Cursor-\u003eState: Mint 1 cookie\n        end\n    end\n    loop Each second\n        loop Each grandma\n            Grandma-\u003eState: Mint 3 cookies\n        end\n    end\n    critical Buy a Cursor\n        Player--\u003eState: buy cursor\n    option Enough cookies\n        State--\u003eState: Player has one more cursor\n    end\n    critical Buy a Grandma\n        Player--\u003eState: buy Grandma\n    option Enough cookies\n        State--\u003eState: Player has one more Grandma\n    end\n    critical Send cookies\n        Player1--\u003ePlayer2: send 3 cookies\n    option Enough cookies\n        State--\u003eState: Player1 has enough cookies\n    end\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarigold-dev%2Fdecookies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarigold-dev%2Fdecookies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarigold-dev%2Fdecookies/lists"}