OpenTezos offers great documentation so we will use it as a reference: https://opentezos.com/ligo/installation
- You may simply execute LIGO through Docker to run the ligo CLI :
docker run --rm -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:0.30.0 [command without "ligo"]
Example:
- To compile a smart-contract, you may use:
docker run --rm -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:0.30.0 compile contract [args]
The list of ligo CLI is available on LIGOland: https://ligolang.org/docs/api/cli-commands/
Node 14 or higher is required to run the originate function.
- Go to https://nodejs.org/en/download/ and choose "macOS Installer". Follow the instructions on the wizard. Once it is complete, to check that the installation was successful :
- run
node -v
- run
npm -v
- Open your terminal, and run: sudo apt update sudo apt install nodejs npm Once it is complete, to check that the installation was successful, run:
- run
node -v
- run
npm -v
cf. https://opentezos.com/dapp/taquito
- You may download from Python (https://wiki.python.org/moin/BeginnersGuide/Download) or install it from the CLI.
- You may use python3.
cf. https://pypi.org/project/pytezos/
- At root, with the last LIGO version run
ligo compile contract src/contract/farm/main.mligo > src/contract/test/compiled/farm.tz
- OR with docker run
docker run --rm -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:0.30.0 compile contract src/contract/farm/main.mligo -e main > src/contract/test/compiled/farm.tz
- At root, with the latest LIGO version run
ligo compile contract src/contract/database/main.mligo > src/contract/test/compiled/database.tz
- OR with docker run
docker run --rm -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:0.30.0 compile contract src/contract/database/main.mligo -e main > src/contract/test/compiled/database.tz
- In the contract/test/ repository, run
pytest [-k "filename"] [-s]
- OR If you want to have more verbose run
python3 -m unittest test_farm.py -v
for Farm tests orpython3 -m unittest test_database.py -v
for Database tests - OR If you want to run a specific test, run
python3 -m unittest test_farm.py -v -k 'test_initializeReward_5week_20Kreward_75rate_initialization_should_work'
-
Create the database initial storage artefact : at root, run
docker run --rm -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:0.30.0 compile contract src/contract/database/main.mligo --michelson-format json > deploy/artefact/database.json
-
Create the farm initial storage artefact : at root, run
docker run --rm -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:0.30.0 compile contract src/contract/farm/main.mligo --michelson-format json > deploy/artefact/farm.json
-
Install dependencies, go to the /deploy folder and run
npm install
Adapt your .env file in the /deploy folder:
PK=[private key]
ADMIN=[admin address]
SMAK=[SMAK token contract address]
RPC=[network]
FARMSDB=[Farms contract address]
LP=[LP token address]
INFOFARM=[name of the LP pair]
RATE=[decreasing rate x10000]
REWARDS=[number of SMAK tokens as rewards for the entire farm lifetime]
WEEKS=[length of the farm lifetime]
-
In the folder /deploy, run
tsc deploy.ts --resolveJsonModule -esModuleInterop
-
Be sure to compile your database and farm, following III.1 and III.2 The database contract reference all farm pools and is only needed to be generated once at the start of the project.
-
In the folder /deploy, run
node deploy_database.js
.
- In the folder /deploy, run
node deploy_farm.js
. ( check again your environment variables )
It will:
- originate a new farm contract with the storage in the .ts file
- call the entrypoint increaseReward (with 0 as argument)
- approve the newly created farm smart-contract to spend SMAK for the amount in total_reward (will allow to transfer some SMAK tokens to the claiming users)
- call the entrypoint addFarm in the FARMS contract to register the newly created farm
The front-end will call the entry point approve on the LP token contract in order to allow the farm contract to use LP tokens owned by the user.