How do you pass in a value as a string via remix - if that value includes quotes?

For example

A function takes a string - in remix I enter:

<path id="svg_1" d="m-44.5,88.5c234,144 125,271 124.5,270.5c0.5,0.5 252.5,-74.5 253.5,-72.5c1,2 -12,141 -12.5,140.5c0.5,0.5 437.5,-39.5 437,-40c0.5,0.5 -9.5,-240.5 -10,-241c0.5,0.5 -219.5,320.5 -220,320" opacity="0.5" stroke-width="1.5" stroke="#000" fill="#6F5C2A"/>

Because this code that I'm trying to store as a string, has quotes in it, remix thinks there are multiple strings being passed, when the function only takes one string.

So how do I pass something like this into remix such that returning the string returns the code properly?

\"m-44........\" does not work unless its single quotes and then it returns the string improperly

  • Hi Zach, do you find a solution?
    – Frank Kong
    Commented Oct 28, 2022 at 3:12

1 Answer 1


Why don't you store the strings in the contract in encoded version? Everytime you are saving data in the smart contract you can encode the strings from the frontend by using encodeURIComponent() and everytime you need to read that particular data you can decode it by using decodeURIComponent().

  • Ideally so that if some dapp or site calls the function they can return the properly formatted svg info and display it without needing to convert anything.
    – Zach
    Commented Jan 31, 2021 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.