Contract con_dice001
Creator | ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d |
Creation Hash | 1823c53e7506ce52bf5b4206462cb7aa27fe10ef64e974ed6fe8d114d4250e36 |
Created On | 906 days ago - 4/5/2021, 8:16:33 PM UTC+0 |
Contract Code
1
import currency
2
random.seed()
3
__owner = Variable(contract='con_dice001', name='owner')
4
__min_amount = Variable(contract='con_dice001', name='min_amount')
5
__max_amount = Variable(contract='con_dice001', name='max_amount')
6
__multiplier = Variable(contract='con_dice001', name='multiplier')
7
8
9
def ____():
10
__owner.set(ctx.caller)
11
__min_amount.set(10)
12
__max_amount.set(50)
13
__multiplier.set(5)
14
15
16
@__export('con_dice001')
17
def roll(guess: int, amount: float):
18
error = 'Not a valid dice number'
19
assert guess >= 1 and guess <= 6, error
20
error = 'Min bet amount is ' + str(__min_amount.get())
21
assert amount >= __min_amount.get(), error
22
error = 'Max bet amount is ' + str(__max_amount.get())
23
assert amount <= __max_amount.get(), error
24
balance = currency.balance_of(account=ctx.this)
25
error = 'Contract balance too low to pay for possible win'
26
assert balance >= amount * __multiplier.get(), error
27
currency.transfer_from(amount=amount, to=ctx.this, main_account=ctx.caller)
28
result = random.randint(1, 6)
29
if result == guess:
30
currency.transfer(amount=amount * __multiplier.get(), to=ctx.caller)
31
return result
32
33
34
@__export('con_dice001')
35
def pay_in(amount: float):
36
currency.transfer_from(amount=amount, to=ctx.this, main_account=ctx.caller)
37
38
39
@__export('con_dice001')
40
def pay_out(amount: float):
41
error = 'Only the owner can request a payout'
42
assert __owner.get() == ctx.caller, error
43
currency.transfer(amount=amount, to=ctx.caller)
44
45
46
@__export('con_dice001')
47
def adjust_min(amount: int):
48
error = 'Only the owner can adjust the min amount'
49
assert __owner.get() == ctx.caller, error
50
__min_amount.set(amount)
51
52
53
@__export('con_dice001')
54
def adjust_max(amount: int):
55
error = 'Only the owner can adjust the max amount'
56
assert __owner.get() == ctx.caller, error
57
__max_amount.set(amount)
58
Byte Code
e3000000000000000000000000040000004000000073bc000000640064016c005a0065016a028300010065036402640364048d025a0465036402640564048d025a0565036402640664048d025a0665036402640764048d025a076408640984005a08650964028301650a650b640a9c02640b640c840483015a0c650964028301650b640d9c01640e640f840483015a0d650964028301650b640d9c0164106411840483015a0e650964028301650a640d9c0164126413840483015a0f650964028301650a640d9c0164146415840483015a10640153002916e9000000004eda0b636f6e5f64696365303031da056f776e65722902da08636f6e7472616374da046e616d65da0a6d696e5f616d6f756e74da0a6d61785f616d6f756e74da0a6d756c7469706c696572630000000000000000000000000200000043000000732e00000074006a0174026a038301010074046a0164018301010074056a0164028301010074066a016403830101006400530029044ee90a000000e932000000e9050000002907da075f5f6f776e6572da03736574da03637478da0663616c6c6572da0c5f5f6d696e5f616d6f756e74da0c5f5f6d61785f616d6f756e74da0c5f5f6d756c7469706c696572a90072130000007213000000da00da045f5f5f5f09000000730800000000010c010a010a0172150000002902da056775657373da06616d6f756e7463020000000000000005000000050000004300000073d200000064017d027c0064026b0572147c0064036b01731c74007c02830182016404740174026a038300830117007d027c0174026a0383006b05734074007c02830182016405740174046a038300830117007d027c0174046a0383006b01736474007c028301820174056a0674076a0864068d017d0364077d027c037c0174096a03830014006b05738e74007c028301820174056a0a7c0174076a0874076a0b64088d030100740c6a0d6402640383027d047c047c006b0272ce74056a0e7c0174096a038300140074076a0b64098d0201007c045300290a4e7a174e6f7420612076616c69642064696365206e756d626572e901000000e9060000007a124d696e2062657420616d6f756e74206973207a124d61782062657420616d6f756e74206973202901da076163636f756e747a30436f6e74726163742062616c616e636520746f6f206c6f7720746f2070617920666f7220706f737369626c652077696e29037217000000da02746fda0c6d61696e5f6163636f756e7429027217000000721b000000290fda0e417373657274696f6e4572726f72da037374727210000000da036765747211000000da0863757272656e6379da0a62616c616e63655f6f66720e000000da04746869737212000000da0d7472616e736665725f66726f6d720f000000da0672616e646f6dda0772616e64696e74da087472616e73666572290572160000007217000000da056572726f72da0762616c616e6365da06726573756c74721300000072130000007214000000da04726f6c6c10000000731c00000000020401180110011401100114010e010401180114010c0108011801722a00000029017217000000630100000000000000010000000500000043000000731800000074006a017c0074026a0374026a0464018d0301006400530029024e29037217000000721b000000721c000000290572200000007223000000720e0000007222000000720f00000029017217000000721300000072130000007214000000da067061795f696e2200000073020000000002722b000000630100000000000000020000000400000043000000732e00000064017d0174006a01830074026a036b02731a74047c018301820174056a067c0074026a0364028d0201006400530029034e7a234f6e6c7920746865206f776e65722063616e20726571756573742061207061796f757429027217000000721b0000002907720c000000721f000000720e000000720f000000721d00000072200000007226000000290272170000007227000000721300000072130000007214000000da077061795f6f7574270000007306000000000204011601722c000000630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a284f6e6c7920746865206f776e65722063616e2061646a75737420746865206d696e20616d6f756e742907720c000000721f000000720e000000720f000000721d0000007210000000720d000000290272170000007227000000721300000072130000007214000000da0a61646a7573745f6d696e2e0000007306000000000204011601722d000000630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a284f6e6c7920746865206f776e65722063616e2061646a75737420746865206d617820616d6f756e742907720c000000721f000000720e000000720f000000721d0000007211000000720d000000290272170000007227000000721300000072130000007214000000da0a61646a7573745f6d6178350000007306000000000204011601722e000000291172200000007224000000da0473656564da085661726961626c65720c0000007210000000721100000072120000007215000000da085f5f6578706f7274da03696e74da05666c6f6174722a000000722b000000722c000000722d000000722e0000007213000000721300000072130000007214000000da083c6d6f64756c653e010000007320000000080108010c010c010c010c030807060112110601100406011006060110060601