Contract con_uw_presale_alpha


Contract Code

1 import currency
2 import con_uwarriors_lst001
3
4 metadata = Hash(default_value=0)
5 balances = Hash(default_value=0)
6 wp = ForeignHash(foreign_contract='con_uwarriors_lst001', foreign_name='balances')
7
8 @construct
9 def seed():
10 metadata['operator'] = ctx.caller
11 metadata['characters'] = ['ALPHA']
12 metadata['price'] = 6000
13 metadata['max'] = 40
14
15
16 @export
17 def buy_presale(option: int):
18 sender = ctx.caller
19 character = metadata['characters']
20 assert wp[sender] >= metadata['price'], 'Not enough coins to send!'
21 assert balances['count', character[option]] <= metadata['max'] , 'Presale end!'
22
23 con_uwarriors_lst001.transfer_from(metadata['price'], metadata['operator'], sender)
24 balances['count', character[option]] +=1
25
26 return character[option]
27
28
29 @export
30 def change_characters(value: list):
31 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
32 metadata['characters'] = value
33
34 @export
35 def change_price(value: int):
36 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
37 metadata['price'] = value
38
39 @export
40 def change_max(value: int):
41 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
42 metadata['max'] = value
43

Byte Code

e3000000000000000000000000060000004000000073a0000000640064016c005a00640064016c015a01650264006402640364048d035a03650264006402640564048d035a046505640664056402640764088d045a066409640a84005a076508640283016509640b9c01640c640d840483015a0a650864028301650b640e9c01640f6410840483015a0c6508640283016509640e9c0164116412840483015a0d6508640283016509640e9c0164136414840483015a0e640153002915e9000000004eda14636f6e5f75775f70726573616c655f616c706861da086d657461646174612903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da0862616c616e636573da14636f6e5f7577617272696f72735f6c7374303031da0277702904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572050000007206000000630000000000000000000000000300000043000000732800000074006a01740264013c0064026701740264033c006404740264053c006406740264073c006400530029084eda086f70657261746f72da05414c504841da0a636861726163746572736970170000da057072696365e928000000da036d61782903da03637478da0663616c6c6572da0a5f5f6d65746164617461a90072150000007215000000da00da045f5f5f5f0b000000730800000000010a010a01080172170000002901da066f7074696f6e630100000000000000030000000400000043000000737c00000074006a017d017402640119007d0274037c0119007402640219006b0573267404640383018201740564047c027c001900660219007402640519006b017346740464068301820174066a077402640219007402640719007c0183030100740564047c027c0019006602050019006408370003003c007c027c001900530029094e720e000000720f0000007a194e6f7420656e6f75676820636f696e7320746f2073656e6421da05636f756e7472110000007a0c50726573616c6520656e6421720c000000e9010000002908721200000072130000007214000000da045f5f7770da0e417373657274696f6e4572726f72da0a5f5f62616c616e6365737208000000da0d7472616e736665725f66726f6d29037218000000da0673656e646572da09636861726163746572721500000072150000007216000000da0b6275795f70726573616c6512000000731200000000020601080118011a0106010c010a01180172210000002901da0576616c7565630100000000000000010000000300000043000000732200000074006a017402640119006b02731674036402830182017c00740264033c006400530029044e720c0000007a1f4f6e6c79206f70657261746f722063616e20736574206d6574616461746121720e0000002904721200000072130000007214000000721c00000029017222000000721500000072150000007216000000da116368616e67655f636861726163746572731f00000073060000000002100106017223000000630100000000000000010000000300000043000000732200000074006a017402640119006b02731674036402830182017c00740264033c006400530029044e720c0000007a1f4f6e6c79206f70657261746f722063616e20736574206d6574616461746121720f0000002904721200000072130000007214000000721c00000029017222000000721500000072150000007216000000da0c6368616e67655f70726963652600000073060000000002100106017224000000630100000000000000010000000300000043000000732200000074006a017402640119006b02731674036402830182017c00740264033c006400530029044e720c0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612172110000002904721200000072130000007214000000721c00000029017222000000721500000072150000007216000000da0a6368616e67655f6d61782d00000073060000000002100106017225000000290fda0863757272656e63797208000000da04486173687214000000721d000000da0b466f726569676e48617368721b0000007217000000da085f5f6578706f7274da03696e747221000000da046c6973747223000000722400000072250000007215000000721500000072150000007216000000da083c6d6f64756c653e01000000732000000008010801060108010601080104010c0308070601100c06011006060110060601