Sol.College

Structure lesson (licence does not allow quoting code)

friendstake

Peer to peer betting app

Original
konstantinagian/friendstake
SuperStack fork
Blockchains/friendstake @ 0364ee3
Stars
0
Last push (original)
2024-04-09
Languages
TypeScript, Rust, JavaScript, CSS
Detected stack
AnchorNext.jsweb3.js
Categories
Other
Licence
none detected: code not quoted on Sol.College
Homepage
https://friendstake.vercel.app

Architecture

45 source files. By extension: .tsx ×26, .rs ×10, .ts ×6, .js ×3.

Top-level directorySource files
app33
programs10
migrations1
tests1

On-chain programs: programs/peer-to-peer-betting

How it works: instructions and accounts

Each instruction handler and the accounts struct it validates, found by reading the Rust source. Links go to the exact line at the pinned commit.

InstructionAccountsSource
makeMakeprograms/peer-to-peer-betting/src/lib.rs:19
cancelCancelprograms/peer-to-peer-betting/src/lib.rs:25
takeTakeprograms/peer-to-peer-betting/src/lib.rs:30
declineDeclineprograms/peer-to-peer-betting/src/lib.rs:35
settle_betSettleBetprograms/peer-to-peer-betting/src/lib.rs:40

Where the Solana code lives

Source files that import a Solana SDK, ranked by how many Solana APIs they use, with the APIs each one calls. Read them in this order to see how the app talks to the chain.

FileSolana APIs used
app/friendstake/web/components/bet/bet-data-access.tsxPublicKey, useConnection, AnchorProvider, Program, SystemProgram, findProgramAddressSync
tests/peer-to-peer-betting.tsgetBalance, SystemProgram, Keypair, PublicKey, requestAirdrop, Program
app/friendstake/web/components/account/account-data-access.tsxPublicKey, useConnection, VersionedTransaction, TransactionMessage, transfer, useWallet
app/friendstake/web/components/bet/bet-ui.tsxPublicKey, useWallet, signTransaction
app/friendstake/web/components/account/account-ui.tsxPublicKey, useWallet, Transaction, sendTransaction
programs/peer-to-peer-betting/src/instructions/settle_bet.rsseeds, transfer, CpiContext, has_one, Program
programs/peer-to-peer-betting/src/instructions/cancel.rsseeds, transfer, has_one, CpiContext, Program
programs/peer-to-peer-betting/src/instructions/decline.rsseeds, transfer, has_one, Program, CpiContext
programs/peer-to-peer-betting/src/instructions/take.rstransfer, has_one, seeds, Program, CpiContext
programs/peer-to-peer-betting/src/instructions/make.rstransfer, seeds, Program, CpiContext
app/friendstake/web/components/cluster/cluster-ui.tsxuseConnection, Connection
programs/peer-to-peer-betting/src/state/mod.rsPubkey

Dapp: devnet deploy pending

⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/friendstake/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
.npm run lint
app/friendstakenpm run dev
app/friendstakenpm run build
.anchor build
.anchor test
.anchor run test
.cargo build
.cargo test

What you could build from it