Contract con_smack_that_6


Contract Code

1 import currency
2 settings = Hash(default_value=0, contract='con_smack_that_6', name='settings'
3 )
4 random.seed()
5
6
7 def ():
8 settings['pot_max'] = 20000
9 settings['min_bet'] = 3
10 settings['refund_per'] = decimal('0.01')
11 settings['refund_div'] = 10
12 settings['dev_contract'] = 'con_smackeroos_3'
13 settings['operator'] = ctx.caller
14 settings['list'] = ['pot_max', 'refund_per', 'refund_div',
15 'dev_contract', 'operator', 'min_bet']
16
17
18 @export('con_smack_that_6')
19 def smack(bet_amount: int):
20 assert bet_amount >= settings['min_bet'
21 ], 'bet must be greater than or equal to ' + str(settings['min_bet'])
22 bet = determine_cost(bet_amount)
23 currency.transfer_from(amount=bet, to=ctx.this, main_account=ctx.caller)
24 x = random.randint(0, 10)
25 if x >= 6:
26 win_amount = bet * 2
27 currency.transfer(amount=win_amount, to=ctx.caller)
28 return {'bet': bet, 'won': win_amount, 'status': 1}
29 else:
30 give_dev_token()
31 check_overflow()
32 return {'bet': bet, 'status': 0}
33
34
35 def determine_cost(bet_amount: int):
36 max_bet = int(currency.balance_of(ctx.this) * decimal('0.08') // 1)
37 if bet_amount < max_bet:
38 return bet_amount
39 else:
40 return max_bet
41
42
43 def give_dev_token():
44 dev_contract = importlib.import_module(settings['dev_contract'])
45 refund = dev_contract.balance_of(ctx.this) * (settings['refund_per'] /
46 settings['refund_div'])
47 dev_contract.transfer(refund, ctx.caller)
48
49
50 def check_overflow():
51 overflow = currency.balance_of(ctx.this) - settings['pot_max']
52 if overflow > 0:
53 currency.transfer(amount=overflow, to=settings['dev_contract'])
54
55
56 @export('con_smack_that_6')
57 def change_settings(setting: str, new_value: Any):
58 assert_operator()
59 assert setting in settings['list'
60 ], setting + ' is not a configurable setting.'
61 settings[setting] = new_value
62
63
64 @export('con_smack_that_6')
65 def transfer(amount: float, to: str):
66 assert_operator()
67 currency.transfer(amount=amount, to=to)
68
69
70 @export('con_smack_that_6')
71 def transfer_dev_token(amount: float, to: str):
72 assert_operator()
73 dev_contract = importlib.import_module(settings['dev_contract'])
74 dev_contract.transfer(amount=amount, to=to)
75
76
77 def assert_operator():
78 assert ctx.caller == settings['operator'
79 ], 'Only operator can call this method.'
80

Byte Code

e3000000000000000000000000050000004000000073ae000000640064016c005a00650164006402640364048d035a0265036a04830001006405640684005a05650664028301650764079c0164086409840483015a08650764079c01640a640b84045a09640c640d84005a0a640e640f84005a0b650664028301650c650d64109c0264116412840483015a0e650664028301650f650c64139c0264146415840483015a10650664028301650f650c64139c0264166417840483015a116418641984005a1264015300291ae9000000004eda10636f6e5f736d61636b5f746861745f36da0873657474696e67732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65630000000000000000000000000600000043000000734e0000006401740064023c006403740064043c00740164058301740064063c006407740064083c0064097400640a3c0074026a037400640b3c00640264066408640a640b640467067400640c3c0064005300290d4e69204e0000da07706f745f6d6178e903000000da076d696e5f6265747a04302e3031da0a726566756e645f706572e90a000000da0a726566756e645f646976da10636f6e5f736d61636b65726f6f735f33da0c6465765f636f6e7472616374da086f70657261746f72da046c6973742904da0a5f5f73657474696e6773da07646563696d616cda03637478da0663616c6c6572a90072150000007215000000da00da045f5f5f5f0700000073100000000001080108010c01080108010a01060172170000002901da0a6265745f616d6f756e74630100000000000000040000000500000043000000738e0000007c007400640119006b057320740164027402740064011900830117008301820174037c0083017d0174046a057c0174066a0774066a0864038d03010074096a0a6404640583027d027c0264066b0572747c01640714007d0374046a0b7c0374066a0864088d0201007c017c036409640a9c035300740c83000100740d830001007c016404640b9c02530064005300290c4e72090000007a25626574206d7573742062652067726561746572207468616e206f7220657175616c20746f202903da06616d6f756e74da02746fda0c6d61696e5f6163636f756e747201000000720b000000e906000000e90200000029027219000000721a000000e9010000002903da03626574da03776f6eda067374617475732902721f0000007221000000290e7211000000da0e417373657274696f6e4572726f72da03737472da105f5f64657465726d696e655f636f7374da0863757272656e6379da0d7472616e736665725f66726f6d7213000000da04746869737214000000da0672616e646f6dda0772616e64696e74da087472616e73666572da105f5f676976655f6465765f746f6b656eda105f5f636865636b5f6f766572666c6f7729047218000000721f000000da0178da0a77696e5f616d6f756e74721500000072150000007216000000da05736d61636b12000000731800000000020e011201080114010c010801080110010c0206010601722f0000006301000000000000000200000004000000430000007330000000740074016a0274036a048301740564018301140064021a0083017d017c007c016b0072287c0053007c0153006400530029034e7a04302e3038721e0000002906da03696e747225000000da0a62616c616e63655f6f6672130000007227000000721200000029027218000000da076d61785f626574721500000072150000007216000000722400000023000000730800000000011c01080104027224000000630000000000000000020000000400000043000000733c00000074006a0174026401190083017d007c006a0374046a0583017402640219007402640319001b0014007d017c006a067c0174046a07830201006400530029044e720e000000720a000000720c0000002908da09696d706f72746c6962da0d696d706f72745f6d6f64756c657211000000723100000072130000007227000000722a00000072140000002902720e000000da06726566756e64721500000072150000007216000000722b0000002b000000730800000000010e0110010c01722b000000630000000000000000010000000400000043000000733200000074006a0174026a03830174046401190018007d007c0064026b04722e74006a057c0074046403190064048d0201006400530029054e72070000007201000000720e00000029027219000000721a000000290672250000007231000000721300000072270000007211000000722a0000002901da086f766572666c6f77721500000072150000007216000000722c000000320000007306000000000114010801722c0000002902da0773657474696e67da096e65775f76616c7565630200000000000000020000000300000043000000732a0000007400830001007c007401640119006b06731e74027c0064021700830182017c0174017c003c006400530029034e72100000007a1f206973206e6f74206120636f6e666967757261626c652073657474696e672e2903da115f5f6173736572745f6f70657261746f7272110000007222000000290272370000007238000000721500000072150000007216000000da0f6368616e67655f73657474696e6773380000007308000000000206010e010a01723a00000029027219000000721a000000630200000000000000020000000400000043000000731800000074008300010074016a027c007c0164018d0201006400530029024e29027219000000721a000000290372390000007225000000722a00000029027219000000721a000000721500000072150000007216000000722a00000040000000730400000000020601722a000000630200000000000000030000000400000043000000732600000074008300010074016a0274036401190083017d027c026a047c007c0164028d0201006400530029034e720e00000029027219000000721a00000029057239000000723300000072340000007211000000722a00000029037219000000721a000000720e000000721500000072150000007216000000da127472616e736665725f6465765f746f6b656e460000007306000000000206010e01723b000000630000000000000000000000000300000043000000731a00000074006a017402640119006b02731674036402830182016400530029034e720f0000007a234f6e6c79206f70657261746f722063616e2063616c6c2074686973206d6574686f642e29047213000000721400000072110000007222000000721500000072150000007215000000721600000072390000004d000000730400000000011001723900000029137225000000da044861736872110000007228000000da04736565647217000000da085f5f6578706f72747230000000722f0000007224000000722b000000722c0000007223000000da03416e79723a000000da05666c6f6174722a000000723b00000072390000007215000000721500000072150000007216000000da083c6d6f64756c653e01000000731e00000008010e020803080b060110100e0808070806060112070601120506011206