UTF-8 to bytes32

I am trying to store strings in a contract but need the fixed size or string32 which is now bytes32. I understand that bytes32 is binary data but can not seem to convert a string in javascript to a byte array to call my smart contract. What is the best way in js to covert between the two?

Comments

  • brandonzfrbrandonzfr Member Posts: 20
    When a param of a solidity function is of type bytes32 one can pass in an ascii string. When solidity returns this string it is in hex. A simple hex to ascii translation can be applied to convert back.
Sign In or Register to comment.