Skip to content

For developers: launching the application

eg edited this page Aug 30, 2023 · 5 revisions

Requirements

Clone repository

git clone https://github.com/Mycelium-Lab/FairFight

Launching local blockchain and deploy contracts

Switch terminal directory to evm

cd PATH/TO/FairFight/evm

Create .env file and add your PRIVATE_KEY (PRIVATE_KEY_EMERALD can be the same)

PRIVATE_KEY=""
PRIVATE_KEY_EMERALD=""

Install dependencies

npm install

Run local blockchain

npx hardhat node

In the different terminal deploy smart contracts in this sequences so that the address of contracts on the test network does not have to be changed

npx hardhat run scripts/FairFight/deployWithTestToken.js --network testnet
npx hardhat run scripts/FairFight/mintTestToken.js --network testnet
npx hardhat run scripts/FairFight/NFT/deployTest.js --network testnet
npx hardhat run scripts/Lootbox/deployTest.js --network testnet

Launching database and cache server

Create database in PostgreSQL and fill it with data from the file tables.sql in psql terminal.

\i PATH/TO/FairFight/tables.sql

Run redis-server

On Linux

sudo systemctl start redis

Launching server and game

Create .env file in the base directory with this data

DB from your PostgreSQL, PRIVATE_KEY_EMERALD and PRIVATE_KEY_TEST can be the same as PRIVATE_KEY

DB=""
DB_USER=""
DB_PASSWORD=""
REDIS_HOST=""
REDIS_PORT=""
PRIVATE_KEY=""
PRIVATE_KEY_EMERALD=""
PRIVATE_KEY_TEST=""

Install dependencies in base directory

npm install

Run server

  1. Development
npm run dev:se

In the different terminal

npm run dev:si
  1. Production

Install pm2

npm install pm2 -g

Run game

npm run prod

Import in your Metamask Wallet Private Key from local blockchain

GAME IS STARTED ON http://localhost:5000/?network=31337 (network=31337 means local hardhat node)

Also for frontend development

If your changing JS files in lib directory except for /lib/game than you should launch webpack

Launching webpack

Go to lib directory

Install dependencies

npm install

Run webpack in watch mode

npm run watch

or just build

npm run build