Solana Riptide Hackathon
# start validator and load programs
anchor localnet
# set config to localhost to test against a local validator
solana config set -u localhost
# 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 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
# 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/draw.ts
# dispense prize to winner
ts-node ./sdk/scripts/dispense.tsanchor test- users choose 6 numbers, creates PDA numbers and vault pubkey as seed
- users calls
buyadds in their PDA, receives ticket - cranks call
draw, draw selects 6 random numbers and sets these in vault manager config.drawlocksbuyuntil find is called - cranks call
dispense, pass in PDA derived from winning numbers generated bydraw - if winning numbers PDA passed to
dispenseis an already initialized account, send the prize to the owner - if winning numbers PDA passed to
dispenseis not initialized, unlock buy, zero out winning numbers, no error
- crank calls
stakeperiodically to exchange tokensdeposittokens indeposit_vaultforyieldtokens inyield_vaultvia an AMM - user calls
redeem, first look indeposit_vaultto see if we have enough liquidity. - if enough liquidity, transfer
deposittokens back to user` - if not call
swap_tokensto get enough liquidity and transferdeposittokens back to user. - if
dispensefinds winner, calculate prize amount and callswap_tokensto swap allyieldtokens fordeposittokens, calculate prize and send to winner.