Contract con_spange


Contract Code


  
1 import currency as tau
2 random.seed()
3 balances = Hash(default_value=0)
4 metadata = Hash()
5
6 @construct
7 def seed():
8 balances[ctx.caller] = 1000000
9 metadata['token_name'] = "Spare Change"
10 metadata['token_symbol'] = "SPANGE"
11 metadata['operator'] = ctx.caller
12
13 @export
14 def Space_Change(got_any: float):
15 tau.transfer_from(amount=s, to=metadata['operator'], main_account=ctx.caller)
16
17
18 @export
19 def approve(amount: float, to: str):
20 assert amount > 0, 'Cannot send negative balances!'
21 balances[ctx.caller, to] += amount
22
23
24 @export
25 def transfer(amount: float, to: str):
26 assert amount > 0, 'Cannot send negative balances!'
27 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
28 balances[ctx.caller] -= amount
29 balances[to] += amount
30
31 @export
32 def transfer_from(amount: float, to: str, main_account: str):
33 assert amount > 0, 'Cannot send negative balances!'
34 assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\
35 .format(balances[main_account, ctx.caller], amount)
36 assert balances[main_account] >= amount, 'Not enough coins to send!'
37 balances[main_account, ctx.caller] -= amount
38 balances[main_account] -= amount
39 balances[to] += amount
40
41 @export
42 def change_metadata(key: str, value: Any):
43 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
44 metadata[key] = value

Byte Code

e3000000000000000000000000050000004000000073ae000000640064016c005a0165026a0383000100650464006402640364048d035a0565046402640564068d025a066407640884005a07650864028301650964099c01640a640b840483015a0a6508640283016509650b640c9c02640d640e840483015a0c6508640283016509650b640c9c02640f6410840483015a0d6508640283016509650b650b64119c0364126413840483015a0e650864028301650b650f64149c0264156416840483015a10640153002917e9000000004eda0a636f6e5f7370616e6765da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d6574616461746129027205000000720600000063000000000000000000000000030000004300000073280000006401740074016a023c006402740364033c006404740364053c0074016a02740364063c006400530029074e6940420f007a0c5370617265204368616e6765da0a746f6b656e5f6e616d65da065350414e4745da0c746f6b656e5f73796d626f6cda086f70657261746f722904da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461a90072100000007210000000da00da045f5f5f5f07000000730800000000010a010801080172120000002901da07676f745f616e79630100000000000000010000000500000043000000731a00000074006a01740274036401190074046a0564028d0301006400530029034e720b0000002903da06616d6f756e74da02746fda0c6d61696e5f6163636f756e742906da03746175da0d7472616e736665725f66726f6dda0173720f000000720d000000720e00000029017213000000721000000072100000007211000000da0c53706163655f4368616e67650e00000073020000000002721a000000290272140000007215000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904da0e417373657274696f6e4572726f72720c000000720d000000720e000000290272140000007215000000721000000072100000007211000000da07617070726f766514000000730400000000021001721c000000630200000000000000020000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904721b000000720c000000720d000000720e000000290272140000007215000000721000000072100000007211000000da087472616e736665721a00000073080000000002100116011201721d0000002903721400000072150000007216000000630300000000000000030000000500000043000000738a0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64212905721b000000720c000000720d000000720e000000da06666f726d617429037214000000721500000072160000007210000000721000000072110000007218000000220000007310000000000210010c010c01140114011601100172180000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720b0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904720d000000720e000000720f000000721b0000002902721f0000007220000000721000000072100000007211000000da0f6368616e67655f6d657461646174612e000000730600000000021001060172210000002911da0863757272656e63797217000000da0672616e646f6dda0473656564da0448617368720c000000720f0000007212000000da085f5f6578706f7274da05666c6f6174721a000000da03737472721c000000721d0000007218000000da03416e7972210000007210000000721000000072100000007211000000da083c6d6f64756c653e01000000731c000000080108010e010c0308070601100506011205060112070601140b0601