How it works
We made safe lottery-like game.
Winner picking procedure
When all tickets in lottery are sold procedure of generation of random integer number starts, which then would be used to determine the winning-ticket number.
Contract's random number generation mechanism is fully decentralized as uses only ethereum blockchain. It uses hashes of the next 32 blocks to generate a random 32bit integer number, which makes it impossible to influence the result of the lottery by individual miners or contract itself.
After random number were being generated contract pick a winner-ticket by using modulo operation:
winnerTicketNumber = randomNumber % numberOfTickets
so contract could get a winner within lottery players.
When contract have the winner-ticket number a prize send to the owner of that ticket and new lottery starts. It's that simple.
You can check verified smartcontract code on etherscan.io
Separate ethereum address can hold up to 49% of tickets in each room
You can't buy already bought ticket (marked with gray color on play ground), if you try - your transaction would fail.
If you and someone else tries to buy the same ticket at the same time, only one of players gets a ticket (depends on decision of miner) another player gets failed tx and his money back (its a restriction of ethereum blockchain)
Contract introduce 1% referral system. You can get 1% of total jackpot your referral won. Referrals are common for all playing rooms and are assigned once forever. So if you bought a ticket using friends referral link you would be always a referral for that friend from that time.
Each room has its lifetime to sold all tickets before refund can be requested. Imagine we have a room of 100 tickets with lifetime of 1 month. You bought 10 tickets there, but after 1 month there's still tickets to buy. Anyone who bought a ticket in that room could request a refund and get full cost of bought tickets back, in case the lifetime of that room has passed. So you can't lock your ethers forever in a contract.
- Contract holds 20% of a jackpot to itself which would be used for development of new features, paying tx fees, marketing.
- Winner gets 80% of a total jackpot.
- Referral gets 1% of a total jackpot which is payed from Contract share.
send method to send prizes, referral payments and refunds, thus do not buy tickets from contracts that have fallback function with requirement of more than 2300 gas. If you used such contract and won the jackpot, requested refund or get a referral payment you're probably wont get the ethers because of
send operation fail.
If you're not sure of what you are doing - dont play this game