
EpicDice is a decentralized dice game built on top of Steem blockchain which aims to provide a refined gambling experience while keeping simplicity intact.
https://epicdice.io/
How to pick the winners?
In the first week of EpicDice's opening, we received tremendous support and hit at least over 8000 transactions in the game, and over 100 resteems of the last post. However, only 93 of them are valids and here is how we going to pick the winners randomly with a simple script.
We aim to write a program that is as provably-fair as possible, just like our dice game. And here is briefly how it works:
- Extract out all resteemers of the post.
- Filter out resteemers with less than 200 followers.
- Each of the potential resteemer will add into array with indexed from 0 - n , subsequently convert the array to string value.
- Apply SHA256 Cryptographic to the string array for hash generation.
- First 5 character of hex value will convert into decimal value for first prize winner. Subsequent 5 character for second prize winner and so does for the 3rd prize.
- The decimal value will normalise from range 1 - 1000. This value will use to calculate remainder base on total number of resteemer. The remainder will be used as index to the initial list of resteemer to select winner of the contest.
In short, the result of this script will always be the same no matter how many time it runs. Below is the code snippet.
from steem import Steem
import random
import hashlib
import base64
import calendar
import time
from datetime import datetime, timezone
#create steem instance
s = Steem()
d = datetime.utcnow()
unixtime = calendar.timegm(d.utctimetuple())
def getDateTime():
utc_dt = datetime.now(timezone.utc) # UTC time
dt = utc_dt.astimezone() # local time
return str(dt)
user = 'epicdice'
postLink = 'epicdice-a-highly-rewarding-dice-game-on-steem'
reblogs = s.get_reblogged_by(user, postLink)
potentialWinnerList = []
counter = 0
for potentialWinner in reblogs:
if s.get_follow_count(potentialWinner)['follower_count'] >= 200 :
potentialWinnerList.append(potentialWinner)
counter = counter + 1
if not potentialWinnerList:
print("No winners :( The list is empty")
else:
hashValue = hashlib.sha256(str(potentialWinnerList).encode('utf-8')).hexdigest()
first = hashValue[0:4]
second = hashValue[5:9]
third = hashValue[10:14]
result1 = int(first, 16)
result2 = int(second, 16)
result3 = int(third, 16)
finalResult1 = result1 % (10000)/10
finalResult1 = int(round(finalResult1))
finalResult2 = result2 % (10000)/10
finalResult2 = int(round(finalResult2))
finalResult3 = result3 % (10000)/10
finalResult3 = int(round(finalResult3))
print("*********************************************************************************************************")
print("potentialWinnerList : " + str(potentialWinnerList))
print("hashValue : " + hashValue)
print("Total Resteem : " + str(counter))
print("First Prize Winner : " + potentialWinnerList[finalResult1 % counter])
print("Second Prize Winner : " + potentialWinnerList[finalResult2 % counter])
print("Third Prize Winner : " + potentialWinnerList[finalResult3 % counter])
print("Unix time : " + str(unixtime))
print("UTC Date : " + getDateTime())
print("program Ended *****")
Here is the winners!
Below are the result generated from the script above.
potentialWinnerList : ['abitcoinskeptic', 'afknchill', 'akshaykumar12257', 'alauddinsee', 'allyouneedtoknow', 'andrea97', 'aniestudio', 'ansoe', 'arkhan', 'austinbiswas', 'badchistes', 'bait002', 'bayeco06', 'beat-the-bookies', 'beco132', 'beggars', 'benedict08', 'bigpanda', 'boddhisattva', 'bonp', 'cgbartow', 'chetanpadliya', 'chisteland', 'crypticat', 'crypto-wisdom', 'cryptoknight12', 'dab.panda', 'deanliu', 'deusjudo', 'direwolf', 'eii', 'ervin-lemark', 'fastadapted', 'foodforcomfort', 'fr3eze', 'fredkese', 'freebirdkhushboo', 'gabbynhice', 'gasaeightyfive', 'glastar', 'gocuriousmind', 'guanipa75', 'guurry123', 'haji', 'hesperiah', 'honoru', 'iamnotageek', 'imransoory', 'ionlysaygroot', 'ivan-perez-anies', 'joancabz', 'kingfunny', 'landscapes.photo', 'laqsking', 'libert', 'littymumma', 'liuke96player', 'lordbutterfly', 'mehta', 'mermaidvampire', 'milaan', 'mister-meeseeks', 'mk992039', 'moneyminded', 'montgomeryburns', 'natha93', 'nico-dounavis', 'oivas', 'olusolaemmanuel', 'onefatindian', 'onlysayexcellent', 'otom', 'regenin', 'rezoanulvibes', 'riseofth', 'rjoshicool', 'ronel', 'sciack', 'sheikhsayem', 'shitsignals', 'shivohum2015', 'skylinebuds', 'steemcollator', 'sthitaprajna', 'stupid', 'summisimeon', 'sunit', 'sweetkathy', 'travoved', 'vedicsamurai', 'veganomics', 'xyzashu', 'zeeshanrafique']
hashValue : 394e024e81bae0c2a3e0c001f6d2ba6e9025c328b81c36b0628e75ff8fbbbbc4
Total Resteem : 93
First Prize Winner : akshaykumar12257
Second Prize Winner : beggars
Third Prize Winner : gocuriousmind
Unix time : 1552837625
UTC Date : 2019-03-17 23:47:39.619763+08:00
Congratulations to the winners, namely
- @akshaykumar12257, 50 STEEM
- @beggars, 30 STEEM
- @gocuriousmind, 20 STEEM
The prizes will be sent out shortly, we appreciate the support very much.

