diff --git a/packages/nextjs/app/create/_components/generateTokenURI.tsx b/packages/nextjs/app/create/_components/generateTokenURI.tsx index dd79235..1b86ae7 100644 --- a/packages/nextjs/app/create/_components/generateTokenURI.tsx +++ b/packages/nextjs/app/create/_components/generateTokenURI.tsx @@ -8,11 +8,16 @@ const generateTokenURI = (description: string, image: string) => { // Convert the metadata object to a JSON string const jsonString = JSON.stringify(metadata); - // Encode the JSON string as base64 - const base64Encoded = btoa(jsonString); + // Encode the JSON string as base64 using a UTF-8 safe method + const base64Encoded = utf8ToBase64(jsonString); // Construct the data URI return `data:application/json;base64,${base64Encoded}`; }; +// Function to encode a UTF-8 string to base64 +const utf8ToBase64 = (str: string) => { + return window.btoa(unescape(encodeURIComponent(str))); +}; + export default generateTokenURI;