Installation
Installation of the Smartcontracts

Prerequirements

Smartcontracts are running inside the Docker container and uses the Hardhat framework.
Therefore, the local computer that wants to install the Smartcontracts has to be with Installed docker and docker-compose.
Once installed, the terminal should show that docker and docker-compose commands are available:
1
C:\Users\alp> docker version
2
Client: Docker Engine - Community
3
Cloud integration: 1.0.12
4
Version: 20.10.5
5
API version: 1.41
6
Go version: go1.13.15
7
Git commit: 55c4c88
8
Built: Tue Mar 2 20:14:53 2021
9
OS/Arch: windows/amd64
10
Context: default
11
Experimental: true
12
13
Server: Docker Engine - Community
14
Engine:
15
Version: 20.10.5
16
API version: 1.41 (minimum version 1.12)
17
Go version: go1.13.15
18
Git commit: 363e9a8
19
Built: Tue Mar 2 20:15:47 2021
20
OS/Arch: linux/amd64
21
Experimental: false
22
containerd:
23
Version: 1.4.4
24
GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
25
runc:
26
Version: 1.0.0-rc93
27
GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
28
docker-init:
29
Version: 0.19.0
30
GitCommit: de40ad0
Copied!
1
C:\Users\alp> docker-compose version
2
docker-compose version 1.29.0, build 07737305
3
docker-py version: 5.0.0
4
CPython version: 3.9.0
5
OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
Copied!
Next required Program is a Git Client. I would recommend GitKraken or Fork with a nice GUI.
Upon installation of Git, you can clone the Lighthouse Github repository into your computer:

Installation

Open in the terminal the folder of the Lighthouse Smartcontracts: Then create .env file with the following key values:
/home/lighthouse-smartcontracts/.env
1
MOONBEAM_DEPLOYER_ADDRESS=<wallet address>
2
MOONBEAM_DEPLOYER_KEY=<wallet privatekey>
3
MOONBEAM_REMOTE_HTTP=<RPC endpoint of the Node>
Copied!
Here: MOONBEAM_DEPLOYER_ADRESS is Wallet Address of Claim verifier. MOONBEAM_DEPLOYER_KEY is the Wallet's private key that will deploy contracts on the Network. MOONBEAM_REMOTE_HTTP is the HTTPS URL of Moonbeam node.
The wallet address, privatekey or remote HTTP nodes could be any wallets or node's url.
For Moonbeam and Moonriver Networks, its recommended to use https://app.onfinality.io/login rather than Official Public RPC nodes.
After installation, you can run the Docker compose to set up the Smartcontracts. The first setup will take some time, as it downloads the dependencies from the network:
1
C:\Users\alp\lighthouse-contracts> docker-compose up -d
2
Docker Compose is now in the Docker CLI, try `docker compose up`
3
4
Building lighthouse-contract
5
failed to get console mode for stdout: The handle is invalid.
6
[+] Building 1.3s (12/12) FINISHED
7
=> [internal] load build definition from Dockerfile 0.0s
8
=> => transferring dockerfile: 32B 0.0s
9
=> [internal] load .dockerignore 0.0s
10
=> => transferring context: 2B 0.0s
11
=> [internal] load metadata for docker.io/library/node:14.13.1 1.3s
12
=> [1/7] FROM docker.io/library/node:[email protected]:2d1077c78724caf4f8bb 0.0s
13
=> [internal] load build context 0.0s
14
=> => transferring context: 34B 0.0s
15
=> CACHED [2/7] RUN apt-get update 0.0s
16
=> CACHED [3/7] RUN apt-get install --yes build-essential inotify-tools 0.0s
17
=> CACHED [4/7] WORKDIR /home/node/app 0.0s
18
=> CACHED [5/7] COPY ./package.json /home/node/app/package.json 0.0s
19
=> CACHED [6/7] RUN npm install --save-dev "[email protected]^2.6.2" 0.0s
20
=> CACHED [7/7] RUN npm install 0.0s
21
=> exporting to image 0.0s
22
=> => exporting layers 0.0s
23
=> => writing image sha256:b2125f9b1625bf8c56e6573e7d0324971a6e34a7a5109 0.0s
24
=> => naming to docker.io/library/lighthouse-contracts_lighthouse-contra 0.0s
25
26
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
27
Successfully built b2125f9b1625bf8c56e6573e7d0324971a6e34a7a5109cce7fe4a75fd3c0faf0
28
WARNING: Image for service lighthouse-contract was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
29
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
30
Creating lighthouse-contract ... done
Copied!

Commands

In order to interact with Smartcontracts, please enter into the Container:
1
C:\Users\alp\lighthouse-contracts> docker exec -it lighthouse-smartcontract bash
2
[email protected]:/home/node/app#
Copied!
This will enter into the Container. As Lighthouse smartcontracts built with Hardhat, the commands to compiling smartcontracts, deploying smartcontracts, testing or running scripts are done via Hardhat command line tool.
Here are the most common commands:

Compile

1
[email protected]:/home/node/app# npx hardhat compile
2
Downloading compiler 0.8.0
3
Compiling 8 files with 0.8.0
4
Compilation finished successfully
Copied!
npx hardhat compile compiles Solidity files. For more info about compiling at Hardhat Compiling Docs.

Deploy

1
[email protected]:/home/node/app# npx hardhat run scripts/deploy-tier.js --network moonbeam
2
Lighthouse Tier deployed to: 0xaba7a46B9E46CdDa4B1f25e40bF691F45dA09c04
Copied!
We run the scripts defined in scripts/ folder. The deployment scripts have deploy- prefix. Visit the deployment scripts and change the parameters passed to constructors. For example above command deployes LighthouseTier.sol contract.
Additionally we pass a --network argument with the network name. To change network settings or toadd another Blockchain networks (Such as Ethereum Mainnet, Ethereum Rinkeby Testnet) you can edit hardhat.config.js file inside the root folder.
For more info about deploying contracts at Hardhat Deploying Docs.

Test

1
[email protected]:/home/node/app# npx hardhat test tests/1-tier.js
2
3
4
Lighthouse Tier
5
✓ initiates the contracts and set the tier user to game owner. (13970ms)
6
✓ should fail to claim tier 1, before claiming tier 0 (8037ms)
7
✓ should claim tier 0 (4028ms)
8
✓ should claim tier 1 (4028ms)
9
✓ should fail to claim tier 0 after claiming tier 1
10
✓ should fail to re-claim tier 1, when tier 1 is usable by tier user (4006ms)
11
✓ uses the tier (4019ms)
12
✓ can not claim any tier except used tier, which is tier 1 (4017ms)
13
✓ re-claims tier 1 which is used (4023ms)
14
✓ should fail to claim tier 3, since tier 2 not claimed (4015ms)
15
✓ claim tier 2 (4020ms)
16
✓ claim tier 3 (4025ms)
17
✓ should fail to claim non existing tier 4
18
✓ should set fees (8035ms)
19
✓ should set claim verifier (8025ms)
20
✓ should add tier editor (8024ms)
21
✓ should delete editor (8026ms)
22
23
24
17 passing (2m)
Copied!
Testing contracts are done via calling npx hardhat test command by passing test script file. In Lighthouse tests are enumerated with number prefix. For example tests/1-tier.js is the LighthouseTier.sol smartcontract's Tests.
For more info about testings using Hardhat visit Hardhat Testing with ethers.js and Waffle Docs.
Last modified 2mo ago