Code Monkey home page Code Monkey logo

coin-flip's Introduction

CoinFlip (Solana)

Demo

https://sol-coinflip.vercel.app/ -> Runs in devnet Run

Provable Coin Flip Program on Solana.

The app consists of a vendor and a player.

  1. Player triggers a coin flip game by selecting side and the amount of SOL to bet.
  2. Vendor creates a CoinFlip game on-chain and saves the bet of the user and sends the equal amount of SOL to CoinFlip PDA. In this step, vendor generates a random seed to be used in the coin flip.
  3. When the CoinFlip account is created, user generates a random seed and sends approves the Play transaction by sending the bet amount to CoinFlip PDA.
  4. Play function will combine the vendor hash, player hash and the current timestamp to flip the coin. This way, not a single participant can influence the result as the seeds are aggregated from different sources.
  5. CoinFlip account sends the amount to the winner, logs the events and closes the account.

Webapp

Webapp is generated using Next.js and Solana Wallet Adapter.

Running the app

  1. Start the local Solana validator
  2. Deploy the app to local cluster with anchor deploy
  3. Go to the app directory and run npm run install
  4. Run the app with VENDOR_SECRET_KEY env variable. You can use any keypair as the vendor. Example: VENDOR_SECRET_KEY=[12, 232,1231 ...] npm run dev

coin-flip's People

Contributors

blacksaru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

coin-flip's Issues

https://sol-coinflip.vercel.app/ not working

Hello, I am getting an error playing the game on your website. The message it displays after I click "Play" first says "Generating Random Seed" and then says "Status: Something went wrong, please try again." Is this on your end or my end and how can this be fixed?

Any help would be appreciated, thanks.

I got issue when tried to run the app

image

and how to do this command "Run the app with VENDOR_SECRET_KEY env variable. You can use any keypair as the vendor. Example: VENDOR_SECRET_KEY=[12, 232,1231 ...] npm run dev"

Tried with "VENDOR_SECRET_KEY=[12, 232,1231 ...] npm run dev" ofc i have changed the Vendor Value, but it said "VENDOR_SECRET_KEY COMMAND IS NOT FOUND"

please make a full tutorial about this project :) i'm new at deploying smart contract

help pls?

Hey any chance you can update readME file and show each command to run to get it going?? Would be amazing!

help pls

Problem: nothing works when i press play button.
Normally he has to tell me if I won or not.
API resolved without sending a response for /api/setup, this may result in stalled requests.

it responds to me with such an answer on visual code terminal. What should I do?

image

Small Issue with program.rpc.play

Screenshot 2023-10-03 at 5 48 32 PM
Screenshot 2023-10-03 at 5 46 52 PM

Hello @venture1981, sorry to bother you mate.. I've just run into a small issue.. Using anchor test.. everything works out smoothly and there are no issues.. however when I deploy the contract and try to use the dev-net I run into this issue:
When the user/player is supposed to sign the transaction after the setup.. it throws the error I showed above.. and given I'm pretty new as to how this works.. I'm struggling to figure it out.. the vendor doesn't need to sign the transaction right?

any help would be very appreciated. Thank you for your time.

Wallet Detection

Hello,

Was running this on linux server and devnet, it would run but would not detect the solana wallet. Not sure if it is because of the VENDER_SECRET_KEY, not sure how to use this command. Any help would be appreciated, thanks.

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.