Git Product home page Git Product logo

alarm-bets's Introduction

Alarm Bets

A smart contract game protocol for waking up early. Put down money, choose your target sleep schedule, solve puzzles every morning to prove you've woken up...

Currently in open-development. See the live demo here:

alarmbets.tech

Quickstart

Install monorepo dependencies (pnpm):

pnpm install

Contracts

Run smart contract test suite:

pnpm test-contracts

Deploy contracts to a local node:

pnpm deploy-local

Client

The client is configured to target deployed contracts on various networks (including testnets). To run the client locally:

pnpm client

Running against a local testnet

The interface can be run against a local hardhat deployment, but this takes a few additional steps to setup.

  1. (Optional) If you want to test with in-browser wallet accounts, these accounts can be funded with local testnet funds by creating a .env file under contracts and including two wallet addresses to fund:
FUND_WALLET_1=<wallet address>
FUND_WALLET_2=<wallet address>
  1. Spin up the hardhat node and send funds the wallets:
pnpm deploy-local
  1. In a new shell window, run the interface: pnpm client

  2. Add the hardhat network (Chain Id: 31337) to you browser wallet if not already added. (Metamask Note: If you see 'nonce too high' error, go to settings and click 'reset activity tab data')

  3. Connect wallet and create test alarms locally


The Game: Overview

The game mechanics are quite simple and play out like so:

  1. Find a friend who is willing to accept the challenge of bettering their sleep schedule by waking up earlier
  2. Agree on a target time of day and days of the week to enforce the alarm
  3. Select on a bet value. While the Social Alarm Clock doesn't require value to be deposited, playing the game as a bet will establish strong incentives for you and your partner to stick with the alarm schedule
  4. Start the alarm
  5. Submit 'Wakeup Confirmations' on the mornings of your alarm BEFORE the alarm time passes. If a player misses their alarm, they will have to pay a penalty which gets sent to their partner
  6. Stick to your schedule. The alarm continues indefinitely until either player withdraws their stake.

Wakeup Confirmations:

A 'wakeup cofirmation' represents an onchain proof that you have woken up. For the MVP Social Alarm Clock, players 'prove' that they have woken up by submitting a simple transaction to the alarm contract. This early version requires some level of social layer verfication; Your partner could simply submit their transaction and fall back asleep. It is ultimately up to both players to keep eachother honest. If you find that your partner is not holding true to their wakeup commitment, simply withdraw from the alarm and find another partner.

While this 'naive' approach will be used at the start, future versions of the Social Alarm Clock can introduce fun and novel 'proof of wakeup' mechanics. These could include proofs generated from solving puzzles, geolication data submission that requires you to actually leave your house to 'wakeup', or even simple URI submission that link to pictures of yourself out of bed drinking your morning coffee.

Contracts

The Social Alarm Clock contains a set of simple Solidity smart contracts that facilliate and alarm clock style enforcement schedule, where'confirmations' must be submitted according to the schedule

Client

The frontend is a svelte app that tracks your alarms and allows you to submit wakeup confirmations. The web app works standalone and does not require and centralized infrastructure to use.

alarm-bets's People

Contributors

jaxernst avatar kipcrossing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kipcrossing

alarm-bets's Issues

[ROADMAP] Alarm Bets proposed features

Current state:

The MVP Alarm Bets app is functioning and operational. The smart contracts are deployed and OP Mainnet and can be used via the UI.

Feature Proposals:

Near Term

  • Abstracted wallet and blockchain transactions.

    • Looking into prvy for an embedded wallet provider.
    • Should allow connecting a wallet for auth (SIWE), or traditional auth (google, apple, etc) for users without wallets
    • Needs one-click transactions
  • Puzzle alarms.

    • Users play puzzles to deactivate their alarms
    • This alarm type is paid - alarm deposits ares taxed or winnings/penalties are taxed (TBD)
    • Considering designs that don't leak the answer of the daily puzzle on chain: Zk proofs should be viable
    • Puzzles have to be enjoyable: NYT Connections, Wordle
  • Notifications:

    • Notify when alarm deadlines are approaching
      • Use native notifications for PWA enabled mode
    • Notify users when someone makes an alarm with them, and show all joinable alarms in the UI.
      • Currently you have to search for an alarm id, this is bad UX
      • Alarms should automatically show up in the UI so users can join the alarm without knowing the alarm ID already.
      • Requires indexing blockchain history. Can be done via The Graph or a backend db. (Also possibly the MODE db used in the MUD framework)
  • Setuo basic indexing for user alarms

    • Track alarm state to show history and joinable alarms

Long Term

  • Pooled Alarms
    • Alarms with many users
    • Pools have reward funds that are funded by alarm penalties

[More to be added here]

Get 'add to alarm balance' working

The add to alarm input and modal don't seem to work (might be just mobile). On mobile, that settings menu also seemed to get stuck open after hitting the 'add to balance' button

Install fail

I'm getting dependency conflicts when installing (fresh install) the client modules:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @sac/[email protected]
npm ERR! Found: @wagmi/[email protected]
npm ERR! node_modules/@wagmi/core
npm ERR!   @wagmi/core@"^1.0.5" from @sac/[email protected]
npm ERR!   client
npm ERR!     @sac/[email protected]
npm ERR!     node_modules/@sac/interface
npm ERR!       workspace client from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @wagmi/core@"^0.8.3" from @gnosis.pm/[email protected]
npm ERR! node_modules/@gnosis.pm/safe-apps-wagmi
npm ERR!   @gnosis.pm/safe-apps-wagmi@"^2.1.0" from @sac/[email protected]
npm ERR!   client
npm ERR!     @sac/[email protected]
npm ERR!     node_modules/@sac/interface
npm ERR!       workspace client from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /home/kipling/.npm/_logs/2023-07-29T02_33_43_473Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kipling/.npm/_logs/2023-07-29T02_33_43_473Z-debug-0.log

Also, a readme in the client dir would be a good starting point

Allow users to set display names for their alarm partners

If a user is playing with an address that doesn't have an ENS name, they should be able to edit the display name/nickname for their partner so it displays as a human readable name in the UI. This can be saved in local storage to avoid saving onchain or saving via a backend.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.