Bitcoin Forum

Economy => Gambling => Topic started by: xyu on September 09, 2013, 12:14:14 PM



Title: ▶Nolimits-Lottery.com - Provably fair, DAILY WEEKLY MONHLY draws. NO price limit
Post by: xyu on September 09, 2013, 12:14:14 PM
Nolimits-Lottery.com (http://nolimits-lottery.com/)
testnet: testnet.nolimits-lottery.com (http://testnet.nolimits-lottery.com/)
https://i.imgur.com/e0GFImt.png (http://nolimits-lottery.com/)

Hi guys, I'd like to introduce a site I've been working on: Nolimits-Lottery.com (http://nolimits-lottery.com/)

Features
  • no registration
  • no tickets
  • no price limit
  • instant results (kind of)
  • the more you send the higher your chances
  • 5 winners
  • daily, weekly, monthly draws
  • 2 confirmations
  • provably fair

Description
So, basically this is a lottery with unusual properties: it's completely anonymous, no registration required, it doesn't have tickets or number guessing, there is no limit to the amount of bitcoin you can send in the each draw and chances to win are proportional to the amount you've sent. So for example if the draw pool is currently 75 BTC and you've just sent 25 BTC, totalling the pool at 100 BTC, your chances to win will be 25%

Winners
There're 5 winners in each draw: 1st place winner takes 50% of the pool, second - 25%, third - 12.5%, forth - 6.75%, fifth - 3.125%, remaining amount is the house edge.

Draws
Currently there is DAILY, WEEKLY and MONTHLY draws, their names are self explanatory I think.

Provably fair
It is provably fair of course. We use a combination of server side seed and transactions hashes: a server side seed and is pregenerated for each draw and its hash published while the draw is active and when the draw ends we publish the original seed. We concatenate it with transaction hashes to generate an unpredictable number that is used to determine lottery winners, you can read more at the Fairness page (http://nolimits-lottery.com/fairness)
And we also have a python script that implements the algorithm and verifies results, you can inspect and run it, just give the draw id: python verify.py 25
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function

import json
import requests
import sys

from hashlib import sha256

def make_draw(amounts, hash):
    hash_num = int(hash, 16)
    total = sum(amounts)
    total_bits = len(bin(total)) - 2
    rand_num = int(bin(hash_num)[-total_bits:], 2)
    offset = 0
    while rand_num > total:
        offset += 1
        rand_num ^= int(bin(hash_num)[-total_bits-offset:-offset], 2)

    i = lottery(amounts, rand_num)
    return i

def lottery(elements, rand):
    value = 0
    for i,el in enumerate(elements):
        value += el
        if rand <= value:
            return i

def prettify(dictionary):
    return json.dumps(dictionary, indent=4, sort_keys=True)

URL = 'http://nolimits-lottery.com/api/draw/' + sys.argv[1]

draw = requests.get(URL).json()

#print "DRAW: ", prettify(draw)

participations = sorted(draw['participations'], key=lambda p:p['amount'], reverse=True)
amounts = map(lambda p:p['amount'], participations)
combined_hash = sha256(reduce(lambda acc, p: acc + p['txid'], participations, draw['seed'])).hexdigest()

total = sum(amounts)
reward = total/2
fee = total * 0.03125
i=0
results = []
while reward >= fee:
    if not participations:
        if results: results[-1]['amount']+=total-fee
        break
    winner = make_draw(amounts, combined_hash)
    result = dict(
        participation_id=participations[winner]['id'],
        place=i+1,
        amount=reward
    )
    results.append(result)
    winning_participation = participations.pop(winner)
    amounts = map(lambda p:p['amount'], participations)
    total = reward
    reward = total/2
    combined_hash = sha256(combined_hash + winning_participation['txid']).hexdigest()
    i+=1

#print "RESULTS: ", prettify(results)

real_winners = sorted(draw['winners'], key=lambda p:p['place'], reverse=True)
expected_winners = sorted(results, key=lambda p:p['place'], reverse=True)

for i, winner in enumerate(real_winners):
    if not expected_winners[i]['participation_id'] == winner['participation_id']:
        print("VERIFICATION FAILED")
        exit(1)

print("RESULT VERIFIED")

Testnet
And you can test it out safely for free using testnet version http://testnet.nolimits-lottery.com/ just use some testnet faucet like http://testnet.mojocoin.com/ to get  free testnet bitcoins

Any feedback and suggestions are appreciated and welcomed.
Good luck to all.


Title: Re: Nolimits-Lottery.com - Provably fair, DAILY WEEKLY MONHLY draws. NO FIXED price
Post by: xyu on September 09, 2013, 02:10:58 PM
CHANGELOG:
  2013-09-10:
     Added instant results, you can see who is going to win the draw like if the draw would end right now.
  2013-09-09:
     If the current draw haven't received more than 5 participations before it have been closed, all participations of the current draw are moved to the next one.


Title: Re: ▶Nolimits-Lottery.com - Provably fair, DAILY WEEKLY MONHLY draws. NO price limit
Post by: xyu on September 10, 2013, 05:35:42 PM
I've added very interesting feature (as I think) - instant preview of the draw results - because server knows the secret it can simulate the draw like if it would stop right now and get results, so if you transaction is got confirmed, server will perform the computation and return results, so you can instantly see who will win if there would be no more transaction in this draw, and if there will be more transaction the results will be regenerated again and of course they will be completely different.

This can bring a very different feeling to the lottery, for example if you've made a large transaction and you have high odds to win, but currently there are other transactions winning, you can send a very small transaction just to "shuffle" the results.


Title: Re: ▶Nolimits-Lottery.com - Provably fair, DAILY WEEKLY MONHLY draws. NO price limit
Post by: jefe541 on October 12, 2013, 01:16:28 PM
what time of day is the daily draw held?