Smartcontrontracts

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

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.

As the example project we will use Element Words game.

Funds needed: 10,000 USD. Funds collected in: USDT Game Token: Elements (ELEMENT)

Now, let's define sample Example of Project phases

0. Registration

First phase is the Lottery registration. For Element Words registration goes from 25th September to 30th September in 2021.

contracts/LighthouseProject.sol
initRegistration(uint256 startTime, uint256 endTime)

To setup registration we call initRegistration function. 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 contracts/LighthouseRegistration.sol.

contracts/LighthouseRegistration.sol
register(uint256 projectId)

Users have to call register function of Client Smartcontract for Registration.

1. Prefund

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 initPrefund function:

contracts/LighthouseProject.sol
initPrefund(uint256 projectId, 
            uint256 startTime, uint256 endTime, 
            uint256[3] calldata investAmounts, 
            uint256[3] calldata pools, 
            address _token)

After successfully initiation of the Prefund, users could invest in Presale from Client Smartcontract for Prefunding:

contracts/LighthousePrefund.sol
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.

2. Auction

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 function:

contracts/LighthouseProject.sol
initAuction(uint256 projectId, uint256 startTime, uint256 endTime)

After successful execution, the user could spend his Crowns on 9th October:

contracts/LighthouseAuction.sol
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.

3. Reward

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:

contracts/LighthouseProject.sol
initAllocationCompensation(
            uint256 projectId, 
            uint256 prefundAllocation, 
            uint256 prefundCompensation, 
            uint256 auctionAllocation, 
            uint256 auctionCompensation, 
            address nftAddress)

After setting allocation and compensation, users can Mint the Reward NFTs on client Smartcontract for Minting:

contracts/LighthouseMint.sol
mint(uint256 projectId)

4. Reward Claim

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 function:

contracts/LighthouseProject.sol
setPcc(uint256 projectId, address pccAddress)

Then, admin has to transfer Allocation amount and Crowns amount to the Lighthouse Client for claiming rewards: contracts/LighthouseBurn.sol.

Users can call two functions in the Lighthouse Client for claiming nfts:

contracts/LighthouseBurn.sol
burnForPcc(uint256 projectId, uint256 nftId)

Last updated