Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have integrated the SVG data directly into the metadata of the NFT. This means that the image data is stored on-chain, which solves the issue of relying on external IPFS nodes. Additionally, this change should improve the overall user experience since the images should load more quickly and reliably
safeMintNFT
: This function can be called by anyone to mint a new NFT. it emits a CreatedNFT event with the tokenID. The s_tokenCounter variable is incremented to keep track of the total number of tokens.svgToImageURI
: This function takes an SVG string as input and returns a data URI for the image version of the SVG. It first encodes the SVG data as a base64 string using the Base64.encode function from the base64.sol library. Then it constructs a data URI by concatenating the base URL "data:image/svg+xml;base64," with the base64-encoded SVG data.tokenURI
: This function is overridden to return a JSON metadata string for a given token ID. It first checks if the token exists using the _exists function provided by the ERC721 standard. Then it constructs a JSON string that includes the name, description, attributes, and image URI for the NFT.