0

How do I convert an address type to a string type in LIGO?

2

You cannot convert an address to a string in Michelson. You could cheat by going through pack and inspecting the binary representation but it is unlikely something you would want to do.

| improve this answer | |
  • OK. I solved my problem another way, by changing the JS signature generation. I still am curious about the answer, though. How would you achieve this? We can probably learn something from getting this explanation. – Thorkil Værge Oct 6 at 13:33
  • Cheating involves going through pack and inspecting the binary representation. Very ugly. – FFF Oct 6 at 13:58
  • Voted up. Will gladly accept answer if you show the specific code to do this. Either in an actual programming language or as pseudo code. – Thorkil Værge Oct 7 at 8:09
  • 2
    You first compute pack(my_address) then you can do a for loop on each byte of the meaningful part (not the prefix) with slice and associate a string by using a pre-determined dictionary. If you want to write the exact address, you need to implement the base 58 translation in Michelson. It’s obviously super cumbersome to do. You possibly also need to take entry points in addresses into account but I guess that, at this point, you should really have stopped caring. – FFF Oct 7 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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