Contract con_gambleme
Creator | e921b40a3143c18bb4df94c20bfe3769144da6771aeb699bf0c5be422147aef5 |
Creation Hash | 976f1940ea9c1f9cbd8261fb1c62ff98528f8631a1d30c850a4951db39147018 |
Created On | 1009 days ago - 6/23/2021, 9:54:47 PM UTC+0 |
Contract Code
1
random.seed()
2
# LST001
3
balances = Hash(default_value=0)
4
# LST002
5
metadata = Hash()
6
pot = Variable()
7
@construct
8
def seed(supply=100):
9
# LST001 - MINT SUPPLY to wallet that submits the contract
10
balances[ctx.caller] = supply
11
# LST002
12
metadata['token_name'] = "GambleMe"
13
metadata['token_symbol'] = "GM"
14
metadata['operator'] = ctx.caller
15
pot.set(0)
16
# LST002
17
@export
18
def change_metadata(key: str, value: Any):
19
assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
20
metadata[key] = value
21
def calc_skim(amount: float):
22
skim = amount * 0.08
23
p = pot.get()
24
pot.set(p + skim)
25
return skim
26
def draw_lotto():
27
draw = random.randint(0, 99)
28
if draw == 0 or draw == 1:
29
# win!
30
return True
31
# lose
32
return False
33
# LST001
34
@export
35
def transfer(amount: float, to: str):
36
assert amount > 0, 'Cannot send negative balances!'
37
assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
38
# Take 3% from the transfer and put it into the pot
39
skim = calc_skim(amount)
40
balances[ctx.caller] -= amount
41
balances[to] += (amount - skim)
42
draw = draw_lotto()
43
if draw:
44
balances[to] += pot.get()
45
pot.set(0)
46
# LST001
47
@export
48
def approve(amount: float, to: str):
49
assert amount > 0, 'Cannot send negative balances!'
50
balances[ctx.caller, to] += amount
51
# LST001
52
@export
53
def transfer_from(amount: float, to: str, main_account: str):
54
assert amount > 0, 'Cannot send negative balances!'
55
assert balances[
56
main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}' \
57
.format(balances[main_account, ctx.caller], amount)
58
assert balances[main_account] >= amount, 'Not enough coins to send!'
59
skim = calc_skim(amount)
60
balances[main_account, ctx.caller] -= amount
61
balances[main_account] -= amount
62
balances[to] += (amount - skim)
63
draw = draw_lotto()
64
if draw:
65
balances[to] += pot.get()
66
pot.set(0)
Byte Code
e3000000000000000000000000050000004000000073b400000065006a0183000100650264006401640264038d035a0365026401640464058d025a0465056401640664058d025a06641b6408640984015a076508640183016509650a640a9c02640b640c840483015a0b650c640d9c01640e640f84045a0d6410641184005a0e650864018301650c650964129c0264136414840483015a0f650864018301650c650964129c0264156416840483015a10650864018301650c6509650964179c0364186419840483015a11641a5300291ce900000000da0c636f6e5f67616d626c656d65da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da03706f74e96400000063010000000000000001000000030000004300000073320000007c00740074016a023c006401740364023c006403740364043c0074016a02740364053c0074046a056406830101006400530029074eda0847616d626c654d65da0a746f6b656e5f6e616d65da02474dda0c746f6b656e5f73796d626f6cda086f70657261746f7272010000002906da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461da055f5f706f74da037365742901da06737570706c79a9007216000000da00da045f5f5f5f07000000730a00000000010a01080108010a0172180000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720e0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721000000072110000007212000000da0e417373657274696f6e4572726f7229027219000000721a000000721600000072160000007217000000da0f6368616e67655f6d657461646174610f0000007306000000000210010601721c0000002901da06616d6f756e7463010000000000000003000000030000004300000073260000007c0074006401830114007d0174016a0283007d0274016a037c027c011700830101007c01530029024e7a04302e30382904da07646563696d616c7213000000da0367657472140000002903721d000000da04736b696dda0170721600000072160000007217000000da0b5f5f63616c635f736b696d16000000730800000000010c0108010e017222000000630000000000000000010000000300000043000000732400000074006a016401640283027d007c0064016b02731c7c0064036b027220640453006405530029064e7201000000e963000000e90100000054462902da0672616e646f6dda0772616e64696e742901da0464726177721600000072160000007217000000da0c5f5f647261775f6c6f74746f1d000000730800000000010c011001040172280000002902721d000000da02746f63020000000000000004000000050000004300000073800000007c0064016b0473107400640283018201740174026a0319007c006b057326740064038301820174047c0083017d02740174026a03050019007c00380003003c0074017c01050019007c007c021800370003003c00740583007d037c03727c74017c010500190074066a078300370003003c0074066a086401830101006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212909721b000000720f00000072100000007211000000722200000072280000007213000000721f00000072140000002904721d000000722900000072200000007227000000721600000072160000007217000000da087472616e73666572240000007312000000000210011601080112011401060104011401722a000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721b000000720f000000721000000072110000002902721d0000007229000000721600000072160000007217000000da07617070726f766531000000730400000000021001722b0000002903721d0000007229000000da0c6d61696e5f6163636f756e7463030000000000000005000000050000004300000073be0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174057c0083017d0374017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c007c031800370003003c00740683007d047c0472ba74017c010500190074076a088300370003003c0074076a096401830101006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e6421290a721b000000720f00000072100000007211000000da06666f726d6174722200000072280000007213000000721f00000072140000002905721d0000007229000000722c00000072200000007227000000721600000072160000007217000000da0d7472616e736665725f66726f6d37000000731a000000000210010c010c01140114010801160110011401060104011401722e0000004e2901720900000029127225000000da0473656564da0448617368720f0000007212000000da085661726961626c6572130000007218000000da085f5f6578706f7274da03737472da03416e79721c000000da05666c6f617472220000007228000000722a000000722b000000722e0000007216000000721600000072160000007217000000da083c6d6f64756c653e01000000731c00000008010e010c010c030a08060112060e0708070601120c060112050601