trueluck Smart Contract Basic Functions.
About trueluck functions.
The TrueLuck smart contract powers all raffle and lottery rooms deployed on Polygon PoS. It handles ticket purchases, room management, winner selection, and automated payouts in a fully on-chain and transparent way.
ποΈ Ticketing
buyTicket() β Allows users to purchase raffle tickets (directly in USDT if on Polygon, or via Stargate if cross-chain).
Validates payment and mints an entry into the raffle room.
Tracks buyer address and number of tickets.
π Room Management
createRoom() β Factory function to spawn new raffle rooms with rules (ticket cap, ticket price, duration).
fillRoom() β Tracks when a room reaches its capacity (all tickets sold).
closeRoom() β Finalizes the room once the winner is determined and payout is done.
π² Randomness
requestRandomness() β Calls Chainlink VRF once the room is full.
fulfillRandomness() β Receives the random number from Chainlink and stores it securely on-chain.
π Winner & Payout
selectWinner() β Uses the VRF random number to select a winning ticket.
payoutWinner() β Sends USDT on Polygon to the winnerβs wallet automatically.
π Safety / Extras
refundTickets() β Handles refunds if a room fails to fill or a transaction error occurs.
getRoomStatus() β Public view function to check status (open, filled, winner decided, closed).
getPlayerEntries() β Shows how many tickets a player owns in a given room.
β Everything is transparent, automated, and on-chain.
No manual intervention, no centralized controlβjust fair raffles powered by Polygon, Stargate, and Chainlink VRF.
Last updated