Any known tool or website can translate the given online contract into ligo? For example, KT18fp5rcTW7mbWDmzFwjLDUhs5MeJmagDSZ, can I review the logic of this contract in ligo somewhere, however michelson would be too difficult for me to grasp it.
2 Answers
The compilation goes in the other direction: from Ligo (or another high-level language) to Michelson. Michelson is designed to be easier to read than other VM bytecodes but reading the source code is usually much easier.
In the case of the contract you mention (the FA2 from the Wrap protocol), a quick search pointed me to the following repo: https://github.com/bender-labs/wrap-tz-contracts/tree/master/ligo/fa2.
FYI, I'm writing an experimental translator from Michelson to OCaml (not ligo).
https://github.com/aigarashi/ocaml_of_michelson
The main caveat is that the generated OCaml code doesn't run -- It's just help human beings understand. :-)
-
Thank you very much, Atsushi. This is amazing. I tested the files in the test folders and randomly checked a few of them. However, for the specific contract I mentioned in the question, it ran into some error message. Sep 2, 2021 at 8:21
-
Thank you for trying!Hmm, I was able to generate some code from KT18fp5rcTW7mbWDmzFwjLDUhs5MeJmagDSZ (but the code doesn't pass the OCaml typechecker ;-). I'll take a look at the problem. Meanwhile, I'm happy to help you solve your problem. Sep 3, 2021 at 8:26
-
A bug has been fixed and the code generated from this contract now passes the OCaml typechecker. Sep 4, 2021 at 1:21
-
FYI, the generated code is available at: gist.github.com/aigarashi/c1601546dbf62d78011abaf863bb700c . Sep 6, 2021 at 2:45
-
Hello Atsushi, thanks for further improvement. I got back to this issue today and tried to recompile the latest version. It seems you modified readme by deleting installation details. Anyway, I didn't compile it successfully this time. However all after all, thanks for coming up with the code translation idea and making such solution. Sep 16, 2021 at 13:30