I would like to convert a bytes type to a string type.
How can this be done in pure CameLIGO?:
let data: bytes = [%bytes "hello"] in
let str: string = ???
Thank you, Edward
Tezos Stack Exchange is a question and answer site for users, experts, and developers of the Tezos blockchain project. It only takes a minute to sign up.
Sign up to join this communityIf you are using literal bytes i don't think you can do it from the standard lib of Ligo. You need to build your bytes to string function.
If you are using bytes create from a Michelson string you can do:
let data: string = "hello" in
let data: bytes = Bytes.pack data in
let str: string = Option.unopt((Bytes.unpack data) : string option)