- Player can connect to the mini game using Metamask on Mumbai Network
- Players can choose Valorant Heroes and mint them as an NFT
- Use the minted Hero NFT to battle against Thanos in the dapp
- Battling against Thanos changes the HP (On-Chain Metadata) of Hero NFT
- Players can heal their heroes by staking their Hero NFT in the dapp
- Staking NFTs increase the HP (On-Chain Metadata) of Hero NFT.
- Players can lend and rent NFTs from the Collateral-Free NFT Rental Marketplace
- Players can earn MATIC by lending their NFTs
- NFTs can be rented from the Rental Marketplace by specifying the rental duration and paying the rental amount in MATIC
- Players can use the rented NFTs to battle with Thanos
- Renters will not be able to transfer or stake the Rented NFTs
- Lenders can claim back the Lent NFTs from the renter once the rental period expires
backend/contracts
โฉ Smart Contract Code [Deployed @ Mumbai Test Network]frontend
โฉ Project's React frontend.backend/test
โฉ Tests for Smart Contracts.
A standard for organizing and upgrading a modular smart contract system. Multi-Facet Proxies for full control over your upgrades.
Diamonds are a proxy pattern for Solidity development that allows a single gateway contract to proxy calls and storage to any number of other contracts. This provides a single interface for anyone to use your contracts, while allowing your feature set to grow into many contracts. The Diamond Standard also allows for replacing or extending functionality after your contracts are deployed.
git clone https://github.com/ShivaShanmuganathan/diamond-dapp
cd frontend
yarn install
Install Dependenciesyarn start
Start the frontend in localhost- Open
http://localhost:3000
We can use the localhost frontend to interact with the smart contract on Mumbai Network
cd backend
npm install
Install Dependenciesnpx hardhat --version
Check if Hardhat is properly installednpx hardhat compile
Compile the Smart Contractnpx hardhat test
Test the Smart Contract Locallynpx hardhat run scripts/deploy.js
Deploy the Smart Contract Locally
- Change filename
.env.example
to.env
- Get Alchemy Key for Mumbai Network from Alchemy, and assign it to
STAGING_ALCHEMY_KEY
in.env
- Get
PRIVATE_KEY
of your wallet from MetaMask, and assign it toPRIVATE_KEY
in.env
- RUN
npx hardhat run scripts/deploy.js --network mumbai
to deploy Diamond Contract, DiamondCutFacet, DiamondInit, DiamondLoupeFacet, and OwnershipFacet to the Mumbai Network. - RUN
npx hardhat run scripts/deploy2.js --network mumbai
to deploy dynamicGameFacet Contract to the Mumbai Network, and add it to the Diamond Contract. - RUN
npx hardhat run scripts/deploy3.js --network mumbai
to deploy nftReceiverFacet Contract to the Mumbai Network, and add it to the Diamond Contract. - RUN
npx hardhat run scripts/deploy4.js --network mumbai
to deploy StakeNFTFacet Contract to the Mumbai Network, and add it to the Diamond Contract. - RUN
npx hardhat run scripts/deploy5.js --network mumbai
to deploy StakeNFTFacet Contract to the Mumbai Network, and add it to the Diamond Contract.
- Open
scripts/deploy.js
inbackend
folder - This is the code you need to edit to make your own heroes
let functionCall = diamondInit.interface.encodeFunctionData('init', [["Jett", "Phoenix", "Neon", "Raze", "Reyna", "Yoru", "Breach", "KAY/O", "Skye", "Sova", "Astra", "Brimstone", "Omen", "Viper", "Cypher", "Sage"], [ "https://gateway.pinata.cloud/ipfs/QmXDEW26MnmgkdijbQtTQSnQZ7DWfMFqJYzruU3mGnp64w", "https://gateway.pinata.cloud/ipfs/QmWbkhC6AunE9ZZMwJbTbrHTPYFPCbY9uDFtLsSbr5zYt2", "https://gateway.pinata.cloud/ipfs/Qmc659ijRouVQEycT5rEwCo73j1QuaFLH1FMSTbDpTPueX", "https://gateway.pinata.cloud/ipfs/QmUpzvz2hC9gBYs5Tr1N3GqqiL9PstSkVR1cxmNKjC1FrU", "https://gateway.pinata.cloud/ipfs/QmWuzkZo4JLBvTo14LLCY7nP5oViifJt4oU5rpcd5QhHFH", "https://gateway.pinata.cloud/ipfs/QmUWYfyJDjMm65WGCNsrXqZdUGAA4Szt7A3wFaNZirfMqn", "https://gateway.pinata.cloud/ipfs/QmNwfv6rUgW3PCKnNo3uxLuy8r3hU9sGEd5TgoyQDLitTf", "https://gateway.pinata.cloud/ipfs/QmS6v2Gz22QSasUCmHg6gaMsUaWT2AvHVpKA4vefMf16u7", "https://gateway.pinata.cloud/ipfs/QmZqr3hj8RPeFeP6DGKi25KBTzTW5h4VWD2f6q94pXrJiA", "https://gateway.pinata.cloud/ipfs/QmPpbjrWbejguWRNP9qwgoPf6VYYfV4SUsZ51vvVMPbyTE", "https://gateway.pinata.cloud/ipfs/QmXHk7GYn7bgLRCig6zTEXpDvA5T8jTKqhXnyiiHEL5G8b", "https://gateway.pinata.cloud/ipfs/QmXrW7CdHC9UjJTAWuNU4vRAk7QdbjyHjewy3SGTD9DWms", "https://gateway.pinata.cloud/ipfs/QmP1R6xYmm77KdT8ZxUyixdA8uwCEHpmgDRBYCVSHMGc36", "https://gateway.pinata.cloud/ipfs/QmX3hV9q5k5B7mwsyj8g6q8qw8HPdkYTKuws6e73L997xQ", "https://gateway.pinata.cloud/ipfs/QmPFbj4Ufx69zf241qJ5U4Qexqc8hx4PG5Uo5ucyuNW61X", "https://gateway.pinata.cloud/ipfs/QmePF9pBnjdfajbT3i4peVoNqijaQCNYeLQXj76P7JoFXr" ], [1000, 1250, 1100, 1400, 1500, 1450, 1700, 1800, 1950, 2000, 2100, 2500, 2400, 3000, 3500, 4000], [45, 30, 35, 25, 15, 20, 60, 55, 50, 45, 80, 75, 70, 65, 100, 90], ["Duelists", "Duelists", "Duelists", "Duelists", "Duelists", "Duelists", "Initiators", "Initiators", "Initiators", "Initiators", "Controllers", "Controllers", "Controllers", "Controllers", "Sentinels", "Sentinels"], "THANOS", "https://raw.githubusercontent.com/ShivaShanmuganathan/diamond-nft-game/main/Thanos.webp", 100000, 150]);
- Change
["Jett", "Phoenix", "Neon", ...]
to the character names you want - Upload images you want to IPFS using Pinata and get the CID of the uploaded images
- Change
["https://gateway.pinata.cloud/ipfs/QmXDEW26MnmgkdijbQtTQSnQZ7DWfMFqJYzruU3mGnp64w", "https://gateway.pinata.cloud/ipfs/QmWbkhC6AunE9ZZMwJbTbrHTPYFPCbY9uDFtLsSbr5zYt2", "https://gateway.pinata.cloud/ipfs/Qmc659ijRouVQEycT5rEwCo73j1QuaFLH1FMSTbDpTPueX", ...]
to the CID of the images uploaded to IPFS - Change
[1000, 1250, 1100, ...]
to the maxHealth you want for the Heroes - Change
[45, 30, 35, ...]
to the attackDamage you want for the Heroes - Change
THANOS
to the name of your Boss - Change
https://raw.githubusercontent.com/ShivaShanmuganathan/diamond-nft-game/main/Thanos.webp"
to the image url of your Boss - Change
100000
to edit the Boss Health - Change
150
to edit the Boss Attack Damage
๐ 0x791B0E7e61B094Eb6B7695d9ABc659F391071c43 ๐ธ
backend/contracts
โโโ Diamond.sol
โโโ facets
โ โโโ DiamondCutFacet.sol
โ โโโ DiamondLoupeFacet.sol
โ โโโ DynamicGameFacet.sol
โ โโโ NFTReceiverFacet.sol
โ โโโ OwnershipFacet.sol
โ โโโ RentalNFTFacet.sol
โ โโโ StakeNFTFacet.sol
โโโ interfaces
โ โโโ IDiamondCut.sol
โ โโโ IDiamondLoupe.sol
โ โโโ IERC165.sol
โ โโโ IERC173.sol
โ โโโ IERC721.sol
โโโ libraries
โ โโโ Base64.sol
โ โโโ LibAppStorage.sol
โ โโโ LibDiamond.sol
โ โโโ LibERC721.sol
โ โโโ LibMeta.sol
โ โโโ LibRentalStorage.sol
โ โโโ LibStakeStorage.sol
โโโ tokens
โ โโโ ERC721Diamond.sol
โโโ upgradeInitializers
โโโ DiamondInit.sol
๐ DiamondCutFacet deployed ๐ฏ 0xd76553C411ed3b0a4792cEB04b71aEa5bE99eC15 ๐ฏ
๐ DiamondInit deployed ๐ 0xd7842705839fF83570836705a4DDa434b821C944 ๐
๐ DiamondLoupeFacet deployed ๐ 0xA794afc756a9115D3f7896977BB7B6b1164B3273 ๐
๐ OwnershipFacet deployed ๐ก 0xBB417f5335c149061cA18991eD51F0578c9cDB33 ๐ก
๐ dynamicGameFacet deployed ๐ฎ 0xf1FeF4915c6D2a73144a6f95239B971197DEAD9e ๐ฎ
๐ nftReceiverFacet deployed ๐ 0x44243fC912be0827FD9A3e532F65e3450d15E513 ๐
๐ stakeNFTFacet deployed ๐ฅฉ 0xC16919F426f58dB947234Acb20C454C06053FB4B ๐ฅฉ
๐ rentalNFTFacet deployed ๐ 0xf53eAcceC787f532f5f25b778bde3910D5B8DA92 ๐