Sol.College

Full lesson

winisol

Transparent and decentralized solana lottery

What it does

From the project README:

You can use any normal anchor commands. Either move to the `anchor` directory and run the `anchor` command or prefix the command with `pnpm`, eg: `pnpm anchor`.
Original
Shobhit2205/winisol
SuperStack fork
Blockchains/winisol @ 1930ba0
Stars
0
Last push (original)
2025-12-13
Languages
TypeScript, Rust, CSS, JavaScript
Detected stack
AnchorNext.jsweb3.js
Categories
Infrastructure & Tooling
Licence
MIT
Homepage
http://winisol.com

Architecture

80 source files. By extension: .tsx ×58, .ts ×20, .js ×1, .rs ×1.

Top-level directorySource files
src73
anchor5
(root)2

On-chain programs: anchor/programs/winisol

Dapp: deploying

This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/winisol/, once it is deployed and checked on devnet. Until then, run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

Shobhit2205/winisol · anchor/programs/winisol/src/lib.rs L781–804 @ 1930ba0 · MIT · original
}  #[derive(Accounts)]#[instruction(lottery_id: u32)]pub struct InitializeConifg<'info> {  #[account(mut)]  pub payer: Signer<'info>,   #[account(      init,      payer = payer,      space = 8 + TokenLottery::INIT_SPACE,      seeds = [b"token_lottery".as_ref(), lottery_id.to_le_bytes().as_ref()],      bump  )]  pub token_lottery: Box<Account<'info, TokenLottery>>,   pub system_program: Program<'info, System>,} #[derive(Accounts)]#[instruction(lottery_id: u32)]pub struct InitializeLimitedLotteryConfig<'info> {
  1. Line 788 pub payer: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 791 init,: Creates and pays for a new account. Space and payer must be specified.
  3. Line 794 seeds = [b"token_lottery".as_ref(), lottery_id.to_le_bytes().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  4. Line 795 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
Shobhit2205/winisol · src/components/winisol/winisol-data-access.tsx L73–96 @ 1930ba0 · MIT · original
          new Date(data.endTime).getTime() / 1000,          new BN(data.price * LAMPORTS_PER_SOL),        ).instruction();            const computeUnitLimitIx = ComputeBudgetProgram.setComputeUnitLimit({          units: 40000,          });                const recentPriorityFees = await connection.getRecentPrioritizationFees();        const minFee = Math.min(...recentPriorityFees.map(fee => fee.prioritizationFee));            const computeUnitPriceIx = ComputeBudgetProgram.setComputeUnitPrice({          microLamports: minFee + 1,         });          const blockhashContext = await connection.getLatestBlockhashAndContext();            const tx = new Transaction({          feePayer: publicKey,          blockhash: blockhashContext.value.blockhash,          lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight        }).add(computeUnitLimitIx).add(computeUnitPriceIx).add(InitConfigIx);            const signature = await sendTransaction(tx, connection, {skipPreflight: true});
  1. Line 77 const computeUnitLimitIx = ComputeBudgetProgram.setComputeUnitLimit({: Sets the compute-unit limit or price (priority fee).
  2. Line 88 const blockhashContext = await connection.getLatestBlockhashAndContext();: Fetches a recent blockhash. Transactions expire if it gets too old.
  3. Line 96 const signature = await sendTransaction(tx, connection, {skipPreflight: true});: Submits the signed transaction to the cluster.

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 devnext dev
.npm run startnext start
.npm run buildnext build
.npm run lintnext lint
anchoranchor buildcompile programs and generate IDLs
anchoranchor testlocal validator + test suite
anchoranchor run test../node_modules/.bin/jest --preset ts-jest

What you could build from it

Used in lessons