Contract con_uw_withdrawal_1


Contract Code

1 import currency
2 import con_uwarriors_lst001
3
4
5 metadata = Hash(default_value=0)
6 balances = Hash(default_value=0)
7 wp = ForeignHash(foreign_contract='con_uwarriors_lst001', foreign_name='balances')
8
9 @construct
10 def seed():
11 metadata['operator'] = ctx.caller
12
13
14 @export
15 def withdrawal():
16 sender = ctx.caller
17 operator = metadata['operator']
18 assert balances[sender,'amount'] > 0 , 'Not enough coins to withdrawal!'
19
20 amount = balances[sender,'amount']
21 con_uwarriors_lst001.transfer_from(amount, sender , operator)
22 balances[sender,'amount'] = 0
23
24
25 @export
26 def charge(sender:str, amount: int):
27 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
28 balances[sender,'amount'] = amount
29
30

Byte Code

e300000000000000000000000006000000400000007370000000640064016c005a00640064016c015a01650264006402640364048d035a03650264006402640564048d035a046505640664056402640764088d045a066409640a84005a07650864028301640b640c840083015a09650864028301650a650b640d9c02640e640f840483015a0c640153002910e9000000004eda13636f6e5f75775f7769746864726177616c5f31da086d657461646174612903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da0862616c616e636573da14636f6e5f7577617272696f72735f6c7374303031da0277702904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572050000007206000000630000000000000000000000000300000043000000730e00000074006a01740264013c006400530029024eda086f70657261746f722903da03637478da0663616c6c6572da0a5f5f6d65746164617461a90072100000007210000000da00da045f5f5f5f0b000000730200000000017212000000630000000000000000030000000400000043000000735000000074006a017d007402640119007d0174037c0064026602190064036b047326740464048301820174037c006402660219007d0274056a067c027c007c0183030100640374037c00640266023c006400530029054e720c000000da06616d6f756e7472010000007a1f4e6f7420656e6f75676820636f696e7320746f207769746864726177616c212907720d000000720e000000720f000000da0a5f5f62616c616e636573da0e417373657274696f6e4572726f727208000000da0d7472616e736665725f66726f6d2903da0673656e646572720c0000007213000000721000000072100000007211000000da0a7769746864726177616c0f000000730c00000000020601080118010c010e017218000000290272170000007213000000630200000000000000020000000400000043000000732600000074006a017402640119006b02731674036402830182017c0174047c00640366023c006400530029044e720c0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612172130000002905720d000000720e000000720f00000072150000007214000000290272170000007213000000721000000072100000007211000000da066368617267651900000073060000000002100106017219000000290dda0863757272656e63797208000000da0448617368720f0000007214000000da0b466f726569676e48617368da045f5f77707212000000da085f5f6578706f72747218000000da03737472da03696e7472190000007210000000721000000072100000007211000000da083c6d6f64756c653e01000000731600000008010801060108010601080104010c030804100a0601