marp |
---|
true |
This project demonstrates a basic fully dynamic NFT with on-chain metadata that changes based on your interactions with it, and deploy it on Polygon Mumbai to lower gas fees.
- ⚙️ NFT stored in metadata on chain
- ✉️ Deployed on Polygon Mumbai
- 🏡 Able to modify metadata based on interactions with the NFT
- ⚙️ Navigate to
mumbai.polygonscan.com
and scroll down to the bottom of the page. You'll see the "Add Polygon Network" button, click on it and confirm you want to add it to Metamask - ⛓ Getting Test MATIC just navigate to one of the following faucets:
-mumbaifaucet.com
-faucet.polygon.technology
Run the following tasks: related to node.js and Hardhat
npm install
npm -y init
npx hardhat init
npx hardhat test
npx hardhat run scripts/Deploy.js
npm install @nomicfoundation/[email protected]
npm install @nomiclabs/[email protected]
npm install @nomiclabs/[email protected]
npm install @openzeppelin/[email protected]
npm install [email protected]
npm install [email protected]
🥾 Two applications ☝️ Alchemy .com 🎯 Polygonscan.com
-testnet.opensea.com:
Certainly! The provided Solidity code defines a contract called IdiancBattles
, an ERC721 token (NFT) that includes functionality for creating and managing unique tokens representing characters for battles.
Let's break down the code and its functionalities into explanatory statements:
- The contract inherits from
ERC721URIStorage
in the OpenZeppelin library, enabling it to implement the ERC721 token standard with URI storage capabilities. - It imports necessary libraries (
Counters.sol
,Strings.sol
,Base64.sol
) for managing token IDs, string manipulation, and Base64 encoding.
- The contract includes a counter
_tokenIds
to manage token IDs and a mappingtokenIdToLevels
to associate each token ID with its corresponding level.
- The constructor initializes the contract with a name "Idianc Battles" and a symbol "CBTLS" for the NFT.
- This function generates an SVG representation for a specific NFT (character) based on its
tokenId
. - It constructs an SVG string representing the character's visualization using the
abi.encodePacked()
function. - The SVG includes a black background, text displaying the character type ("Warrior"), and the character's level obtained from
getLevels()
.
- This function retrieves the level associated with a specific
tokenId
from thetokenIdToLevels
mapping and converts it to a string.
- Generates the token URI for a specific
tokenId
. - Creates a JSON structure representing the token metadata (name, description, and image).
- The image is constructed by calling
generateCharacter()
to get the SVG representation and encoding it to Base64.
- Increments the
_tokenIds
counter to generate a newtokenId
. - Mints a new token (
_safeMint
) for the caller (msg.sender). - Initializes the level for the new token as 0 and sets its token URI using
getTokenURI()
.
- Allows the owner of a token to increment its level.
- Checks if the token exists and verifies that the caller is the token owner.
- Increments the token's level in
tokenIdToLevels
and updates its token URI accordingly.
- The contract enables the minting of unique ERC721 tokens (NFTs) representing characters for battles.
- It provides functionalities to generate character visuals (SVG-based), retrieve token levels, mint new tokens, and increment token levels through training (restricted to token owners).
``@Dennys_wambs_IDEANC