Contract con_mob_dice002


Contract Code


  
1 import con_mintorburn as mob
2
3 random.seed()
4
5 owner = Variable()
6
7 min_amount = Variable()
8 max_amount = Variable()
9 multiplier = Variable()
10
11 @construct
12 def seed():
13 owner.set('ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89')
14 min_amount.set(50_000)
15 max_amount.set(1_000_000)
16 multiplier.set(5)
17
18 @export
19 def roll(guess: int, amount: float):
20 error = 'Not a valid dice number'
21 assert guess >= 1 and guess <= 6, error
22 error = 'Min bet amount is ' + str(min_amount.get()) + ' MOB'
23 assert amount >= min_amount.get(), error
24 error = 'Max bet amount is ' + str(max_amount.get()) + ' MOB'
25 assert amount <= max_amount.get(), error
26
27 balance = mob.balance_of(address=ctx.this)
28
29 error = 'MOB balance of contract too low to pay for possible win'
30 assert balance >= amount * multiplier.get(), error
31
32 mob.transfer_from(amount=amount, to=ctx.this, main_account=ctx.caller)
33
34 result = random.randint(1, 6)
35
36 if result == guess:
37 mob.transfer(amount=amount * multiplier.get(), to=ctx.caller)
38
39 return result
40
41 @export
42 def pay_in(amount: float):
43 mob.transfer_from(amount=amount, to=ctx.this, main_account=ctx.caller)
44
45 @export
46 def pay_out(amount: float):
47 error = 'Only the owner can request a payout'
48 assert owner.get() == ctx.caller, error
49 mob.transfer(amount=amount, to=ctx.caller)
50
51 @export
52 def set_min(amount: int):
53 error = 'Only the owner can adjust the min amount'
54 assert owner.get() == ctx.caller, error
55 min_amount.set(amount)
56
57 @export
58 def set_max(amount: int):
59 error = 'Only the owner can adjust the max amount'
60 assert owner.get() == ctx.caller, error
61 max_amount.set(amount)
62

Byte Code

e3000000000000000000000000040000004000000073bc000000640064016c005a0165026a038300010065046402640364048d025a0565046402640564048d025a0665046402640664048d025a0765046402640764048d025a086408640984005a09650a64028301650b650c640a9c02640b640c840483015a0d650a64028301650c640d9c01640e640f840483015a0e650a64028301650c640d9c0164106411840483015a0f650a64028301650b640d9c0164126413840483015a10650a64028301650b640d9c0164146415840483015a11640153002916e9000000004eda0f636f6e5f6d6f625f64696365303032da056f776e65722902da08636f6e7472616374da046e616d65da0a6d696e5f616d6f756e74da0a6d61785f616d6f756e74da0a6d756c7469706c696572630000000000000000000000000200000043000000732c00000074006a0164018301010074026a0164028301010074036a0164038301010074046a016404830101006400530029054eda40666636313534346561393465616165623564663038656438363363346139333865393132396162613663656565356633316236363831626465646531316238396950c300006940420f00e9050000002905da075f5f6f776e6572da03736574da0c5f5f6d696e5f616d6f756e74da0c5f5f6d61785f616d6f756e74da0c5f5f6d756c7469706c696572a90072100000007210000000da00da045f5f5f5f09000000730a0000000001040106010a010a0172120000002902da056775657373da06616d6f756e7463020000000000000005000000050000004300000073da00000064017d027c0064026b0572147c0064036b01731c74007c02830182016404740174026a03830083011700640517007d027c0174026a0383006b05734474007c02830182016406740174046a03830083011700640517007d027c0174046a0383006b01736c74007c028301820174056a0674076a0864078d017d0364087d027c037c0174096a03830014006b05739674007c028301820174056a0a7c0174076a0874076a0b64098d030100740c6a0d6402640383027d047c047c006b0272d674056a0e7c0174096a038300140074076a0b640a8d0201007c045300290b4e7a174e6f7420612076616c69642064696365206e756d626572e901000000e9060000007a124d696e2062657420616d6f756e74206973207a04204d4f427a124d61782062657420616d6f756e74206973202901da07616464726573737a374d4f422062616c616e6365206f6620636f6e747261637420746f6f206c6f7720746f2070617920666f7220706f737369626c652077696e29037214000000da02746fda0c6d61696e5f6163636f756e74290272140000007218000000290fda0e417373657274696f6e4572726f72da03737472720d000000da03676574720e000000da036d6f62da0a62616c616e63655f6f66da03637478da0474686973720f000000da0d7472616e736665725f66726f6dda0663616c6c6572da0672616e646f6dda0772616e64696e74da087472616e73666572290572130000007214000000da056572726f72da0762616c616e6365da06726573756c74721000000072100000007211000000da04726f6c6c11000000731c00000000020401180114011401140114010e010401180114010c0108011801722900000029017214000000630100000000000000010000000500000043000000731800000074006a017c0074026a0374026a0464018d0301006400530029024e29037214000000721800000072190000002905721d0000007221000000721f0000007220000000722200000029017214000000721000000072100000007211000000da067061795f696e2300000073020000000002722a000000630100000000000000020000000400000043000000732e00000064017d0174006a01830074026a036b02731a74047c018301820174056a067c0074026a0364028d0201006400530029034e7a234f6e6c7920746865206f776e65722063616e20726571756573742061207061796f75742902721400000072180000002907720b000000721c000000721f0000007222000000721a000000721d0000007225000000290272140000007226000000721000000072100000007211000000da077061795f6f7574280000007306000000000204011601722b000000630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a284f6e6c7920746865206f776e65722063616e2061646a75737420746865206d696e20616d6f756e742907720b000000721c000000721f0000007222000000721a000000720d000000720c000000290272140000007226000000721000000072100000007211000000da077365745f6d696e2f0000007306000000000204011601722c000000630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a284f6e6c7920746865206f776e65722063616e2061646a75737420746865206d617820616d6f756e742907720b000000721c000000721f0000007222000000721a000000720e000000720c000000290272140000007226000000721000000072100000007211000000da077365745f6d6178360000007306000000000204011601722d0000002912da0e636f6e5f6d696e746f726275726e721d0000007223000000da0473656564da085661726961626c65720b000000720d000000720e000000720f0000007212000000da085f5f6578706f7274da03696e74da05666c6f61747229000000722a000000722b000000722c000000722d0000007210000000721000000072100000007211000000da083c6d6f64756c653e010000007320000000080108010c010c010c010c030808060112110601100406011006060110060601