Skip to content

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.

License

Notifications You must be signed in to change notification settings

EbiPenMan/Jackpot-Lottery-Smart-Contract

Repository files navigation

Jackpot Lottery Smart Contract

Solidity Contributions Welcome Foundry License: MIT

Introduction

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.

Features

  • 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

Getting Started

Foundry Template

We used this Foundry-based template for developing Solidity smart contracts, with sensible defaults. if you have any questions refer to it.

What's Inside

  • 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

Installation

To deploy and interact with this smart contract, follow these steps:

  1. Clone the repository:

    git clone https://github.com/EbiPenMan/Jackpot-Lottery-Smart-Contract.git
    cd jackpot-lottery-smart-contract
  2. 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.

VSCode Integration

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.

Installing Dependencies

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:

  1. 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
  2. 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.

Deployment

  1. Compile the contract:

    forge compile
  2. Deploy the contract to a local network:

    forge deploy

Usage

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Deploy

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

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Lint

Lint the contracts:

$ bun run lint

Test

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

Interacting with the Contract

Once the contract is deployed, you can interact with it using any Ethereum wallet or a decentralized application (DApp).

Buying Tickets

import { Jackpot } from 'Jackpot';

const jackpot = new Jackpot('YOUR_DEPLOYED_CONTRACT_ADDRESS');

await jackpot.buyTicket([[1, 2, 3, 4, 5]], [10], { value: 0.0055 });

Executing a Draw

await jackpot.executeDraw();

Claiming a Prize

await jackpot.claimPrize(0);

Roadmap

  • 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

Contributing

We welcome contributions from the community! To contribute, please see CONTRIBUTING.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Disclaimer

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.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published