Contract con_smackeroos_2


Contract Code

1 import currency
2 import submission
3 supply = Variable(contract='con_smackeroos_2', name='supply')
4 balances = Hash(default_value=0, contract='con_smackeroos_2', name='balances'
5 )
6 owner = Variable(contract='con_smackeroos_2', name='owner')
7
8
9 def (amount=1000000):
10 balances[ctx.caller] = amount
11 supply.set(amount)
12 owner.set(ctx.caller)
13
14
15 @export('con_smackeroos_2')
16 def transfer(amount: float, to: str):
17 sender = ctx.caller
18 assert balances[sender] >= amount, 'Not enough coins to send!'
19 balances[sender] -= amount
20 balances[to] += amount
21
22
23 @export('con_smackeroos_2')
24 def balance_of(account: str):
25 return balances[account]
26
27
28 @export('con_smackeroos_2')
29 def total_supply():
30 return supply.get()
31
32
33 @export('con_smackeroos_2')
34 def allowance(main: str, spender: str):
35 return balances[main, spender]
36
37
38 @export('con_smackeroos_2')
39 def approve(amount: float, to: str):
40 sender = ctx.caller
41 balances[sender, to] += amount
42 return balances[sender, to]
43
44
45 @export('con_smackeroos_2')
46 def transfer_from(amount: float, to: str, main_account: str):
47 sender = ctx.caller
48 assert balances[main_account, sender
49 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format(
50 balances[main_account, sender], amount)
51 assert balances[main_account] >= amount, 'Not enough coins to send!'
52 balances[main_account, sender] -= amount
53 balances[main_account] -= amount
54 balances[to] += amount
55
56
57 @export('con_smackeroos_2')
58 def redeem(amount: float):
59 assert balances[ctx.caller] >= amount, 'Not enough tokens to redeem!'
60 assert amount > 0, 'Invalid amount!'
61 balances[ctx.caller] -= amount
62 share = amount / supply.get()
63 reward = share * currency.balance_of(ctx.this)
64 if reward > 0:
65 currency.transfer(reward, ctx.caller)
66 supply.set(supply.get() - amount)
67
68
69 @export('con_smackeroos_2')
70 def change_ownership(new_owner: str):
71 assert ctx.caller == owner.get(), 'Only the owner can change ownership!'
72 owner.set(new_owner)
73
74
75 @export('con_smackeroos_2')
76 def change_developer(contract: str, new_developer: str):
77 assert ctx.caller == owner.get(
78 ), 'Only the owner can change the developer!'
79 submission.change_developer(contract=contract, new_developer=new_developer)
80

Byte Code

e300000000000000000000000005000000400000007310010000640064016c005a00640064016c015a0165026402640364048d025a03650464006402640564068d035a0565026402640764048d025a0664246409640a84015a076508640283016509650a640b9c02640c640d840483015a0b650864028301650a640e9c01640f6410840483015a0c65086402830164116412840083015a0d650864028301650a650a64139c0264146415840483015a0e6508640283016509650a640b9c0264166417840483015a0f6508640283016509650a650a64189c036419641a840483015a106508640283016509641b9c01641c641d840483015a11650864028301650a641e9c01641f6420840483015a12650864028301650a650a64219c0264226423840483015a13640153002925e9000000004eda10636f6e5f736d61636b65726f6f735f32da06737570706c792902da08636f6e7472616374da046e616d65da0862616c616e6365732903da0d64656661756c745f76616c756572040000007205000000da056f776e6572e940420f0063010000000000000001000000030000004300000073240000007c00740074016a023c0074036a047c008301010074056a0474016a02830101006400530029014e2906da0a5f5f62616c616e636573da03637478da0663616c6c6572da085f5f737570706c79da03736574da075f5f6f776e65722901da06616d6f756e74a9007211000000da00da045f5f5f5f09000000730600000000010a010a01721300000029027210000000da02746f630200000000000000030000000400000043000000733e00000074006a017d0274027c0219007c006b05731a740364018301820174027c02050019007c00380003003c0074027c01050019007c00370003003c006400530029024e7a194e6f7420656e6f75676820636f696e7320746f2073656e64212904720b000000720c000000720a000000da0e417373657274696f6e4572726f72290372100000007214000000da0673656e646572721100000072110000007212000000da087472616e736665720f0000007308000000000206011401100172170000002901da076163636f756e74630100000000000000010000000200000043000000730800000074007c001900530029014e2901720a00000029017218000000721100000072110000007212000000da0a62616c616e63655f6f6617000000730200000000027219000000630000000000000000000000000100000043000000730800000074006a018300530029014e2902720d000000da036765747211000000721100000072110000007212000000da0c746f74616c5f737570706c791c00000073020000000002721b0000002902da046d61696eda077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e2901720a0000002902721c000000721d000000721100000072110000007212000000da09616c6c6f77616e63652100000073020000000002721e000000630200000000000000030000000400000043000000732600000074006a017d0274027c027c016602050019007c00370003003c0074027c027c0166021900530029014e2903720b000000720c000000720a0000002903721000000072140000007216000000721100000072110000007212000000da07617070726f7665260000007306000000000206011401721f000000290372100000007214000000da0c6d61696e5f6163636f756e74630300000000000000040000000500000043000000737a00000074006a017d0374027c027c03660219007c006b05732e740364016a0474027c027c03660219007c0083028301820174027c0219007c006b057342740364028301820174027c027c036602050019007c00380003003c0074027c02050019007c00380003003c0074027c01050019007c00370003003c006400530029034e7a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64212905720b000000720c000000720a0000007215000000da06666f726d617429047210000000721400000072200000007216000000721100000072110000007212000000da0d7472616e736665725f66726f6d2d0000007310000000000206010a010c0112011401140110017222000000290172100000006301000000000000000300000004000000430000007380000000740074016a0219007c006b05731674036401830182017c0064026b0473267403640383018201740074016a02050019007c00380003003c007c0074046a0583001b007d017c0174066a0774016a08830114007d027c0264026b04726a74066a097c0274016a028302010074046a0a74046a0583007c001800830101006400530029044e7a1c4e6f7420656e6f75676820746f6b656e7320746f2072656465656d2172010000007a0f496e76616c696420616d6f756e7421290b720a000000720b000000720c0000007215000000720d000000721a000000da0863757272656e63797219000000da04746869737217000000720e00000029037210000000da057368617265da06726577617264721100000072110000007212000000da0672656465656d39000000731000000000021601100112010c01100108010e0172270000002901da096e65775f6f776e6572630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174026a057c00830101006400530029024e7a244f6e6c7920746865206f776e65722063616e206368616e6765206f776e657273686970212906720b000000720c000000720f000000721a0000007215000000720e00000029017228000000721100000072110000007212000000da106368616e67655f6f776e65727368697045000000730400000000021601722900000029027204000000da0d6e65775f646576656c6f706572630200000000000000020000000400000043000000732800000074006a0174026a0383006b027316740464018301820174056a067c007c0164028d0201006400530029034e7a284f6e6c7920746865206f776e65722063616e206368616e67652074686520646576656c6f7065722129027204000000722a0000002907720b000000720c000000720f000000721a0000007215000000da0a7375626d697373696f6eda106368616e67655f646576656c6f70657229027204000000722a000000721100000072110000007212000000722c0000004b0000007306000000000210010601722c0000002901720900000029147223000000722b000000da085661726961626c65720d000000da0448617368720a000000720f0000007213000000da085f5f6578706f7274da05666c6f6174da0373747272170000007219000000721b000000721e000000721f000000722200000072270000007229000000722c0000007211000000721100000072110000007212000000da083c6d6f64756c653e01000000732c000000080108010c010e020c030a060601120706011004100506011204060112060601140b0601100b060110050601