Contract con_aprv_contract


Contract Code


  
1 balances = Hash(default_value=0)
2 metadata = Hash()
3
4
5 def seed():
6 balances[ctx.caller] = 200000
7 metadata['token name'] = 'Approval_v2'
8 metadata['token symbol'] = 'APRV'
9
10 @export
11 def transfer(amount: float, to: str):
12 assert amount > 0, 'Cannot send negative balances!'
13 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
14 balances[ctx.caller] -= amount
15 balances[to] += amount
16
17 @export
18 def approve(amount: float, to: str, user: str=''):
19 assert amount > 0, 'Cannot send negative balances!'
20 if user == '':
21 user = ctx.caller
22 balances[user, to] += amount
23 else:
24 balances[user, to] += amount
25
26
27 @export
28 def transfer_from(amount: float, to: str, main_account: str):
29 assert amount > 0, 'Cannot send negative balances!'
30 assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format( balances[main_account, ctx.caller], amount)
31 assert balances[main_account] >= amount, 'Not enough coins to send!'
32 balances[main_account, ctx.caller] -= amount
33 balances[main_account] -= amount
34 balances[to] += amount

Byte Code

e300000000000000000000000006000000400000007374000000650064006401640264038d035a0165006401640464058d025a026406640784005a036504640183016505650664089c026409640a840483015a076504640183016413650565066506640c9c03640d640e840583015a08650464018301650565066506640f9c0364106411840483015a09641253002914e900000000da11636f6e5f617072765f636f6e7472616374da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000630000000000000000000000000300000043000000731e0000006401740074016a023c006402740364033c006404740364053c006400530029064e69400d0300da0b417070726f76616c5f76327a0a746f6b656e206e616d65da04415052567a0c746f6b656e2073796d626f6c2904da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461a900720e000000720e000000da00da065f5f7365656406000000730600000000010a01080172100000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904da0e417373657274696f6e4572726f72720a000000720b000000720c000000290272110000007212000000720e000000720e000000720f000000da087472616e736665720c000000730800000000021001160112017214000000720f000000290372110000007212000000da0475736572630300000000000000030000000400000043000000734c0000007c0064016b04731074006402830182017c0264036b02723474016a027d0274037c027c016602050019007c00370003003c006e1474037c027c016602050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321720f00000029047213000000720b000000720c000000720a0000002903721100000072120000007215000000720e000000720e000000720f000000da07617070726f766514000000730a000000000210010801060116027216000000290372110000007212000000da0c6d61696e5f6163636f756e74630300000000000000030000000500000043000000738a0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e642129057213000000720a000000720b000000720c000000da06666f726d61742903721100000072120000007217000000720e000000720e000000720f000000da0d7472616e736665725f66726f6d1e0000007310000000000210010c010c01140114011601100172190000004e2901720f000000290ada0448617368720a000000720d0000007210000000da085f5f6578706f7274da05666c6f6174da03737472721400000072160000007219000000720e000000720e000000720e000000720f000000da083c6d6f64756c653e010000007312000000060108010c03080606011207060116090601