Contract con_phi


Contract Code


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

Byte Code

e3000000000000000000000000050000004000000073a0000000650064006401640264038d035a0165026401640464058d025a0364186407640884015a046505640183016506650764099c02640a640b840483015a086505640183016507640c9c01640d640e840483015a0965056401830165076507640f9c0264106411840483015a0a6505640183016506650764099c0264126413840483015a0b65056401830165066507650764149c0364156416840483015a0c641753002919e900000000da07636f6e5f706869da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da06737570706c79290272050000007206000000e900ca9a3b63010000000000000001000000030000004300000073180000007c00740074016a023c0074036a047c00830101006400530029014e2905da0a5f5f62616c616e636573da03637478da0663616c6c6572da085f5f737570706c79da037365742901da06616d6f756e74a900720f000000da00da045f5f5f5f05000000730400000000010a0172110000002902720e000000da02746f630200000000000000030000000400000043000000734e0000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904da0e417373657274696f6e4572726f72720a000000720b00000072090000002903720e0000007212000000da0673656e646572720f000000720f0000007210000000da087472616e736665720a000000730a0000000002100106011401100172150000002901da076163636f756e74630100000000000000010000000200000043000000730800000074007c001900530029014e2901720900000029017216000000720f000000720f0000007210000000da0a62616c616e63655f6f66130000007302000000000272170000002902da056f776e6572da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e29017209000000290272180000007219000000720f000000720f0000007210000000da09616c6c6f77616e63651800000073020000000002721a00000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129047213000000720a000000720b00000072090000002903720e00000072120000007214000000720f000000720f0000007210000000da07617070726f76651d00000073080000000002100106011401721b0000002903720e0000007212000000da0c6d61696e5f6163636f756e74630300000000000000040000000500000043000000738a0000007c0064016b047310740064028301820174016a027d0374037c027c03660219007c006b05733e740064036a0474037c027c03660219007c0083028301820174037c0219007c006b057352740064048301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e642129057213000000720a000000720b0000007209000000da06666f726d61742904720e0000007212000000721c0000007214000000720f000000720f0000007210000000da0d7472616e736665725f66726f6d2500000073120000000002100106010a010c011201140114011001721e0000004e29017208000000290dda04486173687209000000da085661726961626c65720c0000007211000000da085f5f6578706f7274da05666c6f6174da0373747272150000007217000000721a000000721b000000721e000000720f000000720f000000720f0000007210000000da083c6d6f64756c653e0100000073180000000e010c030a05060112080601100406011204060112070601