Contract con_spooky


Contract Code


  
1 random.seed()
2 # LST001
3 balances = Hash(default_value=0)
4 # LST002
5 metadata = Hash()
6 pot = Variable()
7 @construct
8 #<https://icons8.com/icon/Sra48NO05ILF/ghost
9 def seed():
10 # LST001 - MINT SUPPLY to wallet that submits the contract
11 balances[ctx.caller] = 1000000
12 # LST002
13 metadata['token_name'] = "SPOOKS"
14 metadata['token_symbol'] = "BOO"
15 metadata['operator'] = ctx.caller
16 metadata['burn_address'] = 'SPOOKED'
17
18 pot.set(0)
19 # LST002
20 @export
21 def change_metadata(key: str, value: Any):
22 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
23 metadata[key] = value
24
25 def calc_skim(amount: float):
26 skim = amount * 0.05
27 p = pot.get()
28 pot.set(p + skim)
29
30 return skim
31
32 def draw_lotto():
33 draw = random.randint(0, 99)
34 if draw == 0 or draw == 1:
35 # win!
36 return True
37 # lose
38 return False
39
40 # LST001
41 @export
42 def transfer(amount: float, to: str):
43 assert amount > 0, 'Cannot send negative balances!'
44 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
45 balances[ctx.caller] -= amount
46 balances[to] += (amount * 0.75)
47 balances[metadata['burn_address']] += (amount * 0.20)
48 # Take 5% from the transfer and put it into the pot
49 skim = calc_skim(amount)
50
51 draw = draw_lotto()
52 if draw:
53 balances[to] += pot.get()
54 pot.set(0)
55
56 # LST001
57 @export
58 def approve(amount: float, to: str):
59 assert amount > 0, 'Cannot send negative balances!'
60 balances[ctx.caller, to] += amount
61 # LST001
62 @export
63 def transfer_from(amount: float, to: str, main_account: str):
64 assert amount > 0, 'Cannot send negative balances!'
65 assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\
66 .format(balances[main_account, ctx.caller], amount)
67 assert balances[main_account] >= amount, 'Not enough coins to send!'
68
69 skim = calc_skim(amount)
70
71 balances[main_account, ctx.caller] -= amount
72 balances[main_account] -= amount
73
74 balances[to] += (amount * 0.75)
75 balances[metadata['burn_address']] += (amount * 0.20)
76
77 draw = draw_lotto()
78 if draw:
79 balances[to] += pot.get()
80 pot.set(0)
81
82

Byte Code

e3000000000000000000000000050000004000000073b200000065006a0183000100650264006401640264038d035a0365026401640464058d025a0465056401640664058d025a066407640884005a076508640183016509650a64099c02640a640b840483015a0b650c640c9c01640d640e84045a0d640f641084005a0e650864018301650c650964119c0264126413840483015a0f650864018301650c650964119c0264146415840483015a10650864018301650c6509650964169c0364176418840483015a1164195300291ae900000000da0a636f6e5f73706f6f6b79da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da03706f74630000000000000000000000000300000043000000733a0000006401740074016a023c006402740364033c006404740364053c0074016a02740364063c006407740364083c0074046a0564098301010064005300290a4e6940420f00da0653504f4f4b53da0a746f6b656e5f6e616d65da03424f4fda0c746f6b656e5f73796d626f6cda086f70657261746f72da0753504f4f4b4544da0c6275726e5f6164647265737372010000002906da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461da055f5f706f74da03736574a90072160000007216000000da00da045f5f5f5f07000000730c00000000010a01080108010a01080172180000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720d0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721100000072120000007213000000da0e417373657274696f6e4572726f7229027219000000721a000000721600000072160000007217000000da0f6368616e67655f6d65746164617461100000007306000000000210010601721c0000002901da06616d6f756e7463010000000000000003000000030000004300000073260000007c0074006401830114007d0174016a0283007d0274016a037c027c011700830101007c01530029024e7a04302e30352904da07646563696d616c7214000000da0367657472150000002903721d000000da04736b696dda0170721600000072160000007217000000da0b5f5f63616c635f736b696d17000000730800000000010c0108010e017222000000630000000000000000010000000300000043000000732400000074006a016401640283027d007c0064016b02731c7c0064036b027220640453006405530029064e7201000000e963000000e90100000054462902da0672616e646f6dda0772616e64696e742901da0464726177721600000072160000007217000000da0c5f5f647261775f6c6f74746f1e000000730800000000010c011001040172280000002902721d000000da02746f63020000000000000004000000060000004300000073a00000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c007404640483011400370003003c007401740564051900050019007c007404640683011400370003003c0074067c0083017d02740783007d037c03729c74017c010500190074086a098300370003003c0074086a0a6401830101006400530029074e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64217a04302e3735720f0000007a03302e32290b721b000000721000000072110000007212000000721e0000007213000000722200000072280000007214000000721f00000072150000002904721d000000722900000072200000007227000000721600000072160000007217000000da087472616e73666572250000007314000000000210011601120118011c010801060104011401722a000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721b0000007210000000721100000072120000002902721d0000007229000000721600000072160000007217000000da07617070726f766533000000730400000000021001722b0000002903721d0000007229000000da0c6d61696e5f6163636f756e7463030000000000000005000000060000004300000073de0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174057c0083017d0374017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c007406640583011400370003003c007401740764061900050019007c007406640783011400370003003c00740883007d047c0472da74017c010500190074096a0a8300370003003c0074096a0b6401830101006400530029084e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64217a04302e3735720f0000007a03302e32290c721b000000721000000072110000007212000000da06666f726d61747222000000721e000000721300000072280000007214000000721f00000072150000002905721d0000007229000000722c00000072200000007227000000721600000072160000007217000000da0d7472616e736665725f66726f6d39000000731c000000000210010c010c011401140108011601100118011c01060104011401722e0000004e29127225000000da0473656564da044861736872100000007213000000da085661726961626c6572140000007218000000da085f5f6578706f7274da03737472da03416e79721c000000da05666c6f617472220000007228000000722a000000722b000000722e0000007216000000721600000072160000007217000000da083c6d6f64756c653e01000000731c00000008010e010c010c030809060112060e0708070601120d060112050601