The Jackpot Lottery Smart Contract is a decentralized lottery system built on the Ethereum blockchain. Participants can buy tickets, and draws are executed at regular intervals. Winners are determined based on matching numbers, and prizes are distributed accordingly.
- Buy tickets with custom numbers
- Weekly draws with random number generation
- Prize distribution based on matching numbers
- Owner fee collection and withdrawal
- View draw results and prizes
- Secure and transparent using Solidity and smart contracts
We used this
Foundry-based template for developing Solidity smart contracts, with sensible defaults. if you have any questions refer to it.
- Forge: compile, test, fuzz, format, and deploy smart contracts
- Forge Std: collection of helpful contracts and utilities for testing
- Prettier: code formatter for non-Solidity files
- Solhint: linter for Solidity code
To deploy and interact with this smart contract, follow these steps:
-
Clone the repository:
git clone https://github.com/EbiPenMan/Jackpot-Lottery-Smart-Contract.git cd jackpot-lottery-smart-contract
-
Install dependencies:
bun install # install Solhint, Prettier, and other Node.js deps
If this is your first time with Foundry, check out the installation instructions.
This template is IDE agnostic, but for the best user experience, you may want to use it in VSCode alongside Nomic Foundation's Solidity extension.
For guidance on how to integrate a Foundry project in VSCode, please refer to this guide.
Foundry typically uses git submodules to manage dependencies, but this template uses Node.js packages because submodules don't scale.
This is how to install dependencies:
- Install the dependency using your preferred package manager, e.g.
bun install dependency-name
- Use this syntax to install from GitHub:
bun install github:username/repo-name
- Use this syntax to install from GitHub:
- Add a remapping for the dependency in remappings.txt, e.g.
dependency-name=node_modules/dependency-name
Note that OpenZeppelin Contracts is pre-installed, so you can follow that as an example.
-
Compile the contract:
forge compile
-
Deploy the contract to a local network:
forge deploy
Build the contracts:
$ forge build
Delete the build artifacts and cache directories:
$ forge clean
Compile the contracts:
$ forge build
Get a test coverage report:
$ forge coverage
Deploy to Anvil:
$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
For this script to work, you need to have a MNEMONIC
environment variable set to a valid
BIP39 mnemonic.
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
Format the contracts:
$ forge fmt
Get a gas report:
$ forge test --gas-report
Lint the contracts:
$ bun run lint
Run the tests:
$ forge test
Generate test coverage and output result to the terminal:
$ bun run test:coverage
Generate test coverage with lcov report (you'll have to open the ./coverage/index.html
file in your browser, to do so
simply copy paste the path):
$ bun run test:coverage:report
Once the contract is deployed, you can interact with it using any Ethereum wallet or a decentralized application (DApp).
import { Jackpot } from 'Jackpot';
const jackpot = new Jackpot('YOUR_DEPLOYED_CONTRACT_ADDRESS');
await jackpot.buyTicket([[1, 2, 3, 4, 5]], [10], { value: 0.0055 });
await jackpot.executeDraw();
await jackpot.claimPrize(0);
- Initial contract implementation
- Ticket purchasing functionality
- Draw execution logic
- Prize claiming mechanism
- Frontend integration
- More comprehensive test coverage
- Integration with Chainlink VRF for true randomness
- Multi-token support for ticket purchasing
- Implement security audits and best practices
We welcome contributions from the community! To contribute, please see CONTRIBUTING.md.
This project is licensed under the MIT License - see the LICENSE file for details.
This project has not undergone security auditing yet. Before using or relying on this project, it is recommended to ensure that security enhancements and proper testing have been conducted.