Leo is a domain-specific programming language for building private smart contracts on the Aleo blockchain. Designed with developer ergonomics and security in mind, it combines:
Static typing (Rust-like syntax)
Built-in zk-SNARKs support
Full integration with Aleo Virtual Machine (snarkVM)
Requirements:
Rust 1.65+
Ubuntu 20.04+/macOS Monterey+
curl -L https://aleo.org/install_leo.sh | bash
leo --version
Standard project layout:
my_contract/
├── program.json # Configuration
├── inputs/ # Input data
│ └── hello.in # Sample input file
├── src/
│ └── main.leo # Main code
└── outputs/ # Generated files
// Primitive types
let boolean: bool = true;
let integer: u32 = 42;
let field: field = 0x1234field; // Finite field element
let group: group = 0x1234group; // Elliptic curve
// Composite types
struct Person {
age: u8,
address: address
}
// Arrays
let arr: [u8; 3] = [1, 2, 3];
function private add_one(private x: u32) -> u32 {
return x + 1;
}
// Public wrapper function
function add_one_public(x: u32) -> u32 {
return add_one(x);
}
function max(a: u32, b: u32) -> u32 {
if (a > b) {
return a;
} else {
return b;
}
}
// Data encryption
function encrypt_data(
private data: field,
public key: group
) -> field {
let encrypted = data + hash_to_field(key);
return encrypted;
}
struct Citizen {
age: u8,
ssn_hash: field
}
function verify_age(
private citizen: Citizen,
public min_age: u8
) -> bool {
return citizen.age >= min_age;
}
program private_auction.aleo {
// Auction state
struct Auction {
highest_bid: u64,
bidder: address,
is_open: bool
}
// Place bid
transition bid(
private current_auction: Auction,
private new_bid: u64,
private bidder: address
) -> Auction {
// Validate conditions
assert(current_auction.is_open);
assert(new_bid > current_auction.highest_bid);
// Update state
let new_auction = Auction {
highest_bid: new_bid,
bidder: bidder,
is_open: true
};
return new_auction;
}
// Close auction
transition close(
private auction: Auction,
public owner: address
) -> (address, u64) {
assert(auction.is_open);
let closed_auction = Auction {
is_open: false,
..auction
};
return (auction.bidder, auction.highest_bid);
}
}
leo build
leo run bid \
--auction "{highest_bid: 100u64, bidder: aleo1xyz..., is_open: true}" \
--new_bid 150u64 \
--bidder aleo1abc...
leo deploy
Minimize circular dependencies - Leo doesn't support recursion
Use inline
functions for frequently used code
Balance private/public operations - private computations are more expensive
assert(input_value != 0u64);
2. Avoid timestamps as truth sources
3. Use standard cryptographic functions from aleo/std
So, Leo enables developers to:
Build fully private dApps
Implement complex business logic with ZKPs
Create scalable solutions on Aleo
Next Steps:
Explore official documentation
Experiment with example contracts
Join the developer community
Links:
Website ~ https://www.aleo.org/
Twitter ~ https://twitter.com/AleoHQ
Community Twitter ~ https://twitter.com/aleocommunity
GitHub ~ https://github.com/AleoHQ
Community Forum — https://community.aleo.org/
Community Calendar ~ https://www.aleo.org/community/calendar
YouTube — https://www.youtube.com/channel/UCS_HKT2heOC_q88YQLiJt0g
Developer Documentation ~ https://developer.aleo.org/
Leo Playground ~ https://play.leo-lang.org/
Aleo Block Explorer ~ https://www.aleo.network/
Community Blog ~ https://medium.com/@AleoHQ
Announcements Blog ~ https://www.aleo.org/blog