
EpicDice is a decentralized gaming platform built on top of Steem blockchain with absolute transparency and fairness. Join the most epic fun today!
https://epicdice.io/
EpicDice is Open Source now
In accordance with EpicDice's manifesto to be the most transparent and fair casino, we've decided to open-source the core code of our business, dice game. So it's clear how every bet is being handled every step of the way. Many platforms promise a fair game but don't open up their code for peer-review. We can understand that sharing vital code this way would potentially create uninvited rivals, but we believe more that open-sourcing could uplift the platform in a compelling way.
While trust in a closed system can be convenient at times, nothing is more trustable than mathematical certainty and utter transparency.
GitHub repository: https://github.com/casinosteem/EpicDice
Brief explanation of the code
Block was read based on block number and always trying to catch the latest block.
try:
blockchain = Blockchain()
print('Block : ' + str(getblock))
except:
print("Latest Block")
try:
block = Block(getblock)
except:
block = None
printX('###########################')
printX('#### End of Block #########')
printX('###########################')
Iterating each transaction on every block to check any transaction is send to @epicdice, then storing all crucial value into global variable which later will be stored into local database for processing.
for i, txs in enumerate(block.transactions):
for (j, tx) in enumerate(txs['operations']):
if tx['type'] == 'transfer_operation' and tx['value']['to'] in [watching]:
if tx != None:
transId = txs['transaction_id']
precision = str(tx['value']['amount']['precision'])
nai = tx['value']['amount']['nai']
fromWho = tx['value']['from']
toWho = tx['value']['to']
amount = tx['value']['amount']['amount']
ref_block_num = txs['ref_block_num']
transaction_num = txs['transaction_num']
block_num = txs['block_num']
memo = tx['value']['memo']
transType = tx['type']
Calculation of the possible winning payout and go through a series of validation checking.
win = (float(finalAmount) * 100/factor) * ( 1 - houseEdge)
win = float_round(win, 3, round)
Most crucial part of entire program, it calculates result of bet based on transactionID , this code is same as Javascript found on the website Fairness tab
while result > 999999:
try:
chop = txid[offset:endValue]
offset += 5
endValue = offset + length
result = int(chop, 16)
printX('chop ' + chop)
printX('txid ' + txid)
printX('result ' + str(result))
try:
tempResult = result % (10000)/100
printX('Below Rounding Result : ' + str(tempResult))
tempResult = int(round(tempResult))
printX('After Rounding Result : ' + str(tempResult))
if tempResult == 0:
printX('tempResult is zero .. trying next 5 char ')
result = 1000000
except Exception as e:
print('error '+ str(e))
except:
result = -1
Determining winning or losing bet of "Above" or "Under"
won = 0
factor = 0
if result > -1:
result = tempResult
processed = True
try:
details = memo
prediction = ""
details = str(details).lower()
rate = 0
betType = 0
if 'over' in details:
indexOfSpace = memo.index(" ")
rate = int(memo[indexOfSpace:indexOfSpace + 3])
prediction = memo[:5+3]
betType = 1
factor = 100 - rate
if result > rate:
won = 1
elif 'above' in details:
indexOfSpace = memo.index(" ")
rate = int(memo[indexOfSpace:indexOfSpace+ 3])
prediction = memo[:6+3]
betType = 1
factor = 100 - rate
if result > rate:
won = 1
elif 'below' in details or 'under' in details:
indexOfSpace = memo.index(" ")
rate = int(memo[indexOfSpace:indexOfSpace + 3])
prediction = memo[:6+3]
betType = 2
factor = 0 + rate - 1
if result < rate:
won = 1
else:
factor = 0
except:
factor = 0
Payout of winning bet and the generation of memo
if won == 1 and factor > 0:
processed = False
payout = (float(amount) * 100/factor) * (1 - houseEdgeParam)
payout = float_round(payout, 3, round)
try:
transactionJSON = {}
transactionJSON["diceRolled"] = str(result)
transactionJSON["TransactionId"] = txid
transactionJSON["BlockNumber"] = str(block)
transactionJSON["isValid"] = True
clientTransfer(watching, user, str(payout) + " " + asset, 'You have Won! Dice Rolled: ' + str(result) + ". Your Prediction: " + prediction + ". Multiplier: " + str(multiplier) + ". Win Chance: " + str(factor)+ "%" + '\n' + json.dumps(transactionJSON))
print('>>>>>>>>>> ' + user + ', You Won! . Dice Roll : ' + str(result) + " Your Prediction: " + prediction + ". Multiplier: " + str(multiplier) + ". Win Chance: " + str(factor)+ "%" + '\n' + json.dumps(transactionJSON) + " amount " + str(amount) + " currency " + asset)
except Exception as e:
print('ERROR SENDING MONEY ' + str(e))
Notification of losing bet processing.
elif won == 0:
payout = 0.001
try:
transactionJSON = {}
transactionJSON["diceRolled"] = str(result)
transactionJSON["TransactionId"] = txid
transactionJSON["BlockNumber"] = str(block)
transactionJSON["isValid"] = True
clientTransfer(watching, user, str(payout) + " " + asset, 'You Lost. Dice Rolled: ' + str(result) + ". Your Prediction: " + prediction + ". Multiplier: " + str(multiplier) + ". Win Chance: " + str(factor)+ "%" + '\n' + json.dumps(transactionJSON))
print('>>>>>>>>>> ' + user + ', You Lost. Dice Roll : ' + str(result) + " Your Prediction: " + prediction + ". Multiplier: " + str(multiplier) + ". Win Chance: " + str(factor)+ "%" + '\n' + json.dumps(transactionJSON) + " amount " + str(amount) + " currency " + asset)
except Exception as e:
print('ERROR SENDING MONEY 2 ' + str(e))
Development updates
Interesting treats are being prepared in the kitchen now! As one may already learn from the post of our mod @hitmeasap, EPC Airdrop is definitely the next big thing we are cooking right now together with mobile support development. We don't have much detail to expose about the Airdrop until the backend system is ready and testing is done. The team is always working towards a better service both in higher technical and branding level. Be sure to stay tuned by following the official account @epicdice or joining our discord channel for direct communication with us.
Keep up that epicness!
Earn EPC via delegation
EPC is the only token to earn from the daily dividend and prize pool in STEEM. Every 1 SP delegation earns 2 EPC daily. It takes one day for the delegation to be effective in order to receive the dividend from the moment of delegation.
100 SP | 500 SP | 1000 SP | 5000 SP | 10000 SP
