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
The function to execute. Can be:
- Function name only:
main(uses program fromprogram.json) - Qualified name:
hello_world.aleo/main
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 type:
mainnet, testnet, or canary. Defaults to testnet.Endpoint URL for network operations.
Private key to use for execution. Defaults to test key for local execution.
Build Options
Enable offline mode. Prevents network requests.
Don’t use the dependency cache.
Use network versions of dependencies instead of local source.
Examples
Execute Default Function
main function with no inputs.
Execute with Inputs
Execute Specific Function
Execute with Qualified Name
Execute with Record Input
Plaintext record:Record ciphertexts starting with
record1 are automatically decrypted using your private key’s view key.Execute Remote Program
- Download the program from the network
- Download all dependencies
- Add programs to the VM
- Execute the function
Execute with Custom Private Key
Execute on Different Network
Execution Flow
-
Build Phase (if in Leo project):
- Compiles the program and dependencies
- Generates bytecode
-
VM Initialization:
- Creates an in-memory VM
- No persistent state
-
Program Loading:
- Loads local programs from
build/ - Downloads remote programs from network
- Adds programs in dependency order
- Loads local programs from
-
Authorization:
- Generates authorization for the function call
- Uses provided private key
-
Evaluation:
- Executes the function in the VM
- Returns outputs
Output Format
Single output: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
| Feature | leo run | leo execute |
|---|---|---|
| Proof Generation | No | Yes |
| Network Broadcast | No | Optional |
| Fee Required | No | Yes (if broadcasting) |
| Speed | Fast | Slower |
| Use Case | Development/Testing | Production |
Input Format Reference
Primitive Types
Addresses
Structs
Records
Plaintext:Troubleshooting
Function Not Found
transition (entry point).
Invalid Input Format
Program Not Found
- Run from a Leo project directory, or
- Use the qualified name:
leo run program.aleo/function