PatrickAlphaC / hardhat-nft-fcc

100 stars 139 forks source link

Issue with ”string“ and "abi.encodePacked" #56

Closed XieWeiJie closed 1 year ago

XieWeiJie commented 1 year ago

This is the "svgToImageURI" function in the DynamicSvgNft contract

Question : Hey Patrick! Why can't it be used directly like in the comments, taking ”svg“ as a parameter?

function svgToImageURI(string memory svg) public pure returns (string memory) {
        string memory baseURL = "data:image/svg+xml;base64,";
        string memory svgBase64Encoded = Base64.encode(bytes(string(abi.encodePacked(svg))));
        //string memory svgBase64Encoded = Base64.encode(bytes(svg));
        return string(abi.encodePacked(baseURL, svgBase64Encoded));
    }

@PatrickAlphaC

PatrickAlphaC commented 1 year ago

You could! The bytes(string(abi.encodePacked(svg))) is leftover from when I had the SVG file combining elements. Sorry!