The guide of smartcontracts
Understanding Lighthouse Smartcontracts.
The lighthouse Tiers are separated project on its own from Rest of the Lighthouse smartcontracts.
Tiers - Each Lighthouse user should have a Tier to use Lighthouse. The Tiers logic is stored in
contracts/LighthouseTier.sol. The tier is the first thing that user interacts with. It is claimed by passing certain requirements. Though each tier is one time usable only. So, if user used the Tier in Lighthouse, then he has to re-claim the Tier one more time.
Projects are ideas that are looking for funds. Users with Tiers are allowed to participate in the project funding. The projects are added into Lighthouse by Lighthouse admins (basically owners of the Lighthouse Smartcontracts). All project fundings have the same phases, that Lighthouse admins are configuring for each project. All project data is stored in
contracts/LighthouseProject.sol. Let's do it with the example project.
Funds needed: 10,000 USD. Funds collected in: USDT Game Token: Elements (ELEMENT)
Now, let's define sample Example of Project phases
First phase is the Lottery registration. For Element Words registration goes from 25th September to 30th September in 2021.
initRegistration(uint256 startTime, uint256 endTime)
To setup registration we call
initRegistrationfunction. This function has to be called firstly for any project in Lighthouse. Because this function also creates a Project ID to use within Lighthouse Smartcontracts.
Again, users with only Tiers could participate in the Project Lottery.
All users have to participate in the Lottery.
After setting Project's registration, the Registration client for users will be available between 25th and 30th September. Users can interact with Project Registration in
Users have to call
registerfunction of Client Smartcontract for Registration.
Once registration for Lottery is done, the Server picks random Lottery winners. The winners are eligble to participate in the second phase of Project Fundraising, which is Prefund.
Prefund phase also goes in certain time. For our example project Element Words it goes from 1st October to 7th October.
For prefund we have to determine the Stable coin we collect, amount of stable coins that Each Tier user could invest, and total amount of Stable Coins that we are collecting in Prefund phase.
For Element Words we collect USDT. A Tier 1 user could invest 500, Tier 2 user could invest 1000 and Tier 3 user could invest 2000 USDT into the project. Element Words is collecting 10,000 US Dollars, where we collect 2000 from Tier 1 users, 3000 from Tier 2 users and 5000 from Tier 3 users.
In order to enable users to fund the project, the Lighthouse admin has to set the prefund phase of the Project by calling
uint256 startTime, uint256 endTime,
uint256 calldata investAmounts,
uint256 calldata pools,
After successfully initiation of the Prefund, users could invest in Presale from Client Smartcontract for Prefunding:
prefund(uint256 projectId, int8 certainTier, uint8 v, bytes32 r, bytes32 s)
For calling Client martcontract, the user has to get Signature from Server that prooves Lottery win of user.
After end of Prefunding, we are starting a public sale of project tokens for a limited time. For Element Words it will be hosted between 9th October to 10h October.
In Auction, anyone could spend Crowns Token of any size. The amount of spent tokens determines his share of getting Element Words' Tokens.
In order to enable Public Auction, the Lighthouse admin has to execute
initAuction(uint256 projectId, uint256 startTime, uint256 endTime)
After successful execution, the user could spend his Crowns on 9th October:
participate(uint256 projectId, uint256 amount, uint8 v, bytes32 r, bytes32 s)
The user has to get a signature from a server that prooves that user is eligible for Auction.
After end of Fundraising, its time for users to get their Funds. Users are getting NFTs that they could burn for Project token, which is called Player Created Coin (PCC). If the project fails, users could get Crowns as a compensation token, again by burning their NFTs.
So first thing to do is to Deploy Special Project's Investment NFT. Then the Lighthouse admin needs to do is add PCC and Crowns compensation for Prefund and Auction sale.
For Element Words the reward details are like this:
PCC: Elements Prefund Allocation: 100,000 Elements Prefund Compensation: 2000 CWS Auction Allocation: 20,000 Elements Auction Compensation: 400 CWS
Then, add the info about allocation in Project smartcontract:
After setting allocation and compensation, users can Mint the Reward NFTs on client Smartcontract for Minting:
Now, after funds were collected, the next step that Lighthouse team is doing is to deploy the PCC token.
For Element Words, the PCC is Elements token.
Then, admins have to set the PCC address of the project by calling
setPcc(uint256 projectId, address pccAddress)
Then, admin has to transfer Allocation amount and Crowns amount to the Lighthouse Client for claiming rewards:
Users can call two functions in the Lighthouse Client for claiming nfts:
burnForPcc(uint256 projectId, uint256 nftId)
burnForCws(uint256 projectId, uint256 nftId)