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

leo run [NAME] [INPUTS...] [OPTIONS]

Arguments

NAME
string
default:"main"
The function to execute. Can be:
  • Function name only: main (uses program from program.json)
  • Qualified name: hello_world.aleo/main
INPUTS
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

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

Build Options

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

Examples

Execute Default Function

leo run
Executes the main function with no inputs.

Execute with Inputs

leo run main 1u32 2u32
Output:
➕Adding programs to the VM in the following order:
  • hello_world.aleo (local)

➡️  Output

 • 3u32

Execute Specific Function

leo run add 5u32 10u32

Execute with Qualified Name

leo run hello_world.aleo/main 1u32 2u32

Execute with Record Input

Plaintext record:
leo run transfer '{ owner: aleo1..., amount: 100u64 }'
Ciphertext record (automatically decrypted):
leo run transfer record1zy9q3y...
Record ciphertexts starting with record1 are automatically decrypted using your private key’s view key.

Execute Remote Program

leo run credits.aleo/transfer_public aleo1... 100u64
Leo will:
  1. Download the program from the network
  2. Download all dependencies
  3. Add programs to the VM
  4. Execute the function
Output:
⬇️ Downloading credits.aleo and its dependencies from https://api.explorer.provable.com/v1...

➕Adding programs to the VM in the following order:
  • credits.aleo (network)

➡️  Outputs

 • record1...
 • record1...

Execute with Custom Private Key

leo run main 1u32 2u32 --private-key APrivateKey1zkp...

Execute on Different Network

leo run main 1u32 2u32 --network testnet --endpoint https://api.explorer.provable.com/v1

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:
➡️  Output

 • 3u32
Multiple outputs:
➡️  Outputs

 • 3u32
 • true
 • 5field

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

Featureleo runleo execute
Proof GenerationNoYes
Network BroadcastNoOptional
Fee RequiredNoYes (if broadcasting)
SpeedFastSlower
Use CaseDevelopment/TestingProduction

Input Format Reference

Primitive Types

leo run main 42u32 true 5field

Addresses

leo run transfer aleo1abc... 100u64

Structs

leo run process '{ x: 1u32, y: 2u32 }'

Records

Plaintext:
leo run consume '{ owner: aleo1abc..., amount: 100u64 }'
Ciphertext:
leo run consume record1zy9q3y...

Troubleshooting

Function Not Found

Function `foo` does not exist in program `hello_world.aleo`.
Ensure the function exists and is a transition (entry point).

Invalid Input Format

Failed to parse input: invalid digit found in string
Check your input format matches the expected type.

Program Not Found

Running `leo run main ...` without an explicit program name requires that your current working directory is a valid Leo project.
Either:
  • Run from a Leo project directory, or
  • Use the qualified name: leo run program.aleo/function

Next Steps