![Logo](/YassineSMARA/ryu-breeding-contracts/raw/main/images/logo.gif)
The Smart-Contracts of Breeding and Potions of the RYU project
View Live Version
·
Ryu Collection
·
RyuGen2 Collection
Table of Contents
This repository contains the contracts used for the breeding of the RYU collection.
These are EVM compatible.
All contracts are upgradable due to a choice requested by the RYU team to eventually add features.
They also contain the logic of the potions used for the NFT of generation 2.
Ryu NFT is a collection of ERC721 tokens available on the Avalanche blockchain.
This one has already realized more than 10 000 $AVAX volume.
The collection sold out at 3333 NFT, the mint price was 2.22 $AVAX.
Gen1 dragons include 3234 base and 99 legendary which can breed and be staked for daily $nRyu.
By staking their Ryu Gen1 users can generate $nRyu.
$nRYU is the Gen1 staking rewards token. It's an ERC20 token.
$nRYU has a hard cap supply of 130,000,000 tokens.
The $nRYU token can be utilized on Breeding, Potions acquisitions, Gen2 Prestige system, and more.
🔍 Check the token on SnowtraceRyuGen2 is a collection of ERC721 tokens available on the Avalanche blockchain.
These tokens are only obtainable by breeding Ryu Gen1 tokens or by using potions from the lab.
The collection is capped at 9999 NFT.
Ryu Gen2 is the first generation of offspring in the Ryu Ecosystem. Stake these NFTs to earn $nRyu.
🛒 Check the collection on KalaoThe project is articulated in 3 parts that I have all imagined, created, and developed.
This choice was made to respect a budget and a deadline.
The first component of this project is smart contracts: BreedingFactory.sol
and Labs.sol
. The main function of these contracts is to set limits, restrictions, and on-chain payments ( Checking stamina, Burning $nRyu, etc...). They also allow the creation of the new ERC721 tokens.
The decision was taken to keep the metadata off-chain to be able to modify them following the uses of the potions and to avoid the problem of randomization related to the specificities of the blockchain (the attributes of the tokens of Gen2 being allotted randomly according to the attributes of the parents). Thus at the time of each use of potions / or coupling of tokens, the smart contract emits events with the data necessary for the creation of the metadata.
This is where the second component of the project comes in: the API.
This one is hosted on Heroku. Its operation is the following, with each call to know the metadata of a token the API will according to the case: create the metadata, modify the metadata or simply return them. With each creation or modification, it will save the metadata on an Amazon S3 compartment.
As for the NFT images, they have are created on the fly at each call to the API thanks to the metadata.
The third component is the Amazon S3 compartment, which is simply used to save the metadata in JSON files. When the NFT of Gen2 will have been created and all the potions will have been used the JSON file will be recovered and stored on IPFS, the URI present in the smart contract will be then modified and the data will become immutable.
Breeding dragons requires the user to have two dragons with available stamina. Dragon breeders are the only way Gen2 dragons can be born. Breeding dragons cost 2000 $nRYU.
Breeding works on a points system (P). Base dragons start with 20 points for breeding stamina, legendary dragons start with 30 points. Breeding with a legendary burns 20 points, and breeding with a base burns 10 points. Once a dragon reaches 0 points, the dragon is done breeding. Stamina is drained from Dragon A in the breeding pair. The first selected dragon is the one to lose stamina points for the production of one egg.
There is an incubation period for the Gen2 dragons. 33 days length of the incubation period, on the 33rd day, the Gen2 NFT is revealed with its traits and rarity:
- Eggs will be tradable before the incubation period is reached.
- This incubation period can be sped up by using potions.
All Possible Breeding Routes:
- A Legendary (30P) can breed 1x with another Legendary (-20P) AND 1x with a Base (-10P) = 0P A Legendary (30P) can breed 3x with a Base (-30P) = 0 P
- A Base (20P) can breed 1x with a Legendary (-20P) = 0 P
- A Base (20P) can breed 2x with another Base (-20P) = 0 P
Potions are for-pay actions on the breeding grounds page.
When buying a potion, a percentage of the cost is automatically burned and the rest sent to the treasury.
In total there are four types of potions, all with a different purpose.
Each type of potion will have a maximum of global uses. This means that only x potions can be used for the whole ecosystem.
Cost : 3300 $nRyu for the first use and 5500 $nRyu for the second.
The purpose of this potion is to reduce incubation time in half.
- The potion can be used twice and will reduce incubation time in half.
- This potion has a maximum usage of 2 for each RyuGen2 ERC721.
- This potion can only be used while the egg is hatching.
Cost : 5000 $nRyu.
The purpose of this potion is to remove all the attributes of the token except the background and its body.
- This potion can only be used 1000 times for the whole ecosystem.
- The potion can only be used once on a token from the same pair of parents including order.
- This potion can only be used once the egg has hatched.
Cost : 7500 $nRyu.
The purpose of this potion is to breed another token with the same parents without using stamina.
- This potion can only be used 3000 times for the whole ecosystem.
- The potion can only be used once on a token from the same pair of parents including order.
Cost : 15000 $nRyu.
The purpose of this potion is to create an identical copy of a RyuGen2 Token, attributes included.
- This potion can only be used 2500 times for the whole ecosystem.
- The potion can only be used once on a token from the same pair of parents including order.
To get a local copy up and running follow these simple example steps.
- npm
npm install npm@latest -g
- hardhat
npm install hardhat
- Clone the repo
git clone https://github.com/YassineSMARA/ryu-breeding-contracts.git
- Install NPM packages
npm install
- Enter your PRIVATE_KEY in
.env.example and rename the file to
.env`PRIVATE_KEY=ENTER_YOUR_PRIVATE_KEY
Try running some of the following tasks:
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
npx hardhat help
REPORT_GAS=true npx hardhat test
npx hardhat coverage
npx hardhat run scripts/deploy.ts
TS_NODE_FILES=true npx ts-node scripts/deploy.ts
npx eslint '**/*.{js,ts}'
npx eslint '**/*.{js,ts}' --fix
npx prettier '**/*.{json,sol,md}' --check
npx prettier '**/*.{json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fix
Some scripts are available for contract functions under the scripts directory.
A deployment script is also available: scripts/deployMock.ts
To run a script :
npx hardhat run scripts/SCRIPT_NAME.ts
The coverage is not 100% for the RyuGen2.sol
contract because the _burn
function is overloaded to solve the inheritance problem, but this one being internal and not being used anywhere is therefore not testable. Might be solved by using hardhat-exposed library.
Mock contracts are ignored as they are only present to simulate the smart contracts already deployed on the mainnet.
Yassine SMARA
Discord: Krabs#9454
Mail: 1yassine.smara@gmail.com