TON smart contract lottery 3 of 13

alfacoder

Member
Сообщения
50
Реакции
9
Smart contract lottery 3 of 13 for Telegram Open Network


Lottery rules:
  • participants choose 3 arbitrary unique numbers 0-99 and "buys" a ticket
  • prize fund of current round is a sum of all "sold" tickets in this round, plus "unused" fund from previos round, minus round commision
  • sponsors can increase current round prize fund by any amount of GR$
  • owner of lottery smc conducts a lottery round (say once per day):
    • generate 13 unique random numbers 0-99
    • find winners and their prize among participants:
      • guess all 3 numbers - 60% of prize fund / winners
      • guess 2 numbers - 22% of prize fund / winners
      • guess 1 number - 15% of prize fund / winners
    • charge smc commision - 3% of prize fund
    • "fills" previous round, "zeros" current round
  • results of previous round can be fetched with lucky_nums, winners and is_winner methods
  • winners of previous round can withdraw their prizes
  • owner of lottery smc can withdraw only commision, not the entire smc balance
Current limitations:
  • participant's accounts must reside in basechain (wc = 0)
  • participant can buy only 1 ticker per round
  • withdraw of previous round prizes needs to be done during the current ongoing round
As an owner of lottery smc you can:
  • create smart-contract with lottery-new.fif
  • conduct a lottery round with lottery-conduct.fif
  • withdraw commison with lottery-withdraw.fif
As an participant of lottery you can:
  • buy a ticket with 3 numbers 0-99 for 1 Gram by sending transfer from your wallet account with message payload generated by lotto-buy.fif, or by sending your numbers in comment of simple transfer message
  • sponsor current lottery round with some Grams by sendidng transfer from your wallet account with message payload generated by lotto-sponsor.fif
  • withdraw your prize by sending "get"-transfer from your wallet account with message payload generated by lotto-withdraw.fif
Github: https://github.com/alunegov/ton-contest-2
 
Сверху