Solana Riptide Hackathon
# set config to localhost to test against a local validator
solana config set -u devnet
# define wallet to use for transactions
# copy path from 'Keypair Path'
export ANCHOR_WALLET=$(solana config get | grep 'Keypair Path' | cut -d ' ' -f3)
# add phantom wallet pubkey used to connect to dapp through browser
export PHANTOM_WALLET="phantom-wallet-pubkey"
# initialize vrf
mkdir secrets
# Create and seed payer account
solana-keygen new --no-bip39-passphrase --outfile secrets/payer-keypair.json
solana airdrop 2 secrets/payer-keypair.json
solana airdrop 2 secrets/payer-keypair.json
solana airdrop 2 secrets/payer-keypair.json
solana airdrop 2 secrets/payer-keypair.json
spl-token wrap 4 secrets/payer-keypair.json
# initialize writes pubkeys to 'clientaccounts.env'
# other funcs read from 'clientaccounts.env'
# required for further commands
# will read $PHANTOM_WALLET to mint dummy tokens
ts-node ./sdk/scripts/initialize.ts init --queueKey F8ce7MsckeZAbAGmxjJNetxYXQa9mKr9nnrC3qKubyYy --userAddress $PHANTOM_WALLET
# run app in a new terminal
cd app/ && yarn run dev
# navigate to webapp with a browser at http://localhost:3000
# connect to webapp with Phantom and airdrop some SOL for transaction fees
solana airdrop 100 $PHANTOM_WALLET
# stake deposit tokens
ts-node ./sdk/scripts/stake.ts
# draw winning ticket numbers
ts-node ./sdk/scripts/request.ts request 8uZLtNzRM5dH3K4VN4wdw4QRs5EEuovGrSkzfmfyGYxZ --payer secrets/payer-keypair.json --rpcUrl https://api.devnet.solana.com --cluster devnet
# dispense prize to winner
ts-node ./sdk/scripts/dispense.ts
anchor test
- users choose numbers, creates PDA numbers and vault pubkey as seed
- users calls
buy
adds in their PDA, receives ticket - cranks call
draw
, draw selects 6 random numbers and sets these in vault manager config.draw
locksbuy
until find is called - cranks call
dispense
, pass in PDA derived from winning numbers generated bydraw
- if winning numbers PDA passed to
dispense
is an already initialized account, send the prize to the owner - if winning numbers PDA passed to
dispense
is not initialized, unlock buy, zero out winning numbers, no error
- crank calls
stake
periodically to exchange tokensdeposit
tokens indeposit_vault
foryield
tokens inyield_vault
via an AMM - user calls
redeem
, first look indeposit_vault
to see if we have enough liquidity. - if enough liquidity, transfer
deposit
tokens back to user` - if not call
swap_tokens
to get enough liquidity and transferdeposit
tokens back to user. - if
dispense
finds winner, calculate prize amount and callswap_tokens
to swap allyield
tokens fordeposit
tokens, calculate prize and send to winner.
- Convert from PDA only to PDA + NFT
- Use Orca in Dev, SOL_ORCA
- Split lottery and integration programs