Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic SvgNft Support #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Vswaroop04
Copy link

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

  1. The Smartcontract that modified can create a dynamic SVG NFT (non-fungible token) using the ERC721 standard.
  2. 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.
  3. 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.
  4. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant