Contract con_node_test_distribution


Contract Code


  
1 import con_node_test as node
2
3 investors = Hash(default_value=0)
4
5 end_date = Variable()
6 total_tau_amount = Variable()
7 total_node_amount = Variable()
8 min_tau_amount = Variable()
9
10 @export
11 def setup(hours: int, min_tau: int, node_amount: float, this_contract: str):
12 end_date.set(now + datetime.timedelta(hours=hours))
13 total_node_amount.set(node_amount)
14 min_tau_amount.set(min_tau)
15
16 node.transfer_from(amount=node_amount, to=this_contract, main_account=ctx.caller)
17
18 @export
19 def invest(amount_tau: float):
20 assert amount_tau >= min_amount.get(), f'You need to invest at least {min_amount.get()} TAU'
21 assert end_date.get() > now, 'Investment timeframe ended'
22
23 total_tau_amount.set(total_tau_amount.get() + amount_tau)
24 investors[ctx.caller] += amount_tau
25
26 return investors[ctx.caller]
27
28 @export
29 def time_until_end():
30 return end_date.get() - now
31
32 @export
33 def withdraw_node_token():
34 assert end_date.get() < now, f'Investment time not over yet! End date is {end_date.get()}'
35 assert investors[ctx.caller] > 0, 'You do not own any NODE tokens'
36
37 tau_percent_owned = investors[ctx.caller] / total_tau_amount.get() * 100
38 node_owned = total_node_amount.get() / 100 * tau_percent_owned
39
40 node.transfer(amount=node_owned, to=ctx.caller)
41

Byte Code

e30000000000000000000000000600000040000000739c000000640064016c005a01650264006402640364048d035a0365046402640564068d025a0565046402640764068d025a0665046402640864068d025a0765046402640964068d025a08650964028301650a650a650b650c640a9c04640b640c840483015a0d650964028301650b640d9c01640e640f840483015a0e65096402830164106411840083015a0f65096402830164126413840083015a10640153002914e9000000004eda1a636f6e5f6e6f64655f746573745f646973747269627574696f6eda09696e766573746f72732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da08656e645f64617465290272050000007206000000da10746f74616c5f7461755f616d6f756e74da11746f74616c5f6e6f64655f616d6f756e74da0e6d696e5f7461755f616d6f756e742904da05686f757273da076d696e5f746175da0b6e6f64655f616d6f756e74da0d746869735f636f6e7472616374630400000000000000040000000500000043000000734000000074006a01740274036a047c0064018d0117008301010074056a017c028301010074066a017c018301010074076a087c027c0374096a0a64028d0301006400530029034e2901720b0000002903da06616d6f756e74da02746fda0c6d61696e5f6163636f756e74290bda0a5f5f656e645f64617465da03736574da036e6f77da086461746574696d65da0974696d6564656c7461da135f5f746f74616c5f6e6f64655f616d6f756e74da105f5f6d696e5f7461755f616d6f756e74da046e6f6465da0d7472616e736665725f66726f6dda03637478da0663616c6c65722904720b000000720c000000720d000000720e000000a900721d000000da00da0573657475700d000000730a000000000216010a010a010801721f0000002901da0a616d6f756e745f74617563010000000000000001000000040000004300000073620000007c0074006a0183006b0573207402640174006a0183009b0064029d038301820174036a01830074046b047334740264038301820174056a0674056a0183007c00170083010100740774086a09050019007c00370003003c00740774086a091900530029044e7a1c596f75206e65656420746f20696e76657374206174206c65617374207a04205441557a1a496e766573746d656e742074696d656672616d6520656e646564290ada0a6d696e5f616d6f756e74da03676574da0e417373657274696f6e4572726f7272120000007214000000da125f5f746f74616c5f7461755f616d6f756e747213000000da0b5f5f696e766573746f7273721b000000721c00000029017220000000721d000000721d000000721e000000da06696e7665737416000000730c00000000020e0112011401120112017226000000630000000000000000000000000200000043000000730c00000074006a01830074021800530029014e2903721200000072220000007214000000721d000000721d000000721d000000721e000000da0e74696d655f756e74696c5f656e6420000000730200000000027227000000630000000000000000020000000400000043000000736e00000074006a01830074026b00731e7403640174006a0183009b009d0283018201740474056a06190064026b0473347403640383018201740474056a06190074076a0183001b00640414007d0074086a01830064041b007c0014007d0174096a0a7c0174056a0664058d0201006400530029064e7a2a496e766573746d656e742074696d65206e6f74206f766572207965742120456e6420646174652069732072010000007a1e596f7520646f206e6f74206f776e20616e79204e4f444520746f6b656e73e9640000002902720f0000007210000000290b72120000007222000000721400000072230000007225000000721b000000721c000000722400000072170000007219000000da087472616e736665722902da117461755f70657263656e745f6f776e6564da0a6e6f64655f6f776e6564721d000000721d000000721e000000da1377697468647261775f6e6f64655f746f6b656e25000000730c000000000206011801160216011001722c0000002911da0d636f6e5f6e6f64655f746573747219000000da04486173687225000000da085661726961626c657212000000722400000072170000007218000000da085f5f6578706f7274da03696e74da05666c6f6174da03737472721f00000072260000007227000000722c000000721d000000721d000000721d000000721e000000da083c6d6f64756c653e01000000731e0000000801060108010c0104010801040108010401080306011608060110091005