Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 2.71 KB

README.md

File metadata and controls

59 lines (42 loc) · 2.71 KB

Snek Raffle Lottery

This repository showcases a Vyper-based decentralized raffle lottery that leverages a custom ERC20 token named SNEK. It serves as both a learning exercise and a demonstration of best practices for writing Vyper smart contracts.


Overview

  1. SNEK Token (ERC20)

    • A custom token implemented in Vyper, following standard ERC20 functionality (e.g., transfer, transferFrom, approve, balanceOf).
    • Minted initially to the contract owner, who can distribute the tokens to participants.
  2. Raffle Lottery

    • Users acquire SNEK tokens (either from the owner or via the faucet).
    • A user must first approve the Raffle contract to spend their tokens.
    • When entering, users call enter_raffle(amount), transferring SNEK tokens to the Raffle contract.
    • A pseudo-random winner is picked after the raffle duration. The winner receives the accumulated pot of SNEK tokens.
    • A small percentage fee is collected for the contract owner, demonstrating fee handling and revenue logic.
  3. SNEK Faucet

    • A simple contract allowing users to claim a small, fixed amount of SNEK tokens at set intervals (e.g., once per day).
    • The faucet contract is funded by the owner (who must approve + deposit SNEK tokens), and any participant can call claim() to receive tokens.

Key Features and Skills Demonstrated

  1. Vyper Contract Development

    • Creation of multiple smart contracts (token, raffle, faucet) entirely in Vyper.
    • Use of Vyper’s syntax, built-in security checks, and immutability features.
  2. ERC20 Implementation

    • Understanding of the approve / transferFrom flow.
    • Implementation of token distribution and balance management.
  3. Raffle Mechanics

    • Raffle entry with a minimum stake requirement.
    • Fee calculation, prize pool accumulation, and winner payout.
    • Demonstrates pseudo-random number usage (with the disclaimer that it is not secure randomness for production).
  4. Faucet Contract

    • Showcases a typical pattern for distributing tokens in test or demo environments.
    • Proper use of allowances, token transfers, and time-based cooldowns.
  5. Ownership and Access Control

    • Restricting critical functionality (e.g., withdrawing fees, resetting faucet, picking winners) to the contract owner.
  6. Deployment & Scripts

    • Includes Python scripts (using boa, moccasin, or other tools) for deploying and testing the contracts.
    • Demonstrates the typical workflow: deploy token → deploy raffle → fund and use faucet → enter raffle.

How to Use

  1. Clone the Repository
    git clone https://github.com/yourusername/snek-raffle-lottery.git
    cd snek-raffle-lottery