aeternity / aesophia

Stand alone compiler for the Sophia smart contract language
https://docs.aeternity.com/aesophia
ISC License
52 stars 19 forks source link

Is it possible to convert string or int to bytes? #436

Closed davidyuk closed 1 year ago

davidyuk commented 1 year ago

https://docs.aeternity.com/aesophia/v7.0.1/sophia_stdlib/#bytes I've found functions to convert bytes to int and string, but I can't find the reverse. Probably it is because int and string have dynamic size, but still. As a workaround, I've used strings to concatenate binary data.

hanssv commented 1 year ago

No, it is not currently possible.

Originally strings used to be just "byte-arrays" but then it was important that they were interpreted as UTF8 (and thus not all byte-arrays are valid strings) - so we lost the generic byte arrays.

I'm curious if it would be possible to make compiler only changes that introduces arbitrary sized byte arrays. If time permits that might be something to look into.

hanssv commented 1 year ago

To follow up, it is only possible to do a little bit without changing FATE - I'll see if I can make a suggestion for Ceres instead...

hanssv commented 1 year ago

See #456