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.
-
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.
- A custom token implemented in Vyper, following standard ERC20 functionality (e.g.,
-
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.
-
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 callclaim()
to receive tokens.
-
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.
-
ERC20 Implementation
- Understanding of the
approve / transferFrom
flow. - Implementation of token distribution and balance management.
- Understanding of the
-
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).
-
Faucet Contract
- Showcases a typical pattern for distributing tokens in test or demo environments.
- Proper use of allowances, token transfers, and time-based cooldowns.
-
Ownership and Access Control
- Restricting critical functionality (e.g., withdrawing fees, resetting faucet, picking winners) to the contract owner.
-
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.
- Includes Python scripts (using
- Clone the Repository
git clone https://github.com/yourusername/snek-raffle-lottery.git cd snek-raffle-lottery