chainsona / vrf-flip

Utilize Switchboard's verifiable randomness to simulate a heads or tails coin toss.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Switchboard VRF Flip

Utilize Switchboard's verifiable randomness to simulate a heads or tails coin toss.

Setup

git clone https://github.com/switchboard-xyz/vrf-flip.git && cd vrf-flip
yarn install
yarn link

Setup program keypairs and client for your environment

yarn client:gen

Deploy the program to devnet with your new Program ID

anchor build && anchor deploy

CLI

NOTE: If using localnet, make sure to pass -c localnet to the commands below.

Create a keypair for the house authority

solana-keygen new --no-bip39-passphrase --outfile house-authority-keypair.json

Create the House account

sbv2-vrf-flip init house-authority-keypair.json uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX
# sbv2-vrf-flip init KEYPAIR QUEUEKEY

NOTE: The House must be initialized with a queue that has unpermissioned_vrf_enabled enabled.

Create a keypair for the user

solana-keygen new --no-bip39-passphrase --outfile user-keypair.json

Create the User account

sbv2-vrf-flip create user-keypair.json

Request some FLIP tokens

sbv2-vrf-flip airdrop user-keypair.json

PLAY!

sbv2-vrf-flip play user-keypair.json --gameType coin-flip --guess 2

where,

  • gameType can be coin-flip, roll-dice, roll-20-sided-dice.
  • guess can be 1 through 2 for a coin-flip, 1 through 6 for dice-roll, and 1 through 20 for a roll-20-sided-dice
  • betAmount is the number of tokens to wager

Speed Run

solana-keygen new --no-bip39-passphrase --outfile house-authority-keypair.json
sbv2-vrf-flip init house-authority-keypair.json uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX
solana-keygen new --no-bip39-passphrase --outfile user-keypair.json
sbv2-vrf-flip create user-keypair.json
sbv2-vrf-flip airdrop user-keypair.json
sbv2-vrf-flip play user-keypair.json --gameType coin-flip --guess 2

About

Utilize Switchboard's verifiable randomness to simulate a heads or tails coin toss.

License:MIT License


Languages

Language:TypeScript 78.5%Language:Rust 18.3%Language:JavaScript 2.5%Language:HTML 0.8%