LEO Part 5

Neiro
5 min readAug 28, 2023

--

Have a nice sunny day or warm evening wherever you are.

Friends, we continue to dive into the Leo language.

Today we are going to talk about Leo Command and Tooling for Leo.

Let’s get started.

You can read previous installments on Leo Language by clicking on the links below:

LEO Part 1
LEO Part 2
LEO Part 3
LEO Part 4

The Leo Command Line Interface

The Leo CLI is a command line interface tool that comes equipped with the Leo compiler.

Installation

Install Leo

Global Flags

  • -d, --debug - Enables debugging mode
  • -h, --help - Prints help information
  • -V, --version - Prints version information

List of Commands:

TIP

You can print the list of commands by running leo --help

  • example - Create a new Leo package from an example program.
  • new - Create a new Leo package in a new directory.
  • build - Compile the current package as a program.
  • run - Run a program with input variables.
  • execute - Execute a program with input variables.
  • clean - Clean the output directory.
  • update - Update to the latest version of Leo.
  • account - Create a new Aleo account.

leo example

To list all available example programs, run:

leo example
# Output:Create a new Leo example package in a new directoryUsage: leo example [OPTIONS] <COMMAND>Commands:
lottery A public lottery program
tictactoe A standard tic-tac-toe game program
token A transparent & shielded custom token program
help Print this message or the help of the given subcommand(s)
Options:
-d Print additional information for debugging
-q Suppress CLI output
--path <PATH> Optional path to Leo program root folder
-h, --help Print help

To create a new Leo package from an example program, run:

leo example {$NAME}

leo new

To create a new package, run:

leo new {$NAME}

Valid package names are snake_case: lowercase letters and numbers separated by underscores. This command will create a new directory with the given package name. The new package will have a directory structure as follows:

package/
├── .env # Your program environment
├── program.json # Your program manifest
├── README.md # Your program description
├── build/
├── inputs/
│ ├── hello.in # Your program inputs
└── src/
└── main.leo # Your program file

leo build

INFO

This command is deprecated as of Leo v1.9.0. It will be removed in a future release.

To compile your program into Aleo Instructions and verify that it builds properly, run:

leo build

This will populate the directory build/ (creating it if it doesn't exist) with an Aleo instructions file .aleo.

console output:

Leo ✅ Compiled 'main.leo' into Aleo instructions

leo run

TIP

Use this command to run your program before executing it.

To run a Leo transition function using inputs from the program input .in file.

leo run {$TRANSITION}

To run a Leo transition function with inputs from the command line. {$INPUTS} should be a list of inputs to the program separated by spaces.

leo run {$TRANSITION} {$INPUTS}

This command does not synthesize the program circuit or generate proving and verifying keys.

console output:

Leo ✅ Compiled 'main.leo' into Aleo instructions
⛓  Constraints
• 'hello.aleo/main' - 35 constraints (called 1 time)
➡️ Output
• 3u32

Leo ✅ Finished 'hello.aleo/main' (in "/hello/build")

leo execute

TIP

Use this command to execute your program and generate a transaction object.

To execute a Leo transition function using inputs from the program input .in file.

leo execute {$TRANSITION}

To execute a Leo transition function with inputs from the command line. {$INPUTS} should be a list of inputs to the program separated by spaces.

leo execute {$TRANSITION} {$INPUTS}

This command synthesizes the program circuit and generates proving and verifying keys.

console output:

Leo ✅ Compiled 'main.leo' into Aleo instructions
⛓  Constraints
• 'hello.aleo/main' - 35 constraints (called 1 time)
➡️ Output
• 3u32

{"type":"execute","id":"at1 ... (transaction object truncated for brevity)

Leo ✅ Executed 'hello.aleo/main' (in "/hello/build")

leo clean

To clean the build directory, run:

leo clean

console output:

Leo cleaned the build directory (in "/build/")

leo update

To download and install the latest Leo version run:

leo update

console output:

Checking target-arch... x86_64-apple-darwin
Checking current version... v1.8.3Checking latest released version... v1.8.3  Updating Leo is on the latest version 1.9.0

leo account

To create a new Aleo account, run:

leo account new
# Output:
Private Key APrivateKey1zkp...
View Key AViewKey1...
Address aleo1...

To import an existing Aleo account, run:

leo account import {$PRIVATE_KEY}

To create a new account and save it to your .env file, run:

leo account new --write

To list all options

leo account --help
# Output:
Create a new Aleo account
Usage: leo account [OPTIONS] <COMMAND>Commands:
new Generates a new Aleo account
import Derive an Aleo account from a private key
help Print this message or the help of the given subcommand(s)
Options:
-d Print additional information for debugging
-q Suppress CLI output
--path <PATH> Optional path to Leo program root folder
-h, --help Print help

Tooling for Leo

Aleo maintains syntax highlighting implementations across different platforms.
If you do not see your favorite editor on this list, please reach out on GitHub.

  1. Sublime Text
  2. Visual Studio Code
  3. Intellij

Sublime Text

Download the editor here: https://www.sublimetext.com/download. Leo support for Sublime’s LSP plugin is provided through a language server.

Install

  1. Install LSP and LSP-Leo from Package Control.
  2. Restart Sublime.

Usage

Follow these steps to toggle the Leo syntax highlighting, hover, and tokens.

  1. Open Sublime Text.
  2. From Preferences > Select Color Scheme… > LSP-aleo-developer

VS Code

Download the editor here: https://code.visualstudio.com/download.

Install

Install Leo for VS Code from the VS Code marketplace.
The correct extension ID is aleohq.leo-extension.

Usage

  1. Open VS Code.
  2. From Preferences > Color Theme… > Aleo Theme

Intellij

Download the editor here: https://www.jetbrains.com/idea/download/.

Install

Install the Leo for Intellij from the JetBrains marketplace.

Thank you for reading this article to the end, and sign up for notifications.

See below for all the official links to Aleo:

Website — https://www.aleo.org/
Discord — https://discord.gg/aleohq
Twitter — https://twitter.com/AleoHQ
GitHub — https://github.com/AleoHQ

--

--