I’m trying to obtain an AST from a solidity contract
I cannot find anyway to achieve that using solc
I saw on previous versions there were --ast options in command line
or other ast commands…
Now i cannot find any of that
Tried also doing an input json with the contract but i get
Cannot retry compilation with SMT because there are no SMT solvers available.
{“sources”:{“SolcTest.sol”:{“id”:0}}}
every time…
Is there a way to obtain an AST using solc ?
thanks
There are many ways to achieve such output. For example:
solc path/to/Contract.sol --ast-compact-json
returns AST in a JSON format.
solc path/to/Contract.sol --ir-ast-json
returns AST of Intermediate Representation (IR) of contract in a JSON format.
solc path/to/Contract.sol --ir-optimized-ast-json
returns AST of optimized Intermediate Representation (IR) of the contract in a JSON format.
solc path/to/Contract.sol --combined-json ast
returns a single JSON document containing the AST.
You can use solc --help
and search for all the options you can use to get the AST.