The World Of Ledger Game (made according to LedgerHQ exercise)
Created using Brownie v1.19.2 and Python 3.10
There are two prerequisites we need before deploying the contract:
- Boss contract address. You can use any ERC-721 contract while deploying, however it should have tokenURI and totalSupply functions;
- VRFV2Coordinator address, Key hash, Link token address. As the contract uses chainlink random number generator for character generation, you need to provide these data to work correctly. Please refer to Chainlink docs
You have to create and fund chainlink subscription with some Link tokens. Players won't be able to generate new Characters without funded subscription.
You have to:
- Give contract approval to use your Link tokens.
- Use fundSubscription function of the contract.
It is possibally to cancel subscription and get your Link tokens back at any time. However, you won't be able to fund it anymore and thus create new characters for the game.
-
Users may generate characters with random HP and Damage (NOTE createRandomCharacter function will require some time for Chainlink nodes to generate random numers)
-
Owner of the contract may create boss;
-
Users may attack boss with their character and able to claim rewards of defeated bosses;
-
Characters level is calculated according to formula: sqrt(xp) * 20 / 100;
-
Everytime a player attack the boss, the boss will counterattack the player. Both will loose life points;
-
Default requirement for heal spell - 2, firebolt spell - 3. May be changed by the contract owner;
-
Default cooldown period for firebolt spell - 1 day. May be changed by the contract owner;
-
Firebolt cast twice more damage then basic attack of the charater;
-
Heal spell heals the same amount of hp as the basic attack of the character;
-
Players can mint NFT after bosses defeat;
The example contract deployed on Goerli chain - 0xCa5514eF8426D4cd09BAB16Fb03dC6Ce6267a1Ae)