Contract con_dec_fix_6_tad


Contract Code


  
1 balances = Hash(default_value=0)
2 metadata = Hash()
3 operator = Variable()
4 total_supply = Variable()
5 @construct
6 def seed(owner: str):
7 total_supply.set(0)
8 operator.set(owner)
9 metadata['token_name'] = 'RubixDAO'
10 metadata['token_symbol'] = 'lMKR'
11 metadata['token_logo_url'] = 'image.site'
12 metadata['operator'] = ctx.caller
13 @export
14 def transfer(amount: float, to: str):
15 assert amount > 0, 'Cannot send negative balances!'
16 sender = ctx.caller
17 assert balances[sender] >= amount, 'Not enough coins to send!'
18 balances[sender] -= amount
19 balances[to] += amount
20 @export
21 def balance_of(account: str):
22 return balances[account]
23 @export
24 def allowance(owner: str, spender: str):
25 return balances[owner, spender]
26 @export
27 def approve(amount: float, to: str):
28 assert amount > 0, 'Cannot send negative balances!'
29 sender = ctx.caller
30 balances[sender, to] += amount
31 return balances[sender, to]
32 @export
33 def transfer_from(amount: float, to: str, main_account: str):
34 assert amount > 0, 'Cannot send negative balances!'
35 sender = ctx.caller
36 assert balances[main_account] >= amount, 'Not enough coins to send!'
37 assert balances[main_account, sender] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\
38 .format(balances[main_account, sender], amount)
39 balances[main_account, sender] -= amount
40 balances[main_account] -= amount
41 balances[to] += amount
42 @export
43 def mint(amount: float):
44 assert_owner()
45 assert amount > 0, 'Cannot mint negative balances!'
46 sender = ctx.caller
47 balances[sender] += amount
48 total = total_supply.get() + amount
49 total_supply.set(total)
50 @export
51 def burn(amount: float):
52 assert amount > 0, 'Cannot burn negative balances!'
53 sender = ctx.caller
54 assert balances[sender] >= amount, 'Not enough coins to burn!'
55 balances[sender] -= amount
56 total = total_supply.get() - amount
57 total_supply.set(total)
58 @export
59 def get_total_supply():
60 return total_supply.get()
61 @export
62 def change_metadata(key: str, value: Any):
63 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
64 metadata[key] = value
65 @export
66 def change_owner(new_owner: str):
67 assert_owner()
68 operator.set(new_owner)
69 def assert_owner():
70 assert ctx.caller == operator.get(), 'Only operator can call!'

Byte Code

e30000000000000000000000000500000040000000732e010000650064006401640264038d035a0165006401640464058d025a0265036401640664058d025a0465036401640764058d025a05650664089c016409640a84045a0765086401830165096506640b9c02640c640d840483015a0a6508640183016506640e9c01640f6410840483015a0b6508640183016506650664119c0264126413840483015a0c65086401830165096506640b9c0264146415840483015a0d65086401830165096506650664169c0364176418840483015a0e650864018301650964199c01641a641b840483015a0f650864018301650964199c01641c641d840483015a10650864018301641e641f840083015a116508640183016506651264209c0264216422840483015a13650864018301650664239c0164246425840483015a146426642784005a15642853002929e900000000da11636f6e5f6465635f6669785f365f746164da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da086f70657261746f72da0c746f74616c5f737570706c792901da056f776e6572630100000000000000010000000300000043000000733a00000074006a0164018301010074026a017c00830101006402740364033c006404740364053c006406740364073c0074046a05740364083c006400530029094e7201000000da08527562697844414fda0a746f6b656e5f6e616d65da046c4d4b52da0c746f6b656e5f73796d626f6c7a0a696d6167652e73697465da0e746f6b656e5f6c6f676f5f75726c72080000002906da0e5f5f746f74616c5f737570706c79da03736574da0a5f5f6f70657261746f72da0a5f5f6d65746164617461da03637478da0663616c6c65722901720a000000a9007216000000da00da045f5f5f5f08000000730c00000000010a010a0108010801080172180000002902da06616d6f756e74da02746f630200000000000000030000000400000043000000734e0000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904da0e417373657274696f6e4572726f7272140000007215000000da0a5f5f62616c616e63657329037219000000721a000000da0673656e646572721600000072160000007217000000da087472616e7366657211000000730a00000000021001060114011001721e0000002901da076163636f756e74630100000000000000010000000200000043000000730800000074007c001900530029014e2901721c0000002901721f000000721600000072160000007217000000da0a62616c616e63655f6f661a0000007302000000000272200000002902720a000000da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e2901721c0000002902720a0000007221000000721600000072160000007217000000da09616c6c6f77616e63651f00000073020000000002722200000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721b00000072140000007215000000721c00000029037219000000721a000000721d000000721600000072160000007217000000da07617070726f76652400000073080000000002100106011401722300000029037219000000721a000000da0c6d61696e5f6163636f756e74630300000000000000040000000500000043000000738a0000007c0064016b047310740064028301820174016a027d0374037c0219007c006b05732a740064038301820174037c027c03660219007c006b057352740064046a0474037c027c03660219007c0083028301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d2905721b00000072140000007215000000721c000000da06666f726d617429047219000000721a0000007224000000721d000000721600000072160000007217000000da0d7472616e736665725f66726f6d2c000000731200000000021001060114010a010c0112011401100172260000002901721900000063010000000000000003000000040000004300000073460000007400830001007c0064016b047316740164028301820174026a037d0174047c01050019007c00370003003c0074056a0683007c0017007d0274056a077c02830101006400530029034e72010000007a1e43616e6e6f74206d696e74206e656761746976652062616c616e636573212908da0e5f5f6173736572745f6f776e6572721b00000072140000007215000000721c0000007210000000da03676574721100000029037219000000721d000000da05746f74616c721600000072160000007217000000da046d696e7439000000730c000000000206011001060110010c01722a00000063010000000000000003000000040000004300000073540000007c0064016b047310740064028301820174016a027d0174037c0119007c006b05732a740064038301820174037c01050019007c00380003003c0074046a0583007c0018007d0274046a067c02830101006400530029044e72010000007a1e43616e6e6f74206275726e206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f206275726e212907721b00000072140000007215000000721c00000072100000007228000000721100000029037219000000721d0000007229000000721600000072160000007217000000da046275726e43000000730c000000000210010601140110010c01722b000000630000000000000000000000000100000043000000730800000074006a018300530029014e2902721000000072280000007216000000721600000072160000007217000000da106765745f746f74616c5f737570706c794d00000073020000000002722c0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e72080000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721400000072150000007213000000721b0000002902722d000000722e000000721600000072160000007217000000da0f6368616e67655f6d65746164617461520000007306000000000210010601722f0000002901da096e65775f6f776e6572630100000000000000010000000200000043000000731400000074008300010074016a027c00830101006400530029014e290372270000007212000000721100000029017230000000721600000072160000007217000000da0c6368616e67655f6f776e6572590000007304000000000206017231000000630000000000000000000000000200000043000000731a00000074006a0174026a0383006b02731674046401830182016400530029024e7a174f6e6c79206f70657261746f722063616e2063616c6c2129057214000000721500000072120000007228000000721b000000721600000072160000007216000000721700000072270000005f0000007302000000000172270000004e2916da0448617368721c0000007213000000da085661726961626c6572120000007210000000da037374727218000000da085f5f6578706f7274da05666c6f6174721e0000007220000000722200000072230000007226000000722a000000722b000000722c000000da03416e79722f000000723100000072270000007216000000721600000072160000007217000000da083c6d6f64756c653e010000007332000000060108010c010c010c030e09060112080601100406011204060112070601140c060110090601100910050601120606011005