Contract con_launchpad_1


Contract Code


  
1 # Launchpad v1.0 without MOBGOV features
2 # Token Creator creates a token and puts amount of token up for sale.
3 # He will need to set a token contract, start, end time, hardcap, tokens for sale and maximum buy.
4 # People can invest TAU
5 # If end time reached and softcap reached - Make tokens available to claim
6 # If hardcap reached - Make tokens available to claim
7 # If endtime reached and softcap not reached - Refund TAU, Refund Tokens to Creator
8 #
9 #
10
11 I = importlib
12 random.seed() # To generate somewhat unique token sale id
13
14 token_sales = Hash(default_value=0)
15 investments = Hash(default_value=0)
16
17 sales = Variable() # IDs of all sales for listing on website
18
19 end_fee = Variable() # Only if sale is successful then fee of raised money
20 operator = Variable() # DEV can help while the sale is running if its a scam or something
21
22
23 @construct
24 def seed():
25 end_fee.set(5)
26 operator.set(
27 "ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89")
28 sales.set("")
29
30
31 @export
32 def create_sale(start_date_day: int, start_date_month: int, start_date_year: int, start_date_hour: int, start_date_minute: int, softcap: float, hardcap: float, max_buy: float, tokens_for_sale: float, token_contract: str, end_date_day: int, end_date_month: int, end_date_year: int, end_date_hour: int, end_date_minute: int):
33 token_sale_id = str(random.randint(0, 100000000))
34 if(token_sale_id not in sales.get().split(',')):
35 I.import_module(token_contract).transfer_from(
36 main_account=ctx.caller,
37 amount=tokens_for_sale,
38 to=ctx.this)
39 token_sales[token_sale_id] = {"start_date": datetime.datetime(start_date_year, start_date_month, start_date_day, start_date_hour, start_date_minute), "end_date": datetime.datetime(
40 end_date_year, end_date_month, end_date_day, end_date_hour, end_date_minute), "softcap": softcap, "hardcap": hardcap, "max_buy": max_buy, "raised": 0, "tokens_for_sale": tokens_for_sale, "token_contract": token_contract, "seller": ctx.caller, "finalized": False}
41 sales.set(sales.get() + "," + token_sale_id)
42 return "Try again"
43
44 @export
45 def finalize(token_sale_id: str):
46 assert token_sales[token_sale_id]["finalized"] == False, "This sale is already finalized"
47 assert token_sales[token_sale_id]["end_date"] <= now, "The sale can only be finalized when the end date is reached"
48 assert token_sales[token_sale_id]["seller"] == ctx.caller or ctx.caller == operator.get(), "The sale can only be finalized by the seller"
49 token_sales[token_sale_id]["finalized"] = True

Byte Code

e3000000000000000000000000110000004000000073a000000065005a0165026a0383000100650464006401640264038d035a05650464006401640464038d035a0665076401640564068d025a0865076401640764068d025a0965076401640864068d025a0a6409640a84005a0b650c64018301650d650d650d650d650d650e650e650e650e650f650d650d650d650d650d640b9c0f640c640d840483015a10650c64018301650f640e9c01640f6410840483015a11641153002912e900000000da0f636f6e5f6c61756e63687061645f31da0b746f6b656e5f73616c65732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da0b696e766573746d656e7473da0573616c6573290272050000007206000000da07656e645f666565da086f70657261746f72630000000000000000000000000200000043000000732200000074006a0164018301010074026a0164028301010074036a016403830101006400530029044ee905000000da4066663631353434656139346561616562356466303865643836336334613933386539313239616261366365656535663331623636383162646564653131623839da002904da095f5f656e645f666565da03736574da0a5f5f6f70657261746f72da075f5f73616c6573a90072120000007212000000720d000000da045f5f5f5f0c000000730800000000010a01040106017213000000290fda0e73746172745f646174655f646179da1073746172745f646174655f6d6f6e7468da0f73746172745f646174655f79656172da0f73746172745f646174655f686f7572da1173746172745f646174655f6d696e757465da07736f6674636170da0768617264636170da076d61785f627579da0f746f6b656e735f666f725f73616c65da0e746f6b656e5f636f6e7472616374da0c656e645f646174655f646179da0e656e645f646174655f6d6f6e7468da0d656e645f646174655f79656172da0d656e645f646174655f686f7572da0f656e645f646174655f6d696e757465630f00000000000000100000000b000000430000007392000000740074016a0264016402830283017d0f7c0f74036a0483006a05640383016b07728e74066a077c0983016a0874096a0a7c0874096a0b64048d030100740c6a0c7c027c017c007c037c048305740c6a0c7c0c7c0b7c0a7c0d7c0e83057c057c067c0764017c087c0974096a0a640564069c0a740d7c0f3c0074036a0e74036a048300640317007c0f1700830101006407530029084e72010000006900e1f505fa012c2903da0c6d61696e5f6163636f756e74da06616d6f756e74da02746f46290ada0a73746172745f64617465da08656e645f646174657219000000721a000000721b000000da06726169736564721c000000721d000000da0673656c6c6572da0966696e616c697a65647a0954727920616761696e290fda03737472da0672616e646f6dda0772616e64696e747211000000da03676574da0573706c6974da0149da0d696d706f72745f6d6f64756c65da0d7472616e736665725f66726f6dda03637478da0663616c6c6572da0474686973da086461746574696d65da0d5f5f746f6b656e5f73616c6573720f0000002910721400000072150000007216000000721700000072180000007219000000721a000000721b000000721c000000721d000000721e000000721f000000722000000072210000007222000000da0d746f6b656e5f73616c655f696472120000007212000000720d000000da0b6372656174655f73616c6513000000731c0000000006100112010e010c01040106010a01060108010601040110011601723a00000029017239000000630100000000000000010000000300000043000000736800000074007c0019006401190064026b027318740164038301820174007c0019006404190074026b017330740164058301820174007c0019006406190074036a046b02735874036a0474056a0683006b0273587401640783018201640874007c00190064013c006400530029094e722b000000467a1e546869732073616c6520697320616c72656164792066696e616c697a656472280000007a3b5468652073616c652063616e206f6e6c792062652066696e616c697a6564207768656e2074686520656e6420646174652069732072656163686564722a0000007a2c5468652073616c652063616e206f6e6c792062652066696e616c697a6564206279207468652073656c6c65725429077238000000da0e417373657274696f6e4572726f72da036e6f77723400000072350000007210000000722f0000002901723900000072120000007212000000720d000000da0866696e616c697a6529000000731000000000020a010e010a010e010a0118010601723d0000004e2912da09696d706f72746c69627231000000722d000000da0473656564da04486173687238000000da0d5f5f696e766573746d656e7473da085661726961626c657211000000720e00000072100000007213000000da085f5f6578706f7274da03696e74da05666c6f6174722c000000723a000000723d000000721200000072120000007212000000720d000000da083c6d6f64756c653e0100000073220000000401080106010801060108010c010c010c0308070601040108010601080112110601