Program Manifest (program.json)
Every Leo project has aprogram.json manifest file that defines metadata and dependencies.
Basic Structure
program.json
Manifest Fields
program (required)
program (required)
The unique name of your program, must end with Must follow naming rules:
.aleo:- Start with a letter
- Contain only ASCII alphanumeric characters and underscores
- Not contain the keyword “aleo” in the name
- Not be a reserved keyword
version (required)
version (required)
description (optional)
description (optional)
Human-readable description of your program:
license (required)
license (required)
Software license identifier:Common options:
MIT, Apache-2.0, GPL-3.0dependencies (optional)
dependencies (optional)
External programs your code depends on:
dev_dependencies (optional)
dev_dependencies (optional)
Dependencies only needed for testing:
Dependency Types
Network Dependencies
Import deployed programs from the Aleo network:src/main.leo
Network dependencies are automatically fetched from the Aleo network and cached locally in
~/.aleo/registry/{network}/{program}/{edition}/.Local Dependencies
Import programs from your local filesystem:Local Aleo File Dependencies
Import compiled.aleo bytecode files:
Dependency Editions
Specify a specific version (edition) of a network dependency:Dependency Resolution
Leo resolves dependencies in topological order:1
Parse Manifest
Leo reads
program.json and collects all dependencies:2
Build Dependency Graph
Constructs a directed graph of program dependencies:
3
Fetch Dependencies
For each dependency:
- Local: Read from filesystem
- Network: Fetch from Aleo network and cache
4
Topological Sort
Orders programs so dependencies are compiled before dependents:
Circular Dependency Detection
Leo detects and rejects circular dependencies:Working with Imports
Basic Import
Import an external program:Using Imported Types
Access structs and records from imported programs:Calling Imported Functions
Invoke functions from dependencies:Use the
program.aleo/item syntax to reference imported items.Package Structure
Leo expects a specific directory structure:Creating Packages
Initialize a new package:- Package directory structure
program.jsonwith defaults- Basic
src/main.leotemplate .gitignorefile- Sample test file
crates/package/src/package.rs:420-442:
Package Constants
Key directory names (fromcrates/package/src/lib.rs):
Dependency Caching
Cache Location
Network dependencies are cached in:Disabling Cache
Force fresh dependency fetches:Clearing Cache
Manually clear cached dependencies:Advanced Configuration
Multiple Dependencies
Combine local and network dependencies:Test Dependencies
Separate dependencies for tests:dependencies and dev_dependencies.
Dependency Conflicts
Leo detects conflicting dependencies:Program Size Limits
Programs have size limits (fromcrates/package/src/lib.rs):
Best Practices
1
Use Semantic Versioning
Version your programs following semver:
- MAJOR: Breaking changes
- MINOR: New features, backwards compatible
- PATCH: Bug fixes
2
Pin Critical Dependencies
Specify editions for production dependencies:
3
Document Dependencies
Add descriptions explaining why dependencies are needed:
4
Minimize Dependencies
Only include necessary dependencies to reduce:
- Build times
- Circuit size
- Attack surface
5
Test Dependency Changes
Run full test suite after updating dependencies:
Troubleshooting
Dependency Not Found
- Verify program name spelling
- Check network connectivity
- Confirm program exists on network
- Try with
--no-cache
Path Not Found
- Verify relative path is correct
- Check directory structure
- Ensure
program.jsonexists in target directory
Version Mismatch
- Ensure
programfield in manifest matches actual program name - Check imported program names match manifest declarations
Next Steps
- Review best practices for dependency management
- Learn about testing with dependencies
- Explore writing programs that others can depend on