2

I want to do some automatic transformation of solidity source code. For this reason, I thought to get its AST representation using solc --ast or solc --ast-json and modify it.

My questions are:

  1. What is the best approach to modify the AST? Should I use the text or json representation?
  2. How do I compile the modified AST to binary code? Do I have to convert the AST back to source code, and if yes how can this be done?
  3. Are there any existing tools that provide such desired functionalities?
2

You can modify the AST and generate new source code from the AST using this tool:

https://github.com/chao-peng/SIF

0

Modifying the AST should be the hardest part. There is a pre-existing tool (XevXml) that looks like it might convert the AST to XML for you, which you could then modify.

To convert this modified AST back into binary, you could theoretically use Rose Compiler. But Rose Compiler is not user friendly; I am trying to get it to work right now, with lots of road blocks. Good luck.

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.