As part of Encode's Aptos bootcamp, the team (Aashish and Akshar) worked on the project: Aptos Lottery. This project implements a decentralized lottery system on the Aptos blockchain using the Move programming language. The smart contract allows users to participate in a lottery by buying tickets with AptosCoin, and uses on-chain randomness to select a winner.
- Ticket Purchase: Users can buy lottery tickets using AptosCoin.
- Random Winner Selection and Payout: Utilizes Aptos' on-chain randomness module for fair winner selection and pays out the prize to the winner in same transaction.
- View Functions: Provides functions to check lottery status, prize amount, and participant count.
This project demonstrates several key concepts learned from the Move bootcamp:
- Struct and Resource Management: Using
struct Lottery has keyto create a resource that can only exist in one place in global storage. - Access Control: Implementing
public entryandpublic(friend)functions to control who can call certain functions. - On-Chain Randomness: Utilizing the
#[randomness]attribute andrandomness::u64_range()for secure random number generation. - Coin Handling: Managing AptosCoin transfers using the
coinmodule. - Error Handling: Defining and using custom error codes for better error management.
- View Functions: Implementing
#[view]functions for easy data retrieval without modifying state. - Timestamp Usage: Using
timestamp::now_seconds()for time-based operations.
This project showcases the power and flexibility of Move in creating complex, secure, and efficient smart contracts on the Aptos blockchain.