{"id":21408524,"url":"https://github.com/dappsar/solana-bootcamp-lottery","last_synced_at":"2026-05-14T05:32:09.662Z","repository":{"id":263488181,"uuid":"890567864","full_name":"dappsar/solana-bootcamp-lottery","owner":"dappsar","description":"A simple \"lottery\" game developed with Solana \u0026 Rust","archived":false,"fork":false,"pushed_at":"2024-11-21T21:24:48.000Z","size":2307,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T04:26:03.106Z","etag":null,"topics":["blockchain","rust","solana","solana-program"],"latest_commit_sha":null,"homepage":"https://solana-s6-lottery.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dappsar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-18T19:51:20.000Z","updated_at":"2024-11-22T16:30:00.000Z","dependencies_parsed_at":"2024-11-19T06:03:53.857Z","dependency_job_id":null,"html_url":"https://github.com/dappsar/solana-bootcamp-lottery","commit_stats":null,"previous_names":["dappsar/solana-bootcamp-lottery"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dappsar%2Fsolana-bootcamp-lottery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dappsar%2Fsolana-bootcamp-lottery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dappsar%2Fsolana-bootcamp-lottery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dappsar%2Fsolana-bootcamp-lottery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dappsar","download_url":"https://codeload.github.com/dappsar/solana-bootcamp-lottery/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243905426,"owners_count":20366821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","rust","solana","solana-program"],"created_at":"2024-11-22T17:16:25.760Z","updated_at":"2026-05-14T05:32:04.639Z","avatar_url":"https://github.com/dappsar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solana Simple Lottery\n\n\nThis **Simple Lottery Game** is built using the Anchor framework on Solana and includes a modern frontend powered by **Next.js**, **TypeScript**, and **Tailwind CSS**. Users can buy lottery tickets by selecting a number between 1 and 75. Once all 25 tickets are sold, the program randomly selects a winner, who can then claim their prize.\n\nNote: \"randomly\": With a pseudo-random method that creates a seed using a combination of on-chain data and the user's public key.\n\n### Key Features\n\n- **Lottery Initialization**: Begins with 25 tickets, each tied to a unique number (1–75), which are shuffled and stored in the game state.\n- **Ticket Purchase**: Users pick a number to purchase a ticket. The program verifies availability, assigns the ticket to the user, and transfers 0.1 SOL from the user to the program.\n- **Winner Selection \u0026 Game Reset**: Upon selling all tickets, a winner is chosen randomly, and the game resets with a fresh shuffle of ticket numbers.\n- **Reward Claim**: The winner can claim their prize (2.5 SOL) by proving ticket ownership.\n- **SOL/Lamport Transfers**: Demonstrates Solana's system program for transferring SOL and manual Lamport manipulation.\n\n### Demo\n\n- **Live Demo**: [here](https://solana-s6-lottery.vercel.app/)\n- **Example images**: [here](.doc/images/)\n\n\n### Folders Structure\n\n#### anchor\n\nThe _anchor_ folder contains the Solana program written in Rust, built using the Anchor framework.\n\nYou can use any normal anchor commands. Either move to the `anchor` directory and run the `anchor` command or prefix the command with `npm run`, eg: `npm run anchor`.\n\n#### web\n\nThe folder \"web\" contains a NextJs application that uses the Anchor-generated client to interact with the Solana program.\n\n---\n\n\n## Getting Started\n\n### Prerequisites\n\nBefore you begin, ensure you have the following installed:\n\n- [Node.js v18.18.0+](https://nodejs.org/)\n- [Rust v1.77.2+](https://www.rust-lang.org/)\n- [Anchor CLI v0.30.1+](https://www.anchor-lang.com/)\n- [Solana CLI v1.18.9+](https://docs.solana.com/cli/install-solana-cli-tools)\n- [Nx CLI](https://nx.dev)\n\n\n### Clone the Repository\n\n```bash\ngit clone \u003crepo-url\u003e\ncd \u003crepo-name\u003e\n```\n\n### Install Dependencies\n\n```shell\n# web\nnpm install -g nx\nnpm install\n\n# anchor\ncd anchor\nnpm install\n```\n\n### Use with program already deployed in devnet\n\nJust start the web app and switch your wallet to devnet.\n\n```shell\nnpm run dev\n```\n\nIf you use Phantom wallet, you have to enable testnet mode. You could get detailed info [here](https://docs.phantom.app/developer-powertools/testnet-mode).\n\n\n## Deploy to localnet\n\n### Build the program\n\n```shell\nnpm run anchor-build\n```\nor\n\n```shell\ncd anchor\nanchor build\n```\n\n### Start the test validator with the program deployed\n\n```shell\nnpm run anchor-localnet\n```\n\nor\n\n```shell\nsolana config set --url localhost\nsolana-test-validator\n```\n\n### get wallets funds \n\n```shell\nsolana airdrop 10\n```\n\n### Deploy to localhost\n\n```shell\ncd anchor\nanchor deploy\n```\n\n### Run the tests\n\n```shell\nnpm run anchor-test\n```\n\n### Update program Id\n\nAfter deploy you have to update del programId in:\n\n- [anchor/Anchor.toml](anchor/Anchor.toml)\n- [anchor/src/lottery-exports.ts](anchor/src/lottery-exports.ts)\n- [anchor/programs/lottery/src/lib.rs](anchor/programs/lottery/src/lib.rs)\n- [anchor/target/idl/lottery.json](anchor/target/idl/lottery.json)\n- [anchor/target/types/lottery.ts](anchor/target/types/lottery.ts)\n\nIn all that files de program id must match!\n\n\n### Start the web app\n\nJust start the web app and switch your wallet to localnet.\n\n```shell\nnpm run dev\n```\n\nIf you receive an error (in the browser console) indicating that the program ID does not match, ensure that the files mentioned above have the correct program ID. You may also try clearing your browser's local cache or deleting the folders `web/.next`, `anchor/.anchor`, and `anchor/.target`, and then follow the steps outlined above again.\n\nSometimes, when using Phantom, the wallet may not be properly set to the correct network. Make sure it is connected to the correct network!\n\nAgain, if you switch between localnet and devnet without refreshing the site, you might encounter this error. Try pressing `Ctrl+F5` to refresh the browser.\n\n\n## Deploy to Devnet\n\nThe same steps as mentioned above, but change the cluster to devnet.\n\n```shell\ncd anchor\nanchor deploy --provider.cluster devnet\n```\n\nAdditionally, after deployment, you need to update the program address in this file within the \"getLotteryProgramId\" method to the Devnet option (switch):\n\n- [anchor/src/lottery-exports.ts](anchor/src/lottery-exports.ts)\n\n\nRemember that to use on devnet, you will need funds in your wallet. You can use [the official Solana faucet](https://faucet.solana.com/).\n\n## Build web \n\nTo build the site, simply run (from project root folder):\n\n```shell\nnpm run build\n```\n\nIf you encounter the following error:\n  _Cannot read properties of null (reading 'message')_ \n  \ntry running:\n\n```shell\nnx reset\n```\n\nnx reset clears the local cache and removes any corrupted or outdated state that Nx may have stored. This is particularly useful when encountering unexpected errors related to task scheduling, dependency graph computation, or workspace configurations. Running this command ensures a clean environment, allowing Nx to rebuild its cache and dependency information from scratch.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdappsar%2Fsolana-bootcamp-lottery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdappsar%2Fsolana-bootcamp-lottery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdappsar%2Fsolana-bootcamp-lottery/lists"}