Skip to main content
The Leo CLI provides a comprehensive set of commands for developing, building, testing, and deploying Aleo programs.

Installation

Install the Leo CLI using the installation guide in the Getting Started section.

Command Structure

All Leo commands follow the structure:
leo <COMMAND> [OPTIONS] [ARGS]

Global Options

The following options are available across multiple commands:
--private-key
string
Private key to use for transactions. Overrides the PRIVATE_KEY environment variable.
Use APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH for local devnets only. NEVER use this key in production.
--network
string
Network type to use: mainnet, testnet, or canary. Overrides the NETWORK environment variable.
--endpoint
string
Endpoint URL for network operations. Overrides the ENDPOINT environment variable.
  • Use https://api.explorer.provable.com/v1 for live networks
  • Use http://localhost:3030 for local devnets
--devnet
boolean
Whether the network is a devnet. Defaults to the DEVNET environment variable.
--consensus-heights
string
Custom consensus heights (comma-separated). Only use with custom devnets.

Environment Variables

Leo reads configuration from environment variables and .env files:
  • PRIVATE_KEY - Default private key for transactions
  • NETWORK - Default network (mainnet, testnet, canary)
  • ENDPOINT - Default network endpoint
  • DEVNET - Whether the network is a devnet
  • CONSENSUS_VERSION_HEIGHTS - Custom consensus heights

Common Patterns

Development Workflow

# Create a new project
leo new my_project
cd my_project

# Build the program
leo build

# Run tests
leo test

# Execute locally
leo run main "1u32" "2u32"

# Deploy to network
leo deploy --broadcast --private-key <KEY>

# Execute on-chain
leo execute main "1u32" "2u32" --broadcast

Using Environment Files

Create a .env file in your project:
PRIVATE_KEY=APrivateKey1zkp...
NETWORK=testnet
ENDPOINT=https://api.explorer.provable.com/v1

Working with Dependencies

# Add a network dependency
leo add credits.aleo --network

# Add a local dependency
leo add my_lib --local ../my_lib

# Remove a dependency
leo remove credits.aleo

Command Categories

Project Management

Building & Testing

Execution

Deployment

Development Tools

Network Operations

Dependencies

Getting Help

Get help for any command:
leo --help
leo <command> --help

Verbose Output

Use the RUST_LOG environment variable for detailed logging:
RUST_LOG=trace leo build