Skip to main content

CLI Commands

In the hello world guide we executed leo run. This command runs several other Leo CLI commands before verifying a proof.

leo run

Step by step

Let's walk through each command called by leo run and get a better understanding of what's happening under the hood. First, remove all build files with:

leo clean
console output:
  Cleaning ✅ Cleaned the build directory (in "/build/")

1. Build

The leo build command compiles the program file main.leo. Leo will check program syntax and produce the main.aleo file.

leo build

The build directory will store all files generated by the Leo CLI.

console output:
     Build ✅ Compiled 'main.leo' into Aleo instructions (in "/hello/build/main.aleo")
Build ✅ Built 'hello.aleo' (in "/hello/build")

2. Run

The leo run command executes the /build/main.aleo Aleo program using the Aleo SDK. For more information read the Aleo SDK documentation.

leo run
console output:
 Build ✅ Compiled 'main.leo' into Aleo instructions (in "/hello/build/main.aleo")
⏳ Compiling 'hello.aleo'...

• Loaded universal setup (in 100 ms)
• Built 'main' (in 1000 ms)

Build ✅ Built 'hello.aleo' (in "/hello/build")
• Loaded universal setup (in 100 ms)
🚀 Executing 'hello.aleo/main'...

• Executing 'hello.aleo/main'...
• Executed 'main' (in 1000 ms)

➡️ Output

• 3u32

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

The leo run command will attempt to verify a proof only if all previous steps completed successfully. Under the hood, the Leo CLI will check for existing .sum, .lpk, .lvk, or .proof files in the outputs directory before running each command. This ensures that we don't run unnecessary commands.

The Leo CLI

To learn more about how to use the Leo CLI, start here.