Contract con_ocoin


Contract Code


  
1 __balances = Hash(default_value=0, contract='con_ocoin', name='balances')
2
3
4 def ____():
5 __balances[ctx.caller] = 1000000
6
7
8 @__export('con_ocoin')
9 def transfer(amount: float, to: str):
10 assert amount > 0, 'Cannot send negative balances!'
11 sender = ctx.caller
12 assert __balances[sender] >= amount, 'Not enough coins to send!'
13 __balances[sender] -= amount
14 __balances[to] += amount
15
16
17 @__export('con_ocoin')
18 def balance_of(account: str):
19 return __balances[account]
20
21
22 @__export('con_ocoin')
23 def allowance(owner: str, spender: str):
24 return __balances[owner, spender]
25
26
27 @__export('con_ocoin')
28 def approve(amount: float, to: str):
29 assert amount > 0, 'Cannot send negative balances!'
30 sender = ctx.caller
31 __balances[sender, to] += amount
32 return __balances[sender, to]
33
34
35 @__export('con_ocoin')
36 def transfer_from(amount: float, to: str, main_account: str):
37 assert amount > 0, 'Cannot send negative balances!'
38 sender = ctx.caller
39 assert __balances[main_account, sender
40 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format(
41 __balances[main_account, sender], amount)
42 assert __balances[main_account] >= amount, 'Not enough coins to send!'
43 __balances[main_account, sender] -= amount
44 __balances[main_account] -= amount
45 __balances[to] += amount
46

Byte Code

e300000000000000000000000005000000400000007392000000650064006401640264038d035a016404640584005a026503640183016504650564069c0264076408840483015a06650364018301650564099c01640a640b840483015a0765036401830165056505640c9c02640d640e840483015a086503640183016504650564069c02640f6410840483015a0965036401830165046505650564119c0364126413840483015a0a641453002915e900000000da09636f6e5f6f636f696eda0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65630000000000000000000000000300000043000000730e0000006401740074016a023c006400530029024e6940420f002903da0a5f5f62616c616e636573da03637478da0663616c6c6572a900720a000000720a000000da00da045f5f5f5f0400000073020000000001720c0000002902da06616d6f756e74da02746f630200000000000000030000000400000043000000734e0000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904da0e417373657274696f6e4572726f727208000000720900000072070000002903720d000000720e000000da0673656e646572720a000000720a000000720b000000da087472616e7366657208000000730a0000000002100106011401100172110000002901da076163636f756e74630100000000000000010000000200000043000000730800000074007c001900530029014e2901720700000029017212000000720a000000720a000000720b000000da0a62616c616e63655f6f66110000007302000000000272130000002902da056f776e6572da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e29017207000000290272140000007215000000720a000000720a000000720b000000da09616c6c6f77616e63651600000073020000000002721600000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904720f0000007208000000720900000072070000002903720d000000720e0000007210000000720a000000720a000000720b000000da07617070726f76651b0000007308000000000210010601140172170000002903720d000000720e000000da0c6d61696e5f6163636f756e74630300000000000000040000000500000043000000738a0000007c0064016b047310740064028301820174016a027d0374037c027c03660219007c006b05733e740064036a0474037c027c03660219007c0083028301820174037c0219007c006b057352740064048301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64212905720f000000720800000072090000007207000000da06666f726d61742904720d000000720e00000072180000007210000000720a000000720a000000720b000000da0d7472616e736665725f66726f6d2300000073120000000002100106010a010c011201140114011001721a0000004e290bda04486173687207000000720c000000da085f5f6578706f7274da05666c6f6174da037374727211000000721300000072160000007217000000721a000000720a000000720a000000720a000000720b000000da083c6d6f64756c653e0100000073160000000e030804060112080601100406011204060112070601