Contract con_kiss_contract


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=1_000_000_000):
9 # LST001 - MINT SUPPLY to wallet that submits the contract
10 balances[ctx.caller] = supply
11 # LST002
12 metadata['token_name'] = "Kiss of Python"
13 metadata['token_symbol'] = "KISS"
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.02
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 1% 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

e3000000000000000000000000050000004000000073b400000065006a0183000100650264006401640264038d035a0365026401640464058d025a0465056401640664058d025a06641b6408640984015a076508640183016509650a640a9c02640b640c840483015a0b650c640d9c01640e640f84045a0d6410641184005a0e650864018301650c650964129c0264136414840483015a0f650864018301650c650964129c0264156416840483015a10650864018301650c6509650964179c0364186419840483015a11641a5300291ce900000000da11636f6e5f6b6973735f636f6e7472616374da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da03706f74e900ca9a3b63010000000000000001000000030000004300000073320000007c00740074016a023c006401740364023c006403740364043c0074016a02740364053c0074046a056406830101006400530029074e7a0e4b697373206f6620507974686f6eda0a746f6b656e5f6e616d65da044b495353da0c746f6b656e5f73796d626f6cda086f70657261746f7272010000002906da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461da055f5f706f74da037365742901da06737570706c79a9007215000000da00da045f5f5f5f08000000730a00000000010a01080108010a0172170000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720d0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904720f00000072100000007211000000da0e417373657274696f6e4572726f72290272180000007219000000721500000072150000007216000000da0f6368616e67655f6d65746164617461100000007306000000000210010601721b0000002901da06616d6f756e7463010000000000000003000000030000004300000073260000007c0074006401830114007d0174016a0283007d0274016a037c027c011700830101007c01530029024e7a04302e30322904da07646563696d616c7212000000da0367657472130000002903721c000000da04736b696dda0170721500000072150000007216000000da0b5f5f63616c635f736b696d17000000730800000000010c0108010e017221000000630000000000000000010000000300000043000000732400000074006a016401640283027d007c0064016b02731c7c0064036b027220640453006405530029064e7201000000e963000000e90100000054462902da0672616e646f6dda0772616e64696e742901da0464726177721500000072150000007216000000da0c5f5f647261775f6c6f74746f1e000000730800000000010c011001040172270000002902721c000000da02746f63020000000000000004000000050000004300000073800000007c0064016b0473107400640283018201740174026a0319007c006b057326740064038301820174047c0083017d02740174026a03050019007c00380003003c0074017c01050019007c007c021800370003003c00740583007d037c03727c74017c010500190074066a078300370003003c0074066a086401830101006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212909721a000000720e000000720f0000007210000000722100000072270000007212000000721e00000072130000002904721c0000007228000000721f0000007226000000721500000072150000007216000000da087472616e736665722500000073120000000002100116010801120114010601040114017229000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721a000000720e000000720f00000072100000002902721c0000007228000000721500000072150000007216000000da07617070726f766532000000730400000000021001722a0000002903721c0000007228000000da0c6d61696e5f6163636f756e7463030000000000000005000000050000004300000073be0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174057c0083017d0374017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c007c031800370003003c00740683007d047c0472ba74017c010500190074076a088300370003003c0074076a096401830101006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e6421290a721a000000720e000000720f0000007210000000da06666f726d6174722100000072270000007212000000721e00000072130000002905721c0000007228000000722b000000721f0000007226000000721500000072150000007216000000da0d7472616e736665725f66726f6d38000000731a000000000210010c010c01140114010801160110011401060104011401722d0000004e2901720900000029127224000000da0473656564da0448617368720e0000007211000000da085661726961626c6572120000007217000000da085f5f6578706f7274da03737472da03416e79721b000000da05666c6f6174722100000072270000007229000000722a000000722d0000007215000000721500000072150000007216000000da083c6d6f64756c653e01000000731e0000000801060108010c010c030a08060112060e0708070601120c060112050601