Skip to main content

Command Line Interface

The command line interface, SmartPy CLI, also known as smartpy-cli, has been introduced in the following outdated Medium Post.

It now provides a CLI that works seamlessly on various syntaxes: SmartPy, SmartTS and SmartML.

Installationโ€‹

The SmartPy CLI can be installed in two ways: the direct installation or through a project.

Direct Installationโ€‹

To install the last CLI:

bash <(curl -s https://smartpy.io/cli/install.sh)

To install the last CLI and compile SmartML (opam is required):

bash <(curl -s https://smartpy.io/cli/install.sh) --with-smartml

To install the current version:

bash <(curl -s https://smartpy.io/cli/install.sh)

To install the current version and compile SmartML:

bash <(curl -s https://smartpy.io/cli/install.sh) --with-smartml

Project Managementโ€‹

See Getting Started/Project Management.

Check versionโ€‹

This command tells which CLI version is installed.

~/smartpy-cli/SmartPy.sh --version

Dependenciesโ€‹

The SmartPy CLI depends on python3 and Node.js.

It also depends on

  • opam for the optional and experimental support of the SmartML syntax;
  • pdoc for Python template documentation.

Executionโ€‹

Executing a SmartPy Script with its testsโ€‹

SmartPy.sh testโ€‹

Perform tests defined in a script (see Tests and Scenarios).

~/smartpy-cli/SmartPy.sh test <script> <output-directory>

This includes many outputs: types, generated michelson code, pretty-printed scenario, etc.

Compiling Contracts and Expressionsโ€‹

SmartPy.sh compileโ€‹

Compute the Compilation Targets defined in a script.

# For a SmartPy, SmartTS or SmartML script:
~/smartpy-cli/SmartPy.sh compile <script> <output-directory>

Example:

# For a SmartPy, SmartTS or SmartML script:
~/smartpy-cli/SmartPy.sh compile welcome.py /tmp/welcome

~/smartpy-cli/SmartPy.sh compile welcome.ts /tmp/welcome

~/smartpy-cli/SmartPy.sh compile welcome.ml /tmp/welcome

Custom Targetsโ€‹

SmartPy.sh kind <kind> <script> <output-directory>โ€‹

Similar to tests. Perform scenarios defined in a script introduced by the custom target.

# For a SmartPy, SmartTS or SmartML script:
~/smartpy-cli/SmartPy.sh kind <kind> <script> <output-directory>

Documentationโ€‹

SmartPy.sh doc <script> <output-directory>โ€‹

Document Python code with pdoc.

Deploying a contractโ€‹

# Using Micheline format (.tz)

~/smartpy-cli/SmartPy.sh originate-contract --code code.tz --storage storage.tz --rpc https://ghostnet.smartpy.io

# Using Michelson format (.json)

~/smartpy-cli/SmartPy.sh originate-contract --code code.json --storage storage.json --rpc https://ghostnet.smartpy.io

# By default, the originator will use a faucet account.
# But you can provide your own private key as an argument

~/smartpy-cli/SmartPy.sh originate-contract --code code.json --storage storage.json --rpc https://ghostnet.smartpy.io --private-key edsk...

CLI optional argumentsโ€‹

SmartPy.sh takes several optional arguments.

See Flag for list of flags and protocols.

ArgumentDescription
--purgeEmpty the output directory before writting to it.
--htmlAdds .html outputs such as a log.html which is identical to the output panel in the Web IDE.
--<flag> argumentsSet some flag with arguments.
--<flag>Activate some boolean flag.
--no-<flag>Deactivate some boolean flag.
--mockupRun in mockup (experimental, needs installed source).
--sandboxRun in sandbox (experimental, needs installed source).