leo build command compiles Leo programs into Aleo bytecode, processes dependencies, and generates the Application Binary Interface (ABI).
Syntax
Options
Network Options
Network type:
mainnet, testnet, or canary. Defaults to testnet.Endpoint URL for network dependencies. Defaults to
https://api.explorer.provable.com/v1.Build Options
Enables offline mode. Prevents network requests for dependencies.
Don’t use the dependency cache. Forces re-download of dependencies.
Don’t use local source code for dependencies. Use network versions instead.
Build tests along with the main program and dependencies.
Compiler Options
Enable dead code elimination in the compiler.
Maximum depth for type checking nested conditionals.
Disable type checking of nested conditional branches in finalize scope.
Debug Options
Enable spans in AST snapshots for debugging.
Write an AST snapshot immediately after parsing.
Write AST snapshots for all compiler phases.
Comma-separated list of passes whose AST snapshots to capture.
Examples
Basic Build
Build with Tests
Build Without Cache
Use
--no-cache when you want to force re-download of network dependencies.Build with AST Snapshots
outputs/ for each compiler pass.
Build for Specific Network
Build Output
The build process creates:main.aleo
Compiled Aleo bytecode:main.abi.json
ABI specification for programmatic interaction:Program Size Limits
Leo enforces a maximum program size:- Maximum size: 10 MB (10,485,760 bytes)
- Programs exceeding this limit will fail to build
Compiler Passes
The Leo compiler runs through multiple passes:- Parsing - Convert source to AST
- Symbol Resolution - Resolve identifiers
- Type Checking - Validate types
- Loop Unrolling - Unroll loops to fixed iterations
- Monomorphization - Convert generic types to concrete types
- Flattening - Flatten complex expressions
- Dead Code Elimination - Remove unused code
- Code Generation - Generate Aleo instructions
Checksum Verification
After building, Leo displays the program checksum:Dependencies
Leo automatically builds dependencies listed inprogram.json:
Troubleshooting
Compiler Version Mismatch
If you see a warning about compiler version mismatch:program.json to match your Leo version.
Network Dependencies Failed
If network dependencies fail to download:--endpoint configuration.