Contract con_uwarriors


Contract Code


  
1 import currency
2 __balances = Hash(default_value=0, contract='con_uwarriors', name='balances')
3 __operator = Variable(contract='con_uwarriors', name='operator')
4
5
6 def ____(vk: str, amount: int):
7 __operator.set(vk)
8 __balances[vk] = amount
9 __balances['pre_sale'] = [200, 600, 2500]
10 __balances['wp'] = [50, 150, 625]
11
12
13 @__export('con_uwarriors')
14 def warrior_point(option: int):
15 sender = ctx.caller
16 owner = __operator.get()
17 cost = __balances['pre_sale']
18 wp = __balances['wp']
19 assert currency.balance_of(sender) >= cost[option
20 ], 'Balance too low to create a post!'
21 currency.transfer_from(int(cost[option]), owner, sender)
22 __balances[sender] += wp[option]
23 __balances[owner] -= wp[option]
24 if option > 0:
25 __balances[sender, 'tickets'] += 1
26
27
28 @__export('con_uwarriors')
29 def transfer(amount: float, to: str):
30 assert amount > 0, 'Cannot send negative balances!'
31 sender = ctx.caller
32 assert __balances[sender] >= amount, 'Not enough coins to send!'
33 __balances[sender] -= amount
34 __balances[to] += amount
35
36
37 @__export('con_uwarriors')
38 def balance_of(account: str):
39 return __balances[account]
40
41
42 @__export('con_uwarriors')
43 def allowance(owner: str, spender: str):
44 return __balances[owner, spender]
45
46
47 @__export('con_uwarriors')
48 def approve(amount: float, to: str):
49 assert amount > 0, 'Cannot send negative balances!'
50 sender = ctx.caller
51 __balances[sender, to] += amount
52 return __balances[sender, to]
53
54
55 @__export('con_uwarriors')
56 def transfer_from(amount: float, to: str, main_account: str):
57 assert amount > 0, 'Cannot send negative balances!'
58 sender = ctx.caller
59 assert __balances[main_account, sender
60 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format(
61 __balances[main_account, sender], amount)
62 assert __balances[main_account] >= amount, 'Not enough coins to send!'
63 __balances[main_account, sender] -= amount
64 __balances[main_account] -= amount
65 __balances[to] += amount
66
67
68 @__export('con_uwarriors')
69 def minted(amount: float):
70 __assert_owner()
71 owner = __operator.get()
72 __balances[owner] += amount
73
74
75 @__export('con_uwarriors')
76 def change_owner(vk: str):
77 __assert_owner()
78 __operator.set(vk)
79
80
81 @__export('con_uwarriors')
82 def change_values(value: str, opt: int, amount: float):
83 __assert_owner()
84 option = __balances[value]
85 option[otp] = amount
86
87
88 def __assert_owner():
89 assert ctx.caller == __operator.get(), 'Only operator can call!'
90

Byte Code

e300000000000000000000000005000000400000007312010000640064016c005a00650164006402640364048d035a0265036402640564068d025a046505650664079c026408640984045a076508640283016506640a9c01640b640c840483015a09650864028301650a6505640d9c02640e640f840483015a0b650864028301650564109c0164116412840483015a0c6508640283016505650564139c0264146415840483015a0d650864028301650a6505640d9c0264166417840483015a0e650864028301650a6505650564189c036419641a840483015a0f650864028301650a641b9c01641c641d840483015a106508640283016505641e9c01641f6420840483015a1165086402830165056506650a64219c0364226423840483015a126424642584005a13640153002926e9000000004eda0d636f6e5f7577617272696f7273da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086f70657261746f722902720500000072060000002902da02766bda06616d6f756e74630200000000000000020000000300000043000000733200000074006a017c00830101007c0174027c003c006401640264036703740264043c006405640664076703740264083c006400530029094ee9c8000000695802000069c4090000da087072655f73616c65e932000000e9960000006971020000da0277702903da0a5f5f6f70657261746f72da03736574da0a5f5f62616c616e636573290272080000007209000000a9007212000000da00da045f5f5f5f06000000730800000000010a0108010e0172140000002901da066f7074696f6e630100000000000000050000000500000043000000739600000074006a017d0174026a0383007d027404640119007d037404640219007d0474056a067c0183017c037c0019006b057338740764038301820174056a0874097c037c00190083017c027c018303010074047c01050019007c047c001900370003003c0074047c02050019007c047c001900380003003c007c0064046b04729274047c0164056602050019006406370003003c006400530029074e720b000000720e0000007a2142616c616e636520746f6f206c6f7720746f20637265617465206120706f7374217201000000da077469636b657473e901000000290ada03637478da0663616c6c6572720f000000da036765747211000000da0863757272656e6379da0a62616c616e63655f6f66da0e417373657274696f6e4572726f72da0d7472616e736665725f66726f6dda03696e7429057215000000da0673656e646572da056f776e6572da04636f7374720e000000721200000072120000007213000000da0d77617272696f725f706f696e740d000000731600000000020601080108010801140106011601140114010801722300000029027209000000da02746f630200000000000000030000000400000043000000734e0000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904721d0000007218000000721900000072110000002903720900000072240000007220000000721200000072120000007213000000da087472616e736665721c000000730a0000000002100106011401100172250000002901da076163636f756e74630100000000000000010000000200000043000000730800000074007c001900530029014e2901721100000029017226000000721200000072120000007213000000721c0000002500000073020000000002721c00000029027221000000da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e29017211000000290272210000007227000000721200000072120000007213000000da09616c6c6f77616e63652a00000073020000000002722800000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721d0000007218000000721900000072110000002903720900000072240000007220000000721200000072120000007213000000da07617070726f76652f000000730800000000021001060114017229000000290372090000007224000000da0c6d61696e5f6163636f756e74630300000000000000040000000500000043000000738a0000007c0064016b047310740064028301820174016a027d0374037c027c03660219007c006b05733e740064036a0474037c027c03660219007c0083028301820174037c0219007c006b057352740064048301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64212905721d000000721800000072190000007211000000da06666f726d6174290472090000007224000000722a0000007220000000721200000072120000007213000000721e0000003700000073120000000002100106010a010c011201140114011001721e00000029017209000000630100000000000000020000000400000043000000732200000074008300010074016a0283007d0174037c01050019007c00370003003c006400530029014e2904da0e5f5f6173736572745f6f776e6572720f000000721a0000007211000000290272090000007221000000721200000072120000007213000000da066d696e746564440000007306000000000206010801722d00000029017208000000630100000000000000010000000200000043000000731400000074008300010074016a027c00830101006400530029014e2903722c000000720f000000721000000029017208000000721200000072120000007213000000da0c6368616e67655f6f776e65724b000000730400000000020601722e0000002903da0576616c7565da036f70747209000000630300000000000000040000000300000043000000731a00000074008300010074017c0019007d037c027c0374023c006400530029014e2903722c0000007211000000da036f74702904722f000000723000000072090000007215000000721200000072120000007213000000da0d6368616e67655f76616c7565735100000073060000000002060108017232000000630000000000000000000000000200000043000000731a00000074006a0174026a0383006b02731674046401830182016400530029024e7a174f6e6c79206f70657261746f722063616e2063616c6c21290572180000007219000000720f000000721a000000721d0000007212000000721200000072120000007213000000722c0000005800000073020000000001722c0000002914721b000000da04486173687211000000da085661726961626c65720f000000da03737472721f0000007214000000da085f5f6578706f72747223000000da05666c6f61747225000000721c00000072280000007229000000721e000000722d000000722e0000007232000000722c0000007212000000721200000072120000007213000000da083c6d6f64756c653e01000000732c00000008010e010c0310070601100e060112080601100406011204060112070601140c060110060601100506011406