Skip to main content
The leo run command executes Leo programs locally in an off-chain environment without generating cryptographic proofs. This is ideal for rapid testing and development.

Syntax

Arguments

string
default:"main"
The function to execute. Can be:
  • Function name only: main (uses program from program.json)
  • Qualified name: hello_world.aleo/main
string[]
Program inputs. Format depends on the input type:
  • Literals: 1u32, true, 5field
  • Records (plaintext): { owner: aleo1..., data: 5u64 }
  • Records (ciphertext): record1... (automatically decrypted)

Options

Network Options

string
Network type: mainnet, testnet, or canary. Defaults to testnet.
string
Endpoint URL for network operations.
string
Private key to use for execution. Defaults to test key for local execution.
Default test key: APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH is for development only.

Build Options

boolean
default:false
Enable offline mode. Prevents network requests.
boolean
default:false
Don’t use the dependency cache.
boolean
default:false
Use network versions of dependencies instead of local source.

Examples

Execute Default Function

Executes the main function with no inputs.

Execute with Inputs

Output:

Execute Specific Function

Execute with Qualified Name

Execute with Record Input

Plaintext record:
Ciphertext record (automatically decrypted):
Record ciphertexts starting with record1 are automatically decrypted using your private key’s view key.

Execute Remote Program

Leo will:
  1. Download the program from the network
  2. Download all dependencies
  3. Add programs to the VM
  4. Execute the function
Output:

Execute with Custom Private Key

Execute on Different Network

Execution Flow

  1. Build Phase (if in Leo project):
    • Compiles the program and dependencies
    • Generates bytecode
  2. VM Initialization:
    • Creates an in-memory VM
    • No persistent state
  3. Program Loading:
    • Loads local programs from build/
    • Downloads remote programs from network
    • Adds programs in dependency order
  4. Authorization:
    • Generates authorization for the function call
    • Uses provided private key
  5. Evaluation:
    • Executes the function in the VM
    • Returns outputs

Output Format

Single output:
Multiple outputs:

Local vs Remote Programs

Local Program

  • Source code in current directory
  • Built automatically before execution
  • Uses build/main.aleo

Remote Program

  • Downloaded from network endpoint
  • Cached for subsequent runs
  • Uses network version of dependencies
Use leo run for rapid testing. For on-chain execution with proofs, use leo execute.

Differences from Execute

Input Format Reference

Primitive Types

Addresses

Structs

Records

Plaintext:
Ciphertext:

Troubleshooting

Function Not Found

Ensure the function exists and is a transition (entry point).

Invalid Input Format

Check your input format matches the expected type.

Program Not Found

Either:
  • Run from a Leo project directory, or
  • Use the qualified name: leo run program.aleo/function

Next Steps