Skip to content

CLI usage

Julian Konchunas edited this page Aug 31, 2020 · 1 revision

General usage: ./cmd.coffee <file.sol>

  • --router - generate a router: a special structure so methods of this contract are accessible from outside. Read more Router*
  • --ds - Also print a default state. Default state is an initial values of your contract. They are required to originate (deploy) your contract into the network. In there you specify, for example, your initial holders inside bigmaps.
  • --test - perform compilation of the resulting code. LIGO executable has to be installed and available in your PATH
  • --disable_enums_to_nat - In Solidity enums implemented like in C. They are virtually unsigned integer numbers. Comparing two enum values is like comparing two integers. But in LIGO enum, also known as variant type is more complex and versatile. The problem here is that you can't compare two enums or perform arithmetic operations like you do in Solidity. This option is true by default and will produce:
const FIRST_ENUM_VAL : nat = 0;
const SECOND_ENUM_VAL : nat = 1;

instead of

type Enum_val of 
  | FIRST_ENUM_VAL
  | SECOND_ENUM_VL

This way enums while being less type safe will behave similarly to Solidity.

  • --contract <name> - specify a contract name to be considered main. This affects what methods of contract will be added to the router. And also what included contracts or interfaces will be considered foreign. Calls to foreign contracts will be attempted to be translated to transaction calls for convenience. If not passed last contract is automatically considered main one.

  • --outfile <name> - output a contract into a file with instead of stdout. This also creates storage.ligo file alongside generated one for contract to be originated with.

  • --dir <path> - keep original directory structure and yield multiple ligo files. By default all imports of original Solidity contract are collected and embedded into one file so transpiler can have as much context as possible. This may lead to a huge and hard-to-navigate LIGO output file. If the original project is consisting of several files in a directory structure this flag should preferably be passed. This way sol2ligo will attempt to preserve the original structure and place #include statements for the system to come together. Target directory might be specified using --outdir flag, current working directory is used otherwise.

Clone this wiki locally