/// <summary> /// initialise the smart contract for use /// </summary> /// <returns></returns> public static bool InitSmartContract() { if (Helpers.ContractInitialised()) { // contract can only be initialised once Runtime.Log("InitSmartContract() contract already initialised"); return(false); } uint ContractInitTime = Helpers.GetBlockTimestamp(); Storage.Put(Storage.CurrentContext, StorageKeys.ContractInitTime(), ContractInitTime); // assign pre-allocated tokens to the project object[] immediateAllocation = ICOContract.ImmediateProjectGrowthAllocation(); object[] vestedAllocation = ICOContract.VestedProjectGrowthAllocation(); BigInteger immediateProjectAllocationValue = ((ICOContract.TokenMaxSupply * (BigInteger)immediateAllocation[0]) / 100) * NEP5.factor; BigInteger vestedProjectAllocationValue = ((ICOContract.TokenMaxSupply * (BigInteger)vestedAllocation[0]) / 100) * NEP5.factor; Helpers.SetBalanceOf(ICOContract.MoonlightProjectKey(), immediateProjectAllocationValue + vestedProjectAllocationValue); Helpers.SetBalanceOfVestedAmount(ICOContract.MoonlightProjectKey(), immediateProjectAllocationValue + vestedProjectAllocationValue); // lockup a portion of the tokens to be released in the future uint vestedGrowthReleaseDate = (uint)vestedAllocation[1] + ContractInitTime; object[] vestedTokenPeriod = new object[] { vestedGrowthReleaseDate, vestedProjectAllocationValue }; StorageMap vestingData = Storage.CurrentContext.CreateMap(StorageKeys.VestedTokenPrefix()); vestingData.Put(ICOContract.MoonlightProjectKey(), vestedTokenPeriod.Serialize()); // token allocation to MoonlightFounderKeys - update the total supply to include balance - these funds will be unlocked gradually BigInteger founderTokenAllocation = ((ICOContract.TokenMaxSupply * (BigInteger)ICOContract.MoonlightFoundersAllocationPercentage()) / 100) * NEP5.factor; // token allocated to presale BigInteger presaleAllocationMaxValue = ((ICOContract.TokenMaxSupply * (BigInteger)ICOContract.PresaleAllocationPercentage()) / 100) * NEP5.factor; // update the total supply to reflect the project allocated tokens BigInteger totalSupply = immediateProjectAllocationValue + vestedProjectAllocationValue + founderTokenAllocation + presaleAllocationMaxValue; Helpers.SetTotalSupply(totalSupply); UpdateAdminAddress(ICOContract.InitialAdminAccount); EnableDEXWhitelisting(ICOContract.WhitelistDEXListings()); Runtime.Log("InitSmartContract() contract initialisation complete"); return(true); }
/// <summary> /// initialise the smart contract for use /// </summary> /// <returns></returns> public static bool InitSmartContract() { if (Helpers.ContractInitialised()) { // contract can only be initialised once Runtime.Log("InitSmartContract() contract already initialised"); return(false); } uint ContractInitTime = Helpers.GetBlockTimestamp(); Storage.Put(Storage.CurrentContext, StorageKeys.ContractInitTime(), ContractInitTime); // assign pre-allocated tokens to the NosProjectKey() (10,000,000 tokens) BigInteger immediateProjectAllocationValue = ICOTemplate.ImmediateCompanyReserve() * NEP5.factor; Helpers.SetBalanceOf(ICOTemplate.NosProjectKey, immediateProjectAllocationValue); transfer(null, ICOTemplate.NosProjectKey, immediateProjectAllocationValue); // token allocated to private sale & vested reserves & incentives BigInteger presaleAllocationMaxValue = ICOTemplate.LockedTokenAllocationAmount() * NEP5.factor; // update the total supply to reflect the project allocated tokens BigInteger totalSupply = immediateProjectAllocationValue + presaleAllocationMaxValue; Helpers.SetTotalSupply(totalSupply); UpdateAdminAddress(ICOTemplate.InitialAdminAccount); EnableTransferFromWhitelisting(ICOTemplate.WhitelistTransferFromListings()); Runtime.Log("InitSmartContract() contract initialisation complete"); return(true); }
/// <summary> /// determine if the contract has been previously initialised /// </summary> /// <returns></returns> public static bool ContractInitialised() { return(Storage.Get(Storage.CurrentContext, StorageKeys.ContractInitTime()).AsBigInteger() > 0); }
/// <summary> /// get the time the contract was first initialised /// </summary> /// <returns></returns> public static uint GetContractInitTime() { return((uint)Storage.Get(Storage.CurrentContext, StorageKeys.ContractInitTime()).AsBigInteger()); }